Skip to content
This repository was archived by the owner on Nov 1, 2021. It is now read-only.

Commit 7f12ba7

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

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
}

containers/Comments/index.js

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

2323
class CommentsContainer extends React.Component {
24-
componentWillMount() {
24+
componentDidMount() {
2525
const { comments } = this.props
2626
logic.init(comments)
2727
}

containers/CommunitiesBanner/CategoryBanner.js

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

1919
class CategoryBanner extends React.Component {
20-
componentWillMount() {
20+
componentDidMount() {
2121
logic.loadCategories()
2222
}
2323

containers/CommunitiesBanner/EditorsBanner.js

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

1919
class EditorsBanner extends React.Component {
20-
componentWillMount() {
20+
componentDidMount() {
2121
// logic.loadEditors()
2222
}
2323

containers/CommunitiesBanner/IndexBanner.js

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

1919
class IndexBanner extends React.Component {
20-
componentWillMount() {
20+
componentDidMount() {
2121
logic.loadCommunities()
2222
}
2323

containers/CommunitiesBanner/JobsBanner.js

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

1919
class JobsBanner extends React.Component {
20-
componentWillMount() {
20+
componentDidMount() {
2121
logic.loadJobs()
2222
}
2323

containers/CommunitiesBanner/PostsBanner.js

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

1919
class PostsBanner extends React.Component {
20-
componentWillMount() {
20+
componentDidMount() {
2121
logic.loadPosts()
2222
}
2323

containers/CommunitiesBanner/TagsBanner.js

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

1919
class TagsBanner extends React.Component {
20-
componentWillMount() {
20+
componentDidMount() {
2121
logic.loadTags()
2222
}
2323

containers/CommunitiesBanner/ThreadsBanner.js

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

1919
class ThreadsBanner extends React.Component {
20-
componentWillMount() {
20+
componentDidMount() {
2121
logic.loadThreads()
2222
}
2323

containers/CommunitiesBanner/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ const ChildBanner = ({ curRoute, store }) => {
9999
}
100100

101101
class CommunitiesBannerContainer extends React.Component {
102-
componentWillMount() {
102+
componentDidMount() {
103103
const { communitiesBanner } = this.props
104104
logic.init(communitiesBanner)
105105
}

containers/CommunitiesContent/CategoriesContent.js

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -110,14 +110,9 @@ const columns = [
110110
]
111111

112112
class CategoriesContent extends React.Component {
113-
componentWillMount() {
113+
componentDidMount() {
114114
logic.loadCategories()
115-
}
116115

117-
componentDidMount() {
118-
/* force rebuild the tooltip, otherwise it won't work in some async cases */
119-
/* if you want to custom see: */
120-
/* https://github.com/wwayne/react-tooltip/blob/2364dc61332aa947b106dd4bbdd1f2b0e4b1e51d/src/index.scss */
121116
setTimeout(() => {
122117
ReactTooltip.rebuild()
123118
}, 2000)

containers/CommunitiesContent/IndexContent.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ const columns = [
163163
]
164164

165165
class IndexContent extends React.Component {
166-
componentWillMount() {
166+
componentDidMount() {
167167
logic.loadCommunitiesIfOnClient()
168168
}
169169

containers/CommunitiesContent/JobsContent.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ const columns = [
158158
]
159159

160160
class JobsContent extends React.Component {
161-
componentWillMount() {
161+
componentDidMount() {
162162
logic.loadJobs()
163163
}
164164

containers/CommunitiesContent/PostsContent.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ const columns = [
165165
]
166166

167167
class PostsContent extends React.Component {
168-
componentWillMount() {
168+
componentDidMount() {
169169
logic.loadPosts()
170170
}
171171

containers/CommunitiesContent/ThreadsContent.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,8 @@ const columns = [
8989
]
9090

9191
class ThreadsContent extends React.Component {
92-
componentWillMount() {
93-
console.log('ThreadsContent ,componentWillMount')
92+
componentDidMount() {
93+
console.log('ThreadsContent ,componentDidMount')
9494
logic.loadThreadsIfOnClient()
9595
}
9696

containers/CommunitiesContent/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ const renderChildContent = (curRoute, store, restProps) => {
6363
}
6464

6565
class CommunitiesContentContainer extends React.Component {
66-
componentWillMount() {
66+
componentDidMount() {
6767
const { communitiesContent } = this.props
6868
logic.init(communitiesContent)
6969
}

containers/CommunityBanner/PostsBanner.js

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

1919
class PostsBanner extends React.Component {
20-
componentWillMount() {
20+
componentDidMount() {
2121
logic.loadPosts()
2222
}
2323

containers/CommunityBanner/SubscribersBanner.js

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

1919
class SubscribersBanner extends React.Component {
20-
componentWillMount() {
20+
componentDidMount() {
2121
logic.loadUsers()
2222
}
2323

containers/CommunityBanner/TagsBanner.js

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

1919
class TagsBanner extends React.Component {
20-
componentWillMount() {
20+
componentDidMount() {
2121
logic.loadTags()
2222
}
2323

containers/CommunityBanner/ThreadsBanner.js

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

1919
class ThreadsBanner extends React.Component {
20-
componentWillMount() {
20+
componentDidMount() {
2121
// logic.loadPosts()
2222
}
2323

containers/CommunityBanner/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ const renderChildBanner = (route, store) => {
6363
}
6464

6565
class CommunityBannerContainer extends React.Component {
66-
componentWillMount() {
66+
componentDidMount() {
6767
const { communityBanner } = this.props
6868
logic.init(communityBanner)
6969
}

containers/CommunityContent/PostsContent.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ const columns = [
130130
]
131131

132132
class PostsContent extends React.Component {
133-
componentWillMount() {
133+
componentDidMount() {
134134
logic.loadPosts()
135135
}
136136

containers/CommunityContent/TagsContent.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ const columns = [
100100
]
101101

102102
class TagsContent extends React.Component {
103-
componentWillMount() {
103+
componentDidMount() {
104104
logic.loadTags()
105105
}
106106

containers/CommunityContent/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ const renderChildContent = (route, store, restProps) => {
4343
}
4444

4545
class CommunityContentContainer extends React.Component {
46-
componentWillMount() {
46+
componentDidMount() {
4747
const { communityContent } = this.props
4848
logic.init(communityContent)
4949
}

containers/CommunityEditor/index.js

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

3131
class CommunityEditorContainer extends React.Component {
32-
componentWillMount() {
32+
componentDidMount() {
3333
const { communityEditor, editData } = this.props
3434
logic.init(communityEditor, editData)
3535
}

containers/CommunitySetter/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ const CommunitiesList = ({ thread, source, communities, selectedids }) => (
4242
)
4343

4444
class CommunitySetterContainer extends React.Component {
45-
componentWillMount() {
45+
componentDidMount() {
4646
const { communitySetter } = this.props
4747
logic.init(communitySetter)
4848
}

containers/Content/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ const DomainContent = ({ curRoute }) => {
3535
for some unkown reasion, pages/index will always be the entry in dev mode
3636
*/
3737
class ContentContainer extends React.Component {
38-
componentWillMount() {
38+
componentDidMount() {
3939
const { content } = this.props
4040
logic.init(content)
4141
}

containers/Doraemon/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ const HintIcon = ({ index, active, cur, length }) => {
4545
}
4646

4747
class DoraemonContainer extends React.Component {
48-
componentWillMount() {
48+
componentDidMount() {
4949
const { doraemon } = this.props
5050
logic.init(doraemon)
5151
}

0 commit comments

Comments
 (0)