Skip to content

Commit 7f12ba7

Browse files
committed
refactor: up to date
1 parent c1c5f42 commit 7f12ba7

File tree

63 files changed

+312
-215
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+312
-215
lines changed

containers/AccountEditor/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ const FormItem = ({ label, textarea, value, onChange }) => (
7878
)
7979

8080
class AccountEditorContainer extends React.Component {
81-
componentWillMount() {
81+
componentDidMount() {
8282
const { accountEditor } = this.props
8383
logic.init(accountEditor)
8484
}

containers/AccountViewer/index.js

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,16 +39,13 @@ const ThemeSection = ({ themeKeys, curTheme }) => {
3939
}
4040

4141
class AccountViewerContainer extends React.Component {
42-
componentWillMount() {
43-
const { accountViewer } = this.props
44-
logic.init(accountViewer)
45-
logic.loadAccount()
46-
}
47-
4842
componentDidMount() {
4943
/* force rebuild the tooltip, otherwise it won't work in some async cases */
5044
/* if you want to custom see: */
5145
/* https://github.com/wwayne/react-tooltip/blob/2364dc61332aa947b106dd4bbdd1f2b0e4b1e51d/src/index.scss */
46+
const { accountViewer, user } = this.props
47+
logic.init(accountViewer, user)
48+
5249
setTimeout(() => {
5350
ReactTooltip.rebuild()
5451
}, 2000)

containers/AccountViewer/logic.js

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111
} from '../../utils'
1212
import SR71 from '../../utils/network/sr71'
1313
import S from './schema'
14+
1415
/* eslint-disable no-unused-vars */
1516
const debug = makeDebugger('L:AccountViewer')
1617
/* eslint-enable no-unused-vars */
@@ -20,6 +21,7 @@ const sr71$ = new SR71({
2021
})
2122

2223
let store = null
24+
let sub$ = null
2325

2426
export function loadUser() {}
2527

@@ -80,7 +82,23 @@ const ErrSolver = [
8082
},
8183
]
8284

83-
export function init(selectedStore) {
84-
store = selectedStore
85-
sr71$.data().subscribe($solver(DataSolver, ErrSolver))
85+
export const loadUserInfo = user => {
86+
if (user) return loadUser(user)
87+
loadAccount()
88+
}
89+
90+
export function init(_store, user) {
91+
store = _store
92+
93+
if (sub$) return loadUserInfo(user)
94+
sub$ = sr71$.data().subscribe($solver(DataSolver, ErrSolver))
95+
96+
return loadUserInfo(user)
97+
}
98+
99+
export function uninit() {
100+
if (!sub$) return false
101+
debug('===== do uninit')
102+
sub$.unsubscribe()
103+
sub$ = null
86104
}

containers/ApiLayout/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ const debug = makeDebugger('C:ApiLayout')
1919
/* eslint-enable no-unused-vars */
2020

2121
class ApiLayoutContainer extends React.Component {
22-
componentWillMount() {
22+
componentDidMount() {
2323
const { apiLayout } = this.props
2424
logic.init(apiLayout)
2525
}

containers/ArticleViwer/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ const Viwer = ({ type, data, loading, onReaction }) => {
4040
}
4141

4242
class ArticleViwerContainer extends React.Component {
43-
componentWillMount() {
43+
componentDidMount() {
4444
const { articleViwer } = this.props
4545
logic.init(articleViwer)
4646
}

containers/Banner/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ const DomainBanner = ({ curRoute }) => {
3939
for some unkown reasion, pages/index will always be the entry in dev mode
4040
*/
4141
class BannerContainer extends React.Component {
42-
componentWillMount() {
42+
componentDidMount() {
4343
const { banner } = this.props
4444
logic.init(banner)
4545
}

containers/BodyLayout/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import Body from './styles'
1717
import * as logic from './logic'
1818

1919
class BodyLayoutContainer extends React.Component {
20-
componentWillMount() {
20+
componentDidMount() {
2121
const { bodylayout } = this.props
2222
logic.init(bodylayout)
2323
}

containers/CategoryEditor/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ const debug = makeDebugger('C:CategoryEditor')
2828
/* eslint-enable no-unused-vars */
2929

3030
class CategoryEditorContainer extends React.Component {
31-
componentWillMount() {
31+
componentDidMount() {
3232
const { categoryEditor, editData } = this.props
3333

3434
logic.init(categoryEditor, editData)

containers/CategorySetter/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ const CategoriesList = ({ communityId, categories, selectedids }) => (
3232
)
3333

3434
class CategorySetterContainer extends React.Component {
35-
componentWillMount() {
35+
componentDidMount() {
3636
const { categorySetter } = this.props
3737
logic.init(categorySetter)
3838
}

containers/CheatSheetContent/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ const Langs = ({ base }) => {
8181
}
8282

8383
class CheatSheetContentContainer extends React.Component {
84-
componentWillMount() {
84+
componentDidMount() {
8585
const { cheatSheetContent } = this.props
8686
logic.init(cheatSheetContent)
8787
}

0 commit comments

Comments
 (0)