Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Nov 1, 2021. It is now read-only.

Commit776563b

Browse files
committed
rename store in container logic
1 parent210a3b5 commit776563b

File tree

23 files changed

+271
-423
lines changed

23 files changed

+271
-423
lines changed

‎containers/AccountEditor/logic.js‎

Lines changed: 18 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ const sr71$ = new SR71()
2020
constdebug=makeDebugger('L:AccountEditor')
2121
/* eslint-enable no-unused-vars */
2222

23-
letaccountEditor=null
23+
letstore=null
2424

2525
exportfunctiongoBack(){
2626
dispatchEvent(EVENT.PREVIEW,{
@@ -29,14 +29,12 @@ export function goBack() {
2929
}
3030

3131
exportconstprofileChange=R.curry((thread,e)=>{
32-
accountEditor.updateUser({
32+
store.updateUser({
3333
[thread]:e.target.value,
3434
})
3535
})
3636

37-
exportfunctionsexChange(sex){
38-
accountEditor.updateUser({ sex})
39-
}
37+
exportconstsexChange=sex=>store.updateUser({ sex})
4038

4139
constupdatableAttrs=[
4240
'nickname',
@@ -56,31 +54,29 @@ const hasValue = R.compose(R.not, nilOrEmpty)
5654
constpickUpdatable=R.compose(R.pickBy(hasValue),R.pick(updatableAttrs))
5755

5856
exportconstupdateConfirm=()=>{
59-
if(!accountEditor.statusClean)returnfalse
57+
if(!store.statusClean)returnfalse
6058
// TODO: 只去除 null 的即可,如果为空也是合法的
61-
constediting=pickUpdatable(accountEditor.accountInfo)
62-
constorigin=pickUpdatable(accountEditor.accountOrigin)
59+
constediting=pickUpdatable(store.accountInfo)
60+
constorigin=pickUpdatable(store.accountOrigin)
6361
/* debug('editing: ', editing) */
6462
/* debug('origin: ', origin) */
6563

6664
// TODO: 唯一的限制是 昵称不能为空
6765
if(R.equals(editing,origin)){
68-
meteorState(accountEditor,'warn',3)
66+
meteorState(store,'warn',3)
6967
returnfalse
7068
}
7169

72-
accountEditor.markState({
73-
updating:true,
74-
})
70+
store.markState({updating:true})
7571

7672
sr71$.mutate(S.updateProfile,{profile:editing})
7773

7874
/*
7975
setTimeout(() => {
80-
accountEditor.markState({
76+
store.markState({
8177
updating: false,
8278
})
83-
meteorState(accountEditor, 'error', 5, '自定义错误')
79+
meteorState(store, 'error', 5, '自定义错误')
8480
}, 3000)
8581
*/
8682
}
@@ -90,20 +86,17 @@ export function cancleEdit() {
9086
}
9187

9288
exportfunctionupdateDone(){
93-
constediting=pickUpdatable(accountEditor.accountInfo)
94-
accountEditor.updateOrign(editing)
89+
constediting=pickUpdatable(store.accountInfo)
90+
store.updateOrign(editing)
9591
}
9692

97-
constcancleLoading=()=>{
98-
accountEditor.markState({
99-
updating:false,
100-
})
101-
}
93+
constcancleLoading=()=>store.markState({updating:false})
94+
10295
constDataSolver=[
10396
{
10497
match:asyncRes('updateProfile'),
10598
action:()=>{
106-
meteorState(accountEditor,'success',3)
99+
meteorState(store,'success',3)
107100
updateDone()
108101
cancleLoading()
109102
// communitiesContent.loadCommunities(data)
@@ -116,7 +109,7 @@ const ErrSolver = [
116109
match:asyncErr(ERR.CRAPHQL),
117110
action:({ details})=>{
118111
consterrMsg=details[0].detail
119-
meteorState(accountEditor,'error',5,errMsg)
112+
meteorState(store,'error',5,errMsg)
120113
cancleLoading()
121114
},
122115
},
@@ -137,7 +130,7 @@ const ErrSolver = [
137130
]
138131

139132
exportfunctioninit(selectedStore){
140-
accountEditor=selectedStore
141-
accountEditor.copyAccountInfo()
133+
store=selectedStore
134+
store.copyAccountInfo()
142135
sr71$.data().subscribe($solver(DataSolver,ErrSolver))
143136
}

‎containers/AccountViewer/logic.js‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ const sr71$ = new SR71({
1919
resv_event:[EVENT.LOGIN],
2020
})
2121

22-
letaccountViewer=null
22+
letstore=null
2323

2424
exportfunctionloadUser(){}
2525

@@ -30,11 +30,11 @@ export function loadAccount() {
3030
}
3131

3232
exportfunctionchangeTheme(name){
33-
accountViewer.changeTheme(name)
33+
store.changeTheme(name)
3434
}
3535

3636
exportfunctionlogout(){
37-
accountViewer.logout()
37+
store.logout()
3838
dispatchEvent(EVENT.LOGOUT)
3939
}
4040

@@ -50,7 +50,7 @@ const DataSolver = [
5050
match:asyncRes('account'),
5151
action:res=>{
5252
constdata=res.account
53-
accountViewer.updateAccount(data)
53+
store.updateAccount(data)
5454
},
5555
},
5656
{
@@ -81,6 +81,6 @@ const ErrSolver = [
8181
]
8282

8383
exportfunctioninit(selectedStore){
84-
accountViewer=selectedStore
84+
store=selectedStore
8585
sr71$.data().subscribe($solver(DataSolver,ErrSolver))
8686
}

‎containers/ArticleViwer/logic.js‎

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const sr71$ = new SR71({
1212
constdebug=makeDebugger('L:ArticleViwer')
1313
/* eslint-enable no-unused-vars */
1414

15-
letarticleViwer=null
15+
letstore=null
1616
letsub$=null
1717

1818
exportfunctiononReaction(type,action,isUndo,data){
@@ -27,9 +27,7 @@ export function onReaction(type, action, isUndo, data) {
2727
}
2828

2929
functionloading(maybe=true){
30-
articleViwer.markState({
31-
postLoading:maybe,
32-
})
30+
store.markState({postLoading:maybe})
3331
}
3432

3533
functionqueryPost(data){
@@ -56,7 +54,7 @@ const dataResolver = [
5654
constinfo=res[EVENT.PREVIEW_POST]
5755
/* debug('EVENT.PREVIEW_POST: ', res[EVENT.PREVIEW_POST]) */
5856
if(info.type===TYPE.POST){
59-
articleViwer.load(TYPE.POST,res[EVENT.PREVIEW_POST].data)
57+
store.load(TYPE.POST,res[EVENT.PREVIEW_POST].data)
6058
loading()
6159
queryPost(info.data)
6260
}
@@ -86,14 +84,14 @@ const dataResolver = [
8684
action:()=>{
8785
// TODO: test
8886
sr71$.stop()
89-
articleViwer.load(TYPE.POST,{})
87+
store.load(TYPE.POST,{})
9088
loading(false)
9189
},
9290
},
9391
{
9492
match:asyncRes(R.toLower(TYPE.POST)),// GraphQL return
9593
action:res=>{
96-
articleViwer.load(TYPE.POST,res[R.toLower(TYPE.POST)])
94+
store.load(TYPE.POST,res[R.toLower(TYPE.POST)])
9795
loading(false)
9896
},
9997
},
@@ -113,8 +111,8 @@ const handleData = res => {
113111
}
114112

115113
exportfunctioninit(selectedStore){
116-
articleViwer=selectedStore
117-
debug(articleViwer)
114+
store=selectedStore
115+
debug(store)
118116
if(sub$)sub$.unsubscribe()
119117

120118
sub$=sr71$.data().subscribe(handleData)

‎containers/Banner/logic.js‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ let sub$ = null
1010
constdebug=makeDebugger('L:Banner')
1111
/* eslint-enable no-unused-vars */
1212

13-
letbanner=null
13+
letstore=null
1414

1515
exportfunctionsomeMethod(){}
1616

@@ -22,8 +22,8 @@ const DataSolver = []
2222
constErrSolver=[]
2323

2424
exportfunctioninit(selectedStore){
25-
banner=selectedStore
26-
debug(banner)
25+
store=selectedStore
26+
debug(store)
2727
if(sub$)sub$.unsubscribe()
2828
sub$=sr71$.data().subscribe($solver(DataSolver,ErrSolver))
2929
}

‎containers/CategoryEditor/logic.js‎

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -18,22 +18,22 @@ let sub$ = null
1818
constdebug=makeDebugger('L:CategoryEditor')
1919
/* eslint-enable no-unused-vars */
2020

21-
letcategoryEditor=null
21+
letstore=null
2222

2323
exportconstprofileChange=R.curry((thread,e)=>
24-
categoryEditor.updateCategory({
24+
store.updateCategory({
2525
[thread]:e.target.value,
2626
})
2727
)
2828

2929
exportconstmutateConfirm=()=>{
3030
constrequiredArgs=['title','raw']
31-
constargs={ ...categoryEditor.categoryData}
31+
constargs={ ...store.categoryData}
3232

33-
categoryEditor.markState({mutating:true})
33+
store.markState({mutating:true})
3434
constfargs=castArgs(args,requiredArgs)
3535

36-
if(categoryEditor.isEdit){
36+
if(store.isEdit){
3737
returnsr71$.mutate(
3838
S.updateCategory,
3939
castArgs(args,['id', ...requiredArgs])
@@ -44,43 +44,34 @@ export const mutateConfirm = () => {
4444
}
4545

4646
exportfunctioncancleMutate(){
47-
categoryEditor.markState({
47+
store.markState({
4848
category:{},
4949
isEdit:false,
5050
})
5151
closePreviewer()
5252
}
5353

54-
constinitEditData=editData=>{
55-
categoryEditor.markState({
56-
category:editData,
57-
isEdit:true,
58-
})
59-
}
54+
constinitEditData=editData=>
55+
store.markState({category:editData,isEdit:true})
6056

6157
// ###############################
6258
// Data & Error handlers
6359
// ###############################
6460
constDataSolver=[
6561
{
6662
match:asyncRes('createCategory'),
67-
action:()=>{
68-
closePreviewer(TYPE.GATEGORIES_REFRESH)
69-
},
63+
action:()=>closePreviewer(TYPE.GATEGORIES_REFRESH),
7064
},
7165
{
7266
match:asyncRes('updateCategory'),
73-
action:()=>{
74-
closePreviewer(TYPE.GATEGORIES_REFRESH)
75-
},
67+
action:()=>closePreviewer(TYPE.GATEGORIES_REFRESH),
7668
},
7769
]
7870

7971
constErrSolver=[]
8072

8173
exportfunctioninit(selectedStore,editData){
82-
categoryEditor=selectedStore
83-
debug(categoryEditor)
74+
store=selectedStore
8475
if(sub$)sub$.unsubscribe()
8576
sub$=sr71$.data().subscribe($solver(DataSolver,ErrSolver))
8677

‎containers/CategorySetter/logic.js‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ let sub$ = null
1919
constdebug=makeDebugger('L:CategorySetter')
2020
/* eslint-enable no-unused-vars */
2121

22-
letcategorySetter=null
22+
letstore=null
2323

2424
constcommonFilter=page=>{
2525
constsize=PAGE_SIZE.COMMON
@@ -46,7 +46,7 @@ const DataSolver = [
4646
{
4747
match:asyncRes('pagedCategories'),
4848
action:({ pagedCategories})=>
49-
categorySetter.markState({
49+
store.markState({
5050
pagedCategories,
5151
}),
5252
},
@@ -59,7 +59,7 @@ const DataSolver = [
5959
constErrSolver=[]
6060

6161
exportfunctioninit(selectedStore){
62-
categorySetter=selectedStore
62+
store=selectedStore
6363
if(sub$)sub$.unsubscribe()
6464
sub$=sr71$.data().subscribe($solver(DataSolver,ErrSolver))
6565

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp