mirror of
https://github.com/wassname/talk.git
synced 2026-07-02 15:23:56 +08:00
dfdea2b9d2
* 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>
31 lines
966 B
TypeScript
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
|
|
);
|