vega-frontend-monorepo/apps/trading/stores/global.ts
macqbat 37a6217169
market page: break down components to smaller chunks for better performance (#1726)
* chore: break down components to smaller chunks for better performance

* chore: break down components to smaller chunks for better performance

* chore: break down components to smaller chunks for better performance - fix failing tests

* chore: break down components to smaller chunks for better performance - adjust token app cases

* chore: break down components to smaller chunks for better performance - small fixes

* chore: break down components to smaller chunks for better performance - small fixes

* chore: break down components to smaller chunks for better performance - small fixes

* chore: break down components to smaller chunks for better performance - small fixes

* chore: break down components to smaller chunks for better performance - add nwe store for pageTitle

* chore: break down components to smaller chunks for better performance - sm fix

* chore: break down components to smaller chunks for better performance - sm fix

* chore: break down components to smaller chunks for better performance - sm imprv

* chore: break down components to smaller chunks for better performance - change prop names

* chore: break down components to smaller chunks for better performance - fix some test

* chore: break down components to smaller chunks for better performance - change cypress url

* chore: break down components to smaller chunks for better perf - set back redundant changes

* chore: resolve conflicts

Co-authored-by: maciek <maciek@vegaprotocol.io>
2022-10-14 17:42:53 +02:00

34 lines
887 B
TypeScript

import { LocalStorage } from '@vegaprotocol/react-helpers';
import create from 'zustand';
interface GlobalStore {
networkSwitcherDialog: boolean;
landingDialog: boolean;
riskNoticeDialog: boolean;
marketId: string | null;
update: (store: Partial<Omit<GlobalStore, 'update'>>) => void;
}
interface PageTitleStore {
pageTitle: string | null;
updateTitle: (title: string) => void;
}
export const useGlobalStore = create<GlobalStore>((set) => ({
networkSwitcherDialog: false,
landingDialog: false,
riskNoticeDialog: false,
marketId: LocalStorage.getItem('marketId') || null,
update: (state) => {
set(state);
if (state.marketId) {
LocalStorage.setItem('marketId', state.marketId);
}
},
}));
export const usePageTitleStore = create<PageTitleStore>((set) => ({
pageTitle: null,
updateTitle: (title: string) => set({ pageTitle: title }),
}));