Skip to content

Commit

Permalink
refactor(mobx): use new useStore arch & update mobx deps (#169)
Browse files Browse the repository at this point in the history
* refactor(mobx): upgrade deps & use react-mobx-lite export

* refactor(poc): new useStore workflow wip

* refactor: wip

* refactor: wip

* refactor: wip

* refactor: wip

* refactor: wip

* refactor: wip

* refactor: wip

* refactor: wip

* refactor: wip

* refactor: wip

* refactor: wip

* refactor: wip

* refactor: wip

* refactor: wip

* refactor: wip

* refactor: wip

* refactor: wip

* refactor: wip

* refactor: wip

* refactor: wip

* refactor: wip

* refactor: wip

* refactor: wip

* refactor: wip

* refactor: wip

* refactor: wip

* refactor: wip

* refactor: wip

* refactor: wip

* refactor: wip

* refactor: wip

* refactor: wip

* refactor: wip

* refactor: wip

* refactor: wip

* refactor: wip

* refactor: wip

* refactor: wip

* refactor: wip

* refactor: wip

* refactor: wip

* refactor: wip
  • Loading branch information
mydearxym authored Nov 5, 2023
1 parent eb8b27f commit 28f30d3
Show file tree
Hide file tree
Showing 303 changed files with 5,747 additions and 9,253 deletions.
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

0 comments on commit 28f30d3

Please sign in to comment.