Files
talk/src/core/client/stream/App/SetActiveTabMutation.ts
T
Wyatt Johnson dfdea2b9d2 [CORL-1150] Discussions Tab (#3050)
* feat: Added Site.topStories edge

* feat: Added User.ongoingDiscussions edge

* connect discussions tab to relay

* style discussions tab

* add message if no ongoing discussions

* style site name in story row

* fix: make line-heights relative

* add custom class hooks

* feat: condition display based on feature flag

* add target attribute to story links

* fix: expose some featureFlags

* fix: fixed sorting

* fix: copy fixes

Co-authored-by: tessalt <tessathornton@gmail.com>
Co-authored-by: Chi Vinh Le <vinh@vinh.tech>
2020-07-30 17:18:59 -04:00

31 lines
966 B
TypeScript

import { commitLocalUpdate, Environment } from "relay-runtime";
import { CoralContext } from "coral-framework/lib/bootstrap";
import { createMutationContainer, LOCAL_ID } from "coral-framework/lib/relay";
import { SetMainTabEvent } from "coral-stream/events";
export interface SetActiveTabInput {
tab: "COMMENTS" | "PROFILE" | "DISCUSSIONS" | "%future added value";
}
export type SetActiveTabMutation = (input: SetActiveTabInput) => Promise<void>;
export async function commit(
environment: Environment,
input: SetActiveTabInput,
{ eventEmitter }: Pick<CoralContext, "eventEmitter">
) {
return commitLocalUpdate(environment, (store) => {
const record = store.get(LOCAL_ID)!;
if (record.getValue("activeTab") !== input.tab) {
SetMainTabEvent.emit(eventEmitter, { tab: input.tab });
record.setValue(input.tab, "activeTab");
}
});
}
export const withSetActiveTabMutation = createMutationContainer(
"setActiveTab",
commit
);