# code-block-pro/1.5.0/src/state/global.ts

Code Block Pro – Beautiful Syntax Highlighting, version 1.5.0. 50 lines.

- Page: https://pluginprobe.com/plugins/code-block-pro/1.5.0/code/src/state/global.ts
- Raw: https://pluginprobe.com/plugins/code-block-pro/1.5.0/raw/src/state/global.ts
- Modified: 2022-08-22T22:25:46+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/code-block-pro/1.5.0/code/src/state/global.ts#L10-L20`.

```typescript
import create from 'zustand';
import { devtools, persist } from 'zustand/middleware';

type GlobalTypes = {
    seenNotices: string[];
    setSeenNotice: (notice: string) => void;
    previousSettings: {
        copyButton: boolean;
    };
    setPreviousSettings: (
        settings: Partial<GlobalTypes['previousSettings']>,
    ) => void;
};
export const useGlobalStore = create<GlobalTypes>()(
    persist(
        devtools(
            (set) => ({
                seenNotices: [],
                setSeenNotice(notice: string) {
                    set((state) => {
                        if (state.seenNotices.includes(notice)) return state;
                        return { seenNotices: [...state.seenNotices, notice] };
                    });
                },
                // If any of these values have changed, we will use these for defaults.
                // Themes and languages are handled separately.
                previousSettings: {
                    copyButton: true,
                },
                setPreviousSettings(
                    s: Partial<GlobalTypes['previousSettings']>,
                ) {
                    set((state) => ({
                        previousSettings: { ...state.previousSettings, ...s },
                    }));
                },
            }),
            { name: 'Code Block Pro Globals' },
        ),
        {
            name: 'code-block-pro-last-globals',
            getStorage: () => localStorage,
            partialize: (state) => ({
                seenNotices: state?.seenNotices ?? [],
                previousSettings: state?.previousSettings ?? {},
            }),
        },
    ),
);

```
