forked from osdio/noder-react-native
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtopic.js
More file actions
64 lines (57 loc) · 1.46 KB
/
topic.js
File metadata and controls
64 lines (57 loc) · 1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import {createAction} from 'redux-actions'
import * as markdown from 'markdown'
import * as types from '../constants/ActionTypes'
import * as topicService from '../services/topicService'
export const getTopicsByTab = createAction(types.GET_TOPICS_BY_TAB, async(tab, params) => {
return await topicService.getTopicsByTab(tab, params)
}, (tab) => {
return {
tab
}
})
export const updateTopicsByTab = createAction(types.UPDATE_TOPICS_BY_TAB, async(tab) => {
return await topicService.getTopicsByTab(tab, {
page: 1
})
}, (tab) => {
return {
tab,
sync: 'topic'
}
})
export const getTopicById = createAction(types.GET_TOPIC_BY_ID, topicService.getTopicById, (id) => {
return {
id,
sync: 'topic'
}
})
export const removeTopicCacheById = createAction(types.REMOVE_TOPIC_CACHE_BY_ID, (id) => {
return {
id
}
})
export const replyTopicById = createAction(types.REPLY_TOPIC_BY_ID, topicService.reply, ({topicId, content, replyId, user}, resolved, rejected) => {
return {
id: topicId,
content: markdown.parse(content),
replyId,
resolved,
rejected,
user
}
})
export const upReply = createAction(types.UP_REPLY, topicService.upReply, ({topicId, replyId, userId, resolved, rejected}) => {
return {
id: topicId,
replyId,
userId,
resolved,
rejected
}
})
export const publish = createAction(types.PUBLISH, topicService.publish, ({resolved, rejected}) => {
return {
resolved,
rejected
}
})