张延森 5 年之前
父節點
當前提交
a5bd304f6c
共有 2 個檔案被更改,包括 14 行新增2 行删除
  1. 8
    0
      src/pages/im/list/index.js
  2. 6
    2
      src/reducers/user.js

+ 8
- 0
src/pages/im/list/index.js 查看文件

47
           pageSize: size,
47
           pageSize: size,
48
           pageNumber: current,
48
           pageNumber: current,
49
         }
49
         }
50
+      }, () => {
51
+        const totalUnRead = (records || []).reduce((acc, item) => (acc + item.unReadNum), 0)
52
+        if (!totalUnRead) {
53
+          // 如果未读为 0, 那么更新 提示组件也为 0
54
+          
55
+          const { dispatch } = getStore()
56
+          dispatch({ type: DECREASE_UNREADNUM })
57
+        }
50
       })
58
       })
51
     })
59
     })
52
   }
60
   }

+ 6
- 2
src/reducers/user.js 查看文件

88
     }
88
     }
89
     case DECREASE_UNREADNUM: {
89
     case DECREASE_UNREADNUM: {
90
       let { unReadNum } = state
90
       let { unReadNum } = state
91
-      unReadNum = unReadNum - action.payload
92
 
91
 
93
-      if (unReadNum < 0) {
92
+      if (action.payload === undefined) {
94
         unReadNum = 0
93
         unReadNum = 0
94
+      } else {
95
+        unReadNum = unReadNum - action.payload
96
+        if (unReadNum < 0) {
97
+          unReadNum = 0
98
+        }
95
       }
99
       }
96
 
100
 
97
       return {
101
       return {