|
| 1 | +importRfrom'ramda' |
1 | 2 | importSR71from'../../utils/network/sr71'
|
2 | 3 |
|
3 | 4 | import{
|
@@ -28,13 +29,12 @@ let store = null
|
28 | 29 | letsub$=null
|
29 | 30 |
|
30 | 31 | exportfunctiononReaction(thread,action,userDid,{ id}){
|
31 |
| -/* |
32 |
| - debug('onReaction thread: ', thread) |
33 |
| - debug('onReaction action: ', action) |
34 |
| - debug('onReaction userDid: ', userDid) |
35 |
| - debug('onReaction id: ', id) |
36 |
| - */ |
37 |
| -constargs={ id, thread, action} |
| 32 | +/* debug('onReaction thread: ', thread) */ |
| 33 | +/* debug('onReaction action: ', action) */ |
| 34 | +// debug('onReaction userDid: ', store.isLogin) |
| 35 | +/* debug('onReaction id: ', id) */ |
| 36 | + |
| 37 | +constargs={ id,thread:R.toUpper(thread), action} |
38 | 38 |
|
39 | 39 | returnuserDid
|
40 | 40 | ?sr71$.mutate(S.undoReaction,args)
|
@@ -62,21 +62,23 @@ function loadJob({ id }) {
|
62 | 62 | constuserHasLogin=store.isLogin
|
63 | 63 | constvariables={ id, userHasLogin}
|
64 | 64 | loading()
|
| 65 | +debug('loadJob variables: ',variables) |
65 | 66 | sr71$.query(S.job,variables)
|
66 | 67 | }
|
67 | 68 |
|
68 |
| -functionreloadReactions(article){ |
69 |
| -constvariables={ |
70 |
| -id:article.id, |
| 69 | +functionreloadReactions({ id}){ |
| 70 | +switch(store.activeThread){ |
| 71 | +caseTHREAD.JOB:{ |
| 72 | +returnsr71$.query(S.jobReactionRes,{ id}) |
| 73 | +} |
| 74 | +default:{ |
| 75 | +returnsr71$.query(S.postReactionRes,{ id}) |
| 76 | +} |
71 | 77 | }
|
72 |
| -debug('reloadReactions: ',variables) |
73 |
| - |
74 |
| -sr71$.query(S.reactionResult,variables) |
75 | 78 | }
|
76 | 79 |
|
77 | 80 | exportfunctiononEdit(thread){
|
78 | 81 | /* debug('onEdit', store.viewingPost) */
|
79 |
| -debug('onEdit viewingData: ',store.viewingData) |
80 | 82 | switch(thread){
|
81 | 83 | caseTHREAD.POST:{
|
82 | 84 | returndispatchEvent(EVENT.PREVIEW_OPEN,{
|
@@ -118,44 +120,38 @@ const openAttachment = att => {
|
118 | 120 | // ###############################
|
119 | 121 | // Data & Error handlers
|
120 | 122 | // ###############################
|
121 |
| - |
122 |
| -functioncontentLoaded(content){ |
123 |
| -store.setViewing(content) |
124 |
| -loading(false) |
125 |
| -} |
126 |
| - |
127 | 123 | constDataSolver=[
|
128 | 124 | {
|
129 | 125 | match:asyncRes('reaction'),
|
130 | 126 | action:({ reaction})=>{
|
131 |
| -// TODO: should be trigger |
132 | 127 | debug('get reaction: ',reaction)
|
133 |
| -reloadReactions(reaction) |
| 128 | +returnreloadReactions(reaction) |
134 | 129 | },
|
135 | 130 | },
|
136 | 131 | {
|
137 | 132 | match:asyncRes('undoReaction'),
|
138 |
| -action:({ undoReaction})=>{ |
139 |
| -debug('get undoReaction: ',undoReaction) |
140 |
| -/* const info = res[TYPE.UNDO_REACTION] */ |
141 |
| -reloadReactions(undoReaction) |
142 |
| -}, |
| 133 | +action:({ undoReaction})=>reloadReactions(undoReaction), |
143 | 134 | },
|
144 | 135 | {
|
145 | 136 | match:asyncRes(EVENT.PREVIEW_CLOSED),
|
146 | 137 | action:()=>{
|
147 | 138 | sr71$.stop()
|
148 |
| -/* store.load(TYPE.POST, {}) */ |
149 | 139 | loading(false)
|
150 | 140 | },
|
151 | 141 | },
|
152 | 142 | {
|
153 | 143 | match:asyncRes('post'),
|
154 |
| -action:({ post})=>contentLoaded({ post}), |
| 144 | +action:({ post})=>{ |
| 145 | +store.setViewing({post:R.merge(store.viewingData,post)}) |
| 146 | +loading(false) |
| 147 | +}, |
155 | 148 | },
|
156 | 149 | {
|
157 | 150 | match:asyncRes('job'),
|
158 |
| -action:({ job})=>contentLoaded({ job}), |
| 151 | +action:({ job})=>{ |
| 152 | +store.setViewing({job:R.merge(store.viewingData,job)}) |
| 153 | +loading(false) |
| 154 | +}, |
159 | 155 | },
|
160 | 156 | ]
|
161 | 157 |
|
|