fix(store): singleton store guard
Signed-off-by: Innei <i@innei.in>
This commit is contained in:
parent
eb01d03012
commit
5a8725b507
|
|
@ -74,7 +74,7 @@ export const EntryItemWrapper: FC<
|
|||
[entry.entries.url],
|
||||
)
|
||||
const [isContextMenuOpen, setIsContextMenuOpen] = useState(false)
|
||||
useAnyPointDown(() => setIsContextMenuOpen(false))
|
||||
useAnyPointDown(() => isContextMenuOpen && setIsContextMenuOpen(false))
|
||||
const handleContextMenu: React.MouseEventHandler<HTMLDivElement> = useCallback(
|
||||
(e) => {
|
||||
e.preventDefault()
|
||||
|
|
|
|||
|
|
@ -145,7 +145,7 @@ function FeedCategoryImpl({ data: ids, view, categoryOpenStateData }: FeedCatego
|
|||
|
||||
const [isContextMenuOpen, setIsContextMenuOpen] = useState(false)
|
||||
useAnyPointDown(() => {
|
||||
setIsContextMenuOpen(false)
|
||||
isContextMenuOpen && setIsContextMenuOpen(false)
|
||||
})
|
||||
const isCategoryIsWaiting = isChangePending
|
||||
|
||||
|
|
|
|||
|
|
@ -81,7 +81,7 @@ const FeedItemImpl = ({ view, feedId, className }: FeedItemProps) => {
|
|||
|
||||
const [isContextMenuOpen, setIsContextMenuOpen] = useState(false)
|
||||
useAnyPointDown(() => {
|
||||
setIsContextMenuOpen(false)
|
||||
isContextMenuOpen && setIsContextMenuOpen(false)
|
||||
})
|
||||
if (!feed) return null
|
||||
|
||||
|
|
@ -208,7 +208,7 @@ const ListItemImpl: Component<{
|
|||
|
||||
const [isContextMenuOpen, setIsContextMenuOpen] = useState(false)
|
||||
useAnyPointDown(() => {
|
||||
setIsContextMenuOpen(false)
|
||||
isContextMenuOpen && setIsContextMenuOpen(false)
|
||||
})
|
||||
const subscription = useSubscriptionByFeedId(listId)
|
||||
const navigate = useNavigateEntry()
|
||||
|
|
@ -291,7 +291,7 @@ const InboxItemImpl: Component<{
|
|||
|
||||
const [isContextMenuOpen, setIsContextMenuOpen] = useState(false)
|
||||
useAnyPointDown(() => {
|
||||
setIsContextMenuOpen(false)
|
||||
isContextMenuOpen && setIsContextMenuOpen(false)
|
||||
})
|
||||
const navigate = useNavigateEntry()
|
||||
const handleNavigate = useCallback(
|
||||
|
|
|
|||
|
|
@ -34,6 +34,11 @@ const storeMap = {} as Record<string, UseBoundStoreWithEqualityFn<any>>
|
|||
export const createZustandStore =
|
||||
<S, T extends StateCreator<S, [], []> = StateCreator<S, [], []>>(name: string) =>
|
||||
(store: T) => {
|
||||
if (import.meta.env.DEV && window[`store_${name}`]) {
|
||||
import.meta.hot?.send("message", "The store has been changed, reloading...")
|
||||
globalThis.location.reload()
|
||||
}
|
||||
|
||||
const newStore = import.meta.env.DEV
|
||||
? createWithEqualityFn(
|
||||
devtools(store, {
|
||||
|
|
@ -60,6 +65,8 @@ export const createZustandStore =
|
|||
},
|
||||
)
|
||||
|
||||
window[`store_${name}`] = newStore
|
||||
|
||||
return newStore
|
||||
}
|
||||
type FunctionKeys<T> = {
|
||||
|
|
|
|||
|
|
@ -44,6 +44,11 @@ function isNodeWithinCircularImports(
|
|||
|
||||
export const circularImportRefreshPlugin = (): Plugin => ({
|
||||
name: "circular-import-refresh",
|
||||
configureServer(server) {
|
||||
server.ws.on("message", (message) => {
|
||||
console.info(message)
|
||||
})
|
||||
},
|
||||
handleHotUpdate({ file, server }: HmrContext) {
|
||||
const mod = server.moduleGraph.getModuleById(file)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue