mirror of
https://github.com/penxio/penx.git
synced 2026-01-13 15:38:12 -05:00
28 lines
708 B
TypeScript
28 lines
708 B
TypeScript
import React, { useState } from 'react'
|
|
import { selectedSpaceKey, spacesKey } from '@/lib/helper'
|
|
import { useStorage } from '@plasmohq/storage/hook'
|
|
|
|
// import { selectedSpaceKey, spacesKey, storageDocKey } from '~/common/helper'
|
|
|
|
export function useSelectedSpace() {
|
|
const [selectedSpace, setSelectedSpace] = useStorage(selectedSpaceKey, '')
|
|
return { selectedSpace, setSelectedSpace }
|
|
}
|
|
|
|
export function useMySpaces() {
|
|
const [mySpaces, setMySpaces] = useStorage<any[]>(spacesKey, [])
|
|
return { mySpaces, setMySpaces }
|
|
}
|
|
|
|
export function useForceUpdate() {
|
|
const [_, setCount] = useState(0)
|
|
|
|
const forceUpdate = () => {
|
|
setCount((count) => count + 1)
|
|
}
|
|
|
|
return {
|
|
forceUpdate,
|
|
}
|
|
}
|