-
-
Notifications
You must be signed in to change notification settings - Fork 754
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: replace jotai hook with jojoo
Signed-off-by: Innei <i@innei.in>
- Loading branch information
Showing
11 changed files
with
68 additions
and
169 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,6 @@ | ||
import { atom, useAtomValue } from 'jotai' | ||
import { createAtomHooks } from 'jojoo/react' | ||
import { atom } from 'jotai' | ||
|
||
import { jotaiStore } from '~/lib/store' | ||
|
||
const cssPrintMediaAtom = atom(false) | ||
|
||
export const useIsPrintMode = () => useAtomValue(cssPrintMediaAtom) | ||
|
||
export const setIsPrintMode = (status: boolean) => | ||
jotaiStore.set(cssPrintMediaAtom, status) | ||
export const [, , useIsPrintMode, , , setIsPrintMode] = createAtomHooks( | ||
atom(false), | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,8 @@ | ||
import { atom, useAtomValue } from 'jotai' | ||
import { createAtomHooks } from 'jojoo/react' | ||
import { setStore } from 'jojoo' | ||
import { atom } from 'jotai' | ||
|
||
import { jotaiStore } from '~/lib/store' | ||
|
||
const onlineCountAtom = atom(0) | ||
|
||
export const setOnlineCount = (count: number) => { | ||
jotaiStore.set(onlineCountAtom, count) | ||
} | ||
|
||
export const useOnlineCount = () => { | ||
return useAtomValue(onlineCountAtom) | ||
} | ||
setStore(jotaiStore) | ||
export const [, , useOnlineCount, , , setOnlineCount] = createAtomHooks(atom(0)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
import { createStore } from 'jotai' | ||
import { setStore } from 'jojoo' | ||
import { createStore } from 'jotai/vanilla' | ||
|
||
export const jotaiStore = createStore() | ||
const jotaiStore = createStore() | ||
setStore(jotaiStore) | ||
|
||
export { jotaiStore } |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,30 @@ | ||
'use client' | ||
|
||
import { createModelDataProvider } from 'jojoo/react' | ||
import type { PageModel } from '@mx-space/api-client' | ||
|
||
import { isClientSide, isDev } from '~/lib/env' | ||
|
||
import { createDataProvider } from '../internal/createDataProvider' | ||
|
||
const { | ||
CurrentDataProvider, | ||
getGlobalCurrentData: getCurrentData, | ||
setGlobalCurrentData: setCurrentData, | ||
useCurrentDataSelector, | ||
CurrentDataAtomProvider, | ||
} = createDataProvider<PageModel>() | ||
ModelDataProvider, | ||
getGlobalModelData: getModelData, | ||
setGlobalModelData: setModelData, | ||
useModelDataSelector, | ||
ModelDataAtomProvider, | ||
} = createModelDataProvider<PageModel>() | ||
|
||
declare global { | ||
interface Window { | ||
getCurrentPageData: typeof getCurrentData | ||
getCurrentPageData: typeof getModelData | ||
} | ||
} | ||
if (isDev && isClientSide) window.getCurrentPageData = getCurrentData | ||
|
||
if (isDev && isClientSide) window.getCurrentPageData = getModelData | ||
|
||
export { | ||
CurrentDataProvider as CurrentPageDataProvider, | ||
getCurrentData as getCurrentPageData, | ||
setCurrentData as setCurrentPageData, | ||
useCurrentDataSelector as useCurrentPageDataSelector, | ||
CurrentDataAtomProvider as CurrentPageDataAtomProvider, | ||
ModelDataProvider as CurrentPageDataProvider, | ||
getModelData as getCurrentPageData, | ||
setModelData as setCurrentPageData, | ||
useModelDataSelector as useCurrentPageDataSelector, | ||
ModelDataAtomProvider as CurrentPageDataAtomProvider, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,29 @@ | ||
'use client' | ||
|
||
import { createModelDataProvider } from 'jojoo/react' | ||
import type { PostModel } from '@mx-space/api-client' | ||
|
||
import { isClientSide, isDev } from '~/lib/env' | ||
|
||
import { createDataProvider } from '../internal/createDataProvider' | ||
|
||
const { | ||
CurrentDataProvider, | ||
CurrentDataAtomProvider, | ||
getGlobalCurrentData, | ||
setGlobalCurrentData, | ||
useCurrentDataSelector, | ||
} = createDataProvider<PostModel>() | ||
ModelDataProvider, | ||
ModelDataAtomProvider, | ||
getGlobalModelData, | ||
setGlobalModelData, | ||
useModelDataSelector, | ||
} = createModelDataProvider<PostModel>() | ||
|
||
declare global { | ||
interface Window { | ||
getCurrentPostData: typeof getGlobalCurrentData | ||
getModelPostData: typeof getGlobalModelData | ||
} | ||
} | ||
if (isDev && isClientSide) window.getCurrentPostData = getGlobalCurrentData | ||
if (isDev && isClientSide) window.getModelPostData = getGlobalModelData | ||
|
||
export { | ||
CurrentDataProvider as CurrentPostDataProvider, | ||
CurrentDataAtomProvider as CurrentPostDataAtomProvider, | ||
getGlobalCurrentData as getGlobalCurrentPostData, | ||
setGlobalCurrentData as setGlobalCurrentPostData, | ||
useCurrentDataSelector as useCurrentPostDataSelector, | ||
ModelDataProvider as CurrentPostDataProvider, | ||
ModelDataAtomProvider as CurrentPostDataAtomProvider, | ||
getGlobalModelData as getGlobalCurrentPostData, | ||
setGlobalModelData as setGlobalCurrentPostData, | ||
useModelDataSelector as useCurrentPostDataSelector, | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
7a1aaa1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
shiro – ./
shiro-innei.vercel.app
springtide.vercel.app
shiro-git-main-innei.vercel.app
innei.in