Explorar o código

replace Array#forEach() ... Array#push with Array#map

Martin Filser %!s(int64=2) %!d(string=hai) anos
pai
achega
66c2140911
Modificáronse 2 ficheiros con 7 adicións e 10 borrados
  1. 5 5
      client/components/boards/boardsList.js
  2. 2 5
      client/lib/utils.js

+ 5 - 5
client/components/boards/boardsList.js

@@ -187,15 +187,15 @@ BlazeComponent.extendComponent({
     return ret;
   },
   boardLists(boardId) {
-    let boardLists = [];
     const lists = Lists.find({ 'boardId': boardId, 'archived': false },{sort: ['sort','asc']});
     /* Bug Board icons random dance https://github.com/wekan/wekan/issues/4214
-    lists.forEach(list => {
-      let cardCount = Cards.find({ 'boardId': boardId, 'listId': list._id }).count()
-      boardLists.push(`${list.title}: ${cardCount}`);
+    const ret = lists.map(list => {
+      let cardCount = ReactiveCache.getCards({ 'boardId': boardId, 'listId': list._id }).length;
+      return `${list.title}: ${cardCount}`;
     });
+    return ret;
     */
-    return boardLists;
+    return [];
   },
 
   boardMembers(boardId) {

+ 2 - 5
client/lib/utils.js

@@ -162,11 +162,8 @@ Utils = {
   },
 
   archivedBoardIds() {
-    const archivedBoards = [];
-    ReactiveCache.getBoards({ archived: false }).forEach(board => {
-      archivedBoards.push(board._id);
-    });
-    return archivedBoards;
+    const ret = ReactiveCache.getBoards({ archived: false }).map(board => board._id);
+    return ret;
   },
 
   dueCardsView() {