فهرست منبع

fix error on console when user logout (Part 1)

Martin Filser 2 سال پیش
والد
کامیت
38a32824ea
2فایلهای تغییر یافته به همراه10 افزوده شده و 16 حذف شده
  1. 4 4
      client/components/boards/boardsList.js
  2. 6 12
      models/users.js

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

@@ -151,8 +151,8 @@ BlazeComponent.extendComponent({
       }
       const currUser = ReactiveCache.getCurrentUser();
 
-      let orgIdsUserBelongs = currUser !== undefined && currUser.teams !== 'undefined' ? currUser.orgIdsUserBelongs() : '';
-      if (orgIdsUserBelongs && orgIdsUserBelongs != '') {
+      let orgIdsUserBelongs = currUser?.orgIdsUserBelongs() || '';
+      if (orgIdsUserBelongs) {
         let orgsIds = orgIdsUserBelongs.split(',');
         // for(let i = 0; i < orgsIds.length; i++){
         //   query.$and[2].$or.push({'orgs.orgId': orgsIds[i]});
@@ -162,8 +162,8 @@ BlazeComponent.extendComponent({
         query.$and[2].$or.push({ 'orgs.orgId': { $in: orgsIds } });
       }
 
-      let teamIdsUserBelongs = currUser !== undefined && currUser.teams !== 'undefined' ? currUser.teamIdsUserBelongs() : '';
-      if (teamIdsUserBelongs && teamIdsUserBelongs != '') {
+      let teamIdsUserBelongs = currUser?.teamIdsUserBelongs() || '';
+      if (teamIdsUserBelongs) {
         let teamsIds = teamIdsUserBelongs.split(',');
         // for(let i = 0; i < teamsIds.length; i++){
         //   query.$or[2].$or.push({'teams.teamId': teamsIds[i]});

+ 6 - 12
models/users.js

@@ -687,14 +687,11 @@ Users.helpers({
     return '';
   },
   orgIdsUserBelongs() {
+    let ret = '';
     if (this.orgs) {
-      return this.orgs
-        .map(function (org) {
-          return org.orgId;
-        })
-        .join(',');
+      ret = this.orgs.map(org => org.orgId).join(',');
     }
-    return '';
+    return ret;
   },
   teamsUserBelongs() {
     if (this.teams) {
@@ -708,14 +705,11 @@ Users.helpers({
     return '';
   },
   teamIdsUserBelongs() {
+    let ret = '';
     if (this.teams) {
-      return this.teams
-        .map(function (team) {
-          return team.teamId;
-        })
-        .join(',');
+      ret = this.teams.map(team => team.teamId).join(',');
     }
-    return '';
+    return ret;
   },
   boards() {
     return Boards.userBoards(this._id, null, {}, { sort: { sort: 1 } });