mirror of
https://github.com/wassname/talk.git
synced 2026-08-12 12:30:39 +08:00
* save comment sort order preference in local storage * await async localstorage operation Co-authored-by: Wyatt Johnson <accounts+github@wyattjoh.ca>
25 lines
858 B
TypeScript
25 lines
858 B
TypeScript
import { Environment } from "relay-runtime";
|
|
|
|
import { CoralContext } from "coral-framework/lib/bootstrap";
|
|
import { createMutation } from "coral-framework/lib/relay";
|
|
import { commit as signOut } from "coral-framework/mutations/SignOutMutation";
|
|
import { COMMENTS_ORDER_BY } from "coral-stream/constants";
|
|
import { SignOutEvent } from "coral-stream/events";
|
|
|
|
const SignOutMutation = createMutation(
|
|
"signOut",
|
|
async (environment: Environment, input: undefined, ctx: CoralContext) => {
|
|
const signOutEvent = SignOutEvent.begin(ctx.eventEmitter);
|
|
try {
|
|
await ctx.localStorage.removeItem(COMMENTS_ORDER_BY);
|
|
await signOut(environment, input, ctx);
|
|
signOutEvent.success();
|
|
} catch (error) {
|
|
signOutEvent.error({ message: error.message, code: error.code });
|
|
throw error;
|
|
}
|
|
}
|
|
);
|
|
|
|
export default SignOutMutation;
|