# extendify/3.2.0/src/Launch/state/pages-selections.js

Extendify, version 3.2.0. 43 lines.

- Page: https://pluginprobe.com/plugins/extendify/3.2.0/code/src/Launch/state/pages-selections.js
- Raw: https://pluginprobe.com/plugins/extendify/3.2.0/raw/src/Launch/state/pages-selections.js
- Modified: 2026-08-12T16:23:58+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/extendify/3.2.0/code/src/Launch/state/pages-selections.js#L10-L20`.

```javascript
import { safeParseJson } from '@shared/lib/parsing';
import { safeLocalStorage } from '@shared/state/safe-local-storage';
import { create } from 'zustand';
import { createJSONStorage, devtools, persist } from 'zustand/middleware';

const initialState = {
	pages: [],
	style: null,
};

const key = `extendify-launch-pages-selection-${window.extSharedData.siteId}`;
const state = (set, get) => ({
	// initialize the state with default values
	...initialState,
	...(safeParseJson(window.localStorage.getItem(key))?.state || {}),
	has(type, item) {
		if (!item?.id) return false;
		return (get()?.[type] ?? [])?.some((t) => t.id === item.id);
	},
	add(type, item) {
		if (get().has(type, item)) return;
		set({ [type]: [...(get()?.[type] ?? []), item] });
	},
	remove(type, item) {
		set({ [type]: get()?.[type]?.filter((t) => t.id !== item.id) });
	},
	removeAll(type) {
		set({ [type]: [] });
	},
	setStyle(style) {
		set({ style });
	},
});

export const usePagesSelectionStore = create(
	persist(devtools(state, { name: 'Extendify Launch Pages Selections' }), {
		name: key,
		storage: createJSONStorage(() => safeLocalStorage),
		skipHydration: true,
	}),
	state,
);

```
