This repository was archived by the owner on Jan 3, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 6 files changed +31
-2
lines changed Expand file tree Collapse file tree 6 files changed +31
-2
lines changed Original file line number Diff line number Diff line change 1
1
var types = require ( '../constants/ActionTypes' )
2
2
var UserService = require ( '../services/UserService' )
3
+ var TopicService = require ( '../services/TopicService' )
4
+ var MessageService = require ( '../services/MessageService' )
5
+ var Storage = require ( '../services/Storage' )
3
6
4
7
5
8
function getUser ( user ) {
@@ -125,3 +128,12 @@ exports.logout = function () {
125
128
type : types . LOGOUT
126
129
}
127
130
}
131
+
132
+
133
+ exports . clear = function ( ) {
134
+ TopicService . storage . remove ( )
135
+ MessageService . storage . remove ( )
136
+ return {
137
+ type : types . CLEAR
138
+ }
139
+ }
Original file line number Diff line number Diff line change @@ -36,8 +36,9 @@ class Setting extends Component {
36
36
}
37
37
38
38
39
- onClearPress ( ) {
40
-
39
+ onClearPress ( ) {
40
+ this . props . actions . clear ( )
41
+ window . alert ( '缓存清除成功!' )
41
42
}
42
43
43
44
Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ exports.CHECK_TOKEN_FAILED = 'CHECK_TOKEN_FAILED'
14
14
exports . LIKE_TOPIC = 'LIKE_TOPIC'
15
15
exports . UN_LIKE_TOPIC = 'UN_LIKE_TOPIC'
16
16
exports . LOGOUT = 'LOGOUT'
17
+ exports . CLEAR = 'CLEAR'
17
18
18
19
19
20
exports . GET_UNREAD_MESSAGE_COUNT_SUCCESS = 'GET_UNREAD_MESSAGE_COUNT_SUCCESS'
Original file line number Diff line number Diff line change @@ -12,6 +12,10 @@ storage.save = function (value) {
12
12
return Storage . setItem ( 'messages' , value )
13
13
}
14
14
15
+ storage . remove = function ( ) {
16
+ return Storage . removeItem ( 'messages' )
17
+ }
18
+
15
19
16
20
var req = { }
17
21
Original file line number Diff line number Diff line change @@ -32,4 +32,8 @@ Storage.multiGet = function (keys) {
32
32
} )
33
33
}
34
34
35
+ Storage . multiRemove = function ( keys ) {
36
+ return AsyncStorage . multiRemove ( keys )
37
+ }
38
+
35
39
module . exports = Storage
Original file line number Diff line number Diff line change @@ -24,6 +24,13 @@ storage.getAll = function () {
24
24
}
25
25
26
26
27
+ storage . remove = function ( ) {
28
+ return Storage . multiRemove ( tabs . map ( tab => {
29
+ return 'tab_' + tab
30
+ } ) )
31
+ }
32
+
33
+
27
34
var req = { }
28
35
29
36
You can’t perform that action at this time.
0 commit comments