浏览代码

Merge branch 'dev' of http://git.ycjcjy.com/zhiyuxing/miniapp-v3 into dev

xujing 5 年前
父节点
当前提交
4667c4ea1f
共有 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,6 +47,14 @@ export default class Index extends Component {
47 47
           pageSize: size,
48 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,10 +88,14 @@ export default function user(state = INITIAL_STATE, action) {
88 88
     }
89 89
     case DECREASE_UNREADNUM: {
90 90
       let { unReadNum } = state
91
-      unReadNum = unReadNum - action.payload
92 91
 
93
-      if (unReadNum < 0) {
92
+      if (action.payload === undefined) {
94 93
         unReadNum = 0
94
+      } else {
95
+        unReadNum = unReadNum - action.payload
96
+        if (unReadNum < 0) {
97
+          unReadNum = 0
98
+        }
95 99
       }
96 100
 
97 101
       return {