Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(mobx): use new useStore arch & update mobx deps #169

Merged
merged 44 commits into from
Nov 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
ecf4aa4
refactor(mobx): upgrade deps & use react-mobx-lite export
mydearxym Nov 3, 2023
cf4e057
refactor(poc): new useStore workflow wip
mydearxym Nov 3, 2023
dad1a65
refactor: wip
mydearxym Nov 4, 2023
fc5fd06
refactor: wip
mydearxym Nov 4, 2023
ad324c0
refactor: wip
mydearxym Nov 4, 2023
6a251ee
refactor: wip
mydearxym Nov 4, 2023
0595b51
refactor: wip
mydearxym Nov 4, 2023
98d32f0
refactor: wip
mydearxym Nov 4, 2023
30a191f
refactor: wip
mydearxym Nov 4, 2023
8177383
refactor: wip
mydearxym Nov 5, 2023
302d509
refactor: wip
mydearxym Nov 5, 2023
53db449
refactor: wip
mydearxym Nov 5, 2023
c1425d6
refactor: wip
mydearxym Nov 5, 2023
d4f9f66
refactor: wip
mydearxym Nov 5, 2023
bfe74ca
refactor: wip
mydearxym Nov 5, 2023
37d8821
refactor: wip
mydearxym Nov 5, 2023
0015f76
refactor: wip
mydearxym Nov 5, 2023
b606911
refactor: wip
mydearxym Nov 5, 2023
3ede124
refactor: wip
mydearxym Nov 5, 2023
5357821
refactor: wip
mydearxym Nov 5, 2023
623ea5a
refactor: wip
mydearxym Nov 5, 2023
f57c33e
refactor: wip
mydearxym Nov 5, 2023
5d27630
refactor: wip
mydearxym Nov 5, 2023
bbd697c
refactor: wip
mydearxym Nov 5, 2023
756f209
refactor: wip
mydearxym Nov 5, 2023
c68a074
refactor: wip
mydearxym Nov 5, 2023
dd42b49
refactor: wip
mydearxym Nov 5, 2023
ceff3fe
refactor: wip
mydearxym Nov 5, 2023
51460af
refactor: wip
mydearxym Nov 5, 2023
696d3df
refactor: wip
mydearxym Nov 5, 2023
73e653f
refactor: wip
mydearxym Nov 5, 2023
1316be6
refactor: wip
mydearxym Nov 5, 2023
a214822
refactor: wip
mydearxym Nov 5, 2023
cc6cad3
refactor: wip
mydearxym Nov 5, 2023
59f2df5
refactor: wip
mydearxym Nov 5, 2023
4901fb1
refactor: wip
mydearxym Nov 5, 2023
a863d99
refactor: wip
mydearxym Nov 5, 2023
1a626d4
refactor: wip
mydearxym Nov 5, 2023
2c85307
refactor: wip
mydearxym Nov 5, 2023
86f8ee8
refactor: wip
mydearxym Nov 5, 2023
a2c87a6
refactor: wip
mydearxym Nov 5, 2023
b2bea44
refactor: wip
mydearxym Nov 5, 2023
21c0c5b
refactor: wip
mydearxym Nov 5, 2023
ffa9b7b
refactor: wip
mydearxym Nov 5, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion config/version.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export const APP_VERSION = '1.2.49'
export const APP_VERSION = '1.2.50'
10,137 changes: 5,219 additions & 4,918 deletions package-lock.json

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
}
},
"dependencies": {
"@formkit/auto-animate": "^1.0.0-beta.6",
"@formkit/auto-animate": "^0.8.0",
"@fortawesome/fontawesome-svg-core": "^6.2.1",
"@fortawesome/free-regular-svg-icons": "^6.2.1",
"@fortawesome/free-solid-svg-icons": "^6.2.1",
Expand All @@ -55,11 +55,11 @@
"graphql": "^16.6.0",
"markdown-to-jsx": "^7.2.1",
"mastani-codehighlight": "0.0.7",
"mobx": "^6.7.0",
"mobx-react": "^7.6.0",
"mobx-state-tree": "^5.1.6",
"mobx-react": "^9.0.0",
"mobx-react-lite": "^4.0.5",
"mobx-state-tree": "^5.3.0",
"nanoid": "^3.1.12",
"next": "^14.0.0",
"next": "^14.0.1",
"next-compose-plugins": "^2.2.0",
"next-i18next": "4.4.1",
"next-pwa": "^5.6.0",
Expand Down
11 changes: 6 additions & 5 deletions src/containers/Route/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,18 @@
*
*/

import React from 'react'
import { useRouter } from 'next/router'
import { observer } from 'mobx-react-lite'

import { bond } from '@/mobx'
import { useStore } from './store'
import { useInit } from './logic'

const RouteContainer = ({ route }) => {
const Route = () => {
const store = useStore()
const router = useRouter()
useInit(route, router)
useInit(store, router)

return <div />
}

export default bond(RouteContainer, 'route')
export default observer(Route)
3 changes: 2 additions & 1 deletion src/containers/Route/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { merge, pickBy, omit, isEmpty } from 'ramda'
import type { TRootStore, TRoute } from '@/spec'
import { PAGE_SIZE } from '@/config'

import { T, getParent, Instance, markStates } from '@/mobx'
import { T, getParent, Instance, markStates, useMobxContext } from '@/mobx'
import { Global } from '@/helper'
import { isClientSide } from '@/utils/ssr'
import { serializeQuery } from '@/utils/route'
Expand Down Expand Up @@ -103,5 +103,6 @@ const RouteStore = T.model('RouteStore', {
}))

export type TStore = Instance<typeof RouteStore>
export const useStore = (): TStore => useMobxContext().store.route

export default RouteStore
13 changes: 5 additions & 8 deletions src/containers/content/CommunityContent/AboutContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,27 @@
*/

import { FC } from 'react'
import { observer } from 'mobx-react-lite'
import useMobileDetect from '@groupher/use-mobile-detect-hook'

import useBannerLayout from '@/hooks/useBannerLayout'
import useMetric from '@/hooks/useMetric'

import { bond } from '@/mobx'
import { BANNER_LAYOUT } from '@/constant/layout'

import AboutThread from '@/containers/thread/AboutThread'
import CommunityDigest from '@/widgets/CommunityDigest'

import type { TStore } from './store'
import { useStore } from './store'
import { useInit } from './logic'

import { Wrapper, SidebarWrapper, InnerWrapper, ContentWrapper, MobileCardsWrapper } from './styles'

type TProps = {
communityContent?: TStore
}

/**
* only for AboutThread, but link to the common communityContent store
*/
const CommunityContentContainer: FC<TProps> = ({ communityContent: store }) => {
const AboutContent: FC = () => {
const store = useStore()
useInit(store)

const metric = useMetric()
Expand Down Expand Up @@ -55,4 +52,4 @@ const CommunityContentContainer: FC<TProps> = ({ communityContent: store }) => {
)
}

export default bond(CommunityContentContainer, 'communityContent') as FC<TProps>
export default observer(AboutContent)
12 changes: 4 additions & 8 deletions src/containers/content/CommunityContent/ChangeLogContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,21 @@ import useMobileDetect from '@groupher/use-mobile-detect-hook'
import useMetric from '@/hooks/useMetric'
import useBannerLayout from '@/hooks/useBannerLayout'

import { bond } from '@/mobx'
import { BANNER_LAYOUT } from '@/constant/layout'

import ChangelogThread from '@/containers/thread/ChangelogThread'
import CommunityDigest from '@/widgets/CommunityDigest'

import type { TStore } from './store'
import { useStore } from './store'
import { useInit } from './logic'

import { Wrapper, SidebarWrapper, InnerWrapper, ContentWrapper, MobileCardsWrapper } from './styles'

type TProps = {
communityContent?: TStore
}

/**
* only for AboutThread, but link to the common communityContent store
*/
const CommunityContentContainer: FC<TProps> = ({ communityContent: store }) => {
const ChangelogContent: FC = () => {
const store = useStore()
useInit(store)
const metric = useMetric()
const bannerLayout = useBannerLayout()
Expand Down Expand Up @@ -55,4 +51,4 @@ const CommunityContentContainer: FC<TProps> = ({ communityContent: store }) => {
)
}

export default bond(CommunityContentContainer, 'communityContent') as FC<TProps>
export default ChangelogContent
20 changes: 7 additions & 13 deletions src/containers/content/CommunityContent/DashboardContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,14 @@
*/

import { FC } from 'react'
import { observer } from 'mobx-react-lite'
import useMobileDetect from '@groupher/use-mobile-detect-hook'

import type { TMetric } from '@/spec'
import METRIC from '@/constant/metric'

import { bond } from '@/mobx'

import useMetric from '@/hooks/useMetric'
import DashboardThread from '@/containers//thread/DashboardThread'
import CommunityDigest from '@/widgets/CommunityDigest'

import type { TStore } from './store'
import { useStore } from './store'
import { useInit } from './logic'

import {
Expand All @@ -23,16 +20,13 @@ import {
MobileCardsWrapper,
} from './styles/dashboard_content'

type TProps = {
communityContent?: TStore
metric?: TMetric
}

/**
* only for AboutThread, but link to the common communityContent store
*/
const DashboardContainer: FC<TProps> = ({ communityContent: store, metric = METRIC.DASHBOARD }) => {
const DashboardContent: FC = () => {
const store = useStore()
useInit(store)
const metric = useMetric()

const { isMobile } = useMobileDetect()

Expand All @@ -56,4 +50,4 @@ const DashboardContainer: FC<TProps> = ({ communityContent: store, metric = METR
)
}

export default bond(DashboardContainer, 'communityContent') as FC<TProps>
export default observer(DashboardContent)
16 changes: 6 additions & 10 deletions src/containers/content/CommunityContent/DocContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,25 @@
*/

import { FC } from 'react'
import { observer } from 'mobx-react-lite'
import useMobileDetect from '@groupher/use-mobile-detect-hook'

import { bond } from '@/mobx'
import { BANNER_LAYOUT } from '@/constant/layout'

import useMetric from '@/hooks/useMetric'
import useBannerLayout from '@/hooks/useBannerLayout'
import DocThread from '@/containers//thread/DocThread'
import CommunityDigest from '@/widgets/CommunityDigest'

import type { TStore } from './store'
import { useStore } from './store'
import { useInit } from './logic'

import { Wrapper, InnerWrapper, SidebarWrapper, ContentWrapper, MobileCardsWrapper } from './styles'
import useMetric from '@/hooks/useMetric'

type TProps = {
communityContent?: TStore
}

/**
* only for AboutThread, but link to the common communityContent store
*/
const CommunityContentContainer: FC<TProps> = ({ communityContent: store }) => {
const DocContent: FC = () => {
const store = useStore()
useInit(store)
const metric = useMetric()

Expand Down Expand Up @@ -55,4 +51,4 @@ const CommunityContentContainer: FC<TProps> = ({ communityContent: store }) => {
)
}

export default bond(CommunityContentContainer, 'communityContent') as FC<TProps>
export default observer(DocContent)
13 changes: 5 additions & 8 deletions src/containers/content/CommunityContent/KanbanContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,25 @@
*/

import { FC } from 'react'
import { observer } from 'mobx-react-lite'

import { bond } from '@/mobx'
import { BANNER_LAYOUT } from '@/constant/layout'
import useBannerLayout from '@/hooks/useBannerLayout'
import useMetric from '@/hooks/useMetric'

import KanbanThread from '@/containers//thread/KanbanThread'
import CommunityDigest from '@/widgets/CommunityDigest'

import type { TStore } from './store'
import { useStore } from './store'
import { useInit } from './logic'

import { Wrapper, InnerWrapper, SidebarWrapper, ContentWrapper, MobileCardsWrapper } from './styles'

type TProps = {
communityContent?: TStore
}

/**
* only for AboutThread, but link to the common communityContent store
*/
const CommunityContentContainer: FC<TProps> = ({ communityContent: store }) => {
const KanbanContent: FC = () => {
const store = useStore()
useInit(store)
const bannerLayout = useBannerLayout()
const metric = useMetric()
Expand All @@ -48,4 +45,4 @@ const CommunityContentContainer: FC<TProps> = ({ communityContent: store }) => {
)
}

export default bond(CommunityContentContainer, 'communityContent') as FC<TProps>
export default observer(KanbanContent)
13 changes: 5 additions & 8 deletions src/containers/content/CommunityContent/PostContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
*/

import { FC } from 'react'
import { observer } from 'mobx-react-lite'

import { bond } from '@/mobx'
import { BANNER_LAYOUT } from '@/constant/layout'
// import { THREAD } from '@/constant/thread'
import useMetric from '@/hooks/useMetric'
Expand All @@ -15,19 +15,16 @@ import CommunityDigest from '@/widgets/CommunityDigest'
import { Br } from '@/widgets/Common'
// import SidebarLayoutHeader from '@/widgets/SidebarLayoutHeader'

import type { TStore } from './store'
import { useStore } from './store'
import { useInit } from './logic'

import { Wrapper, SidebarWrapper, InnerWrapper, ContentWrapper, MobileCardsWrapper } from './styles'

type TProps = {
communityContent?: TStore
}

/**
* only for AboutThread, but link to the common communityContent store
*/
const CommunityContentContainer: FC<TProps> = ({ communityContent: store }) => {
const PostContent: FC = () => {
const store = useStore()
useInit(store)
const metric = useMetric()
const bannerLayout = useBannerLayout()
Expand Down Expand Up @@ -61,4 +58,4 @@ const CommunityContentContainer: FC<TProps> = ({ communityContent: store }) => {
)
}

export default bond(CommunityContentContainer, 'communityContent') as FC<TProps>
export default observer(PostContent)
41 changes: 0 additions & 41 deletions src/containers/content/CommunityContent/ThreadContent.tsx

This file was deleted.

38 changes: 0 additions & 38 deletions src/containers/content/CommunityContent/index.tsx

This file was deleted.

Loading
Loading