فهرست منبع

Add canView to ControllerModel interface

Danilo Bargen 8 سال پیش
والد
کامیت
8a725ccb0f
4فایلهای تغییر یافته به همراه13 افزوده شده و 1 حذف شده
  1. 4 1
      src/controller_model/contact.ts
  2. 4 0
      src/controller_model/distributionList.ts
  3. 4 0
      src/controller_model/group.ts
  4. 1 0
      src/threema.d.ts

+ 4 - 1
src/controller_model/contact.ts

@@ -79,7 +79,6 @@ export class ContactControllerModel implements threema.ControllerModel {
 
             default:
                 $log.error('Invalid controller model mode: ', this.getMode());
-
         }
     }
 
@@ -99,6 +98,10 @@ export class ContactControllerModel implements threema.ControllerModel {
         return this.identity !== undefined && this.identity.length === 8;
     }
 
+    public canView(): boolean {
+        return this.contact.id !== this.webClientService.me.id;
+    }
+
     public canEdit(): boolean {
         return this.access !== undefined && (
             this.access.canChangeAvatar === true

+ 4 - 0
src/controller_model/distributionList.ts

@@ -85,6 +85,10 @@ export class DistributionListControllerModel implements threema.ControllerModel
             }).length > 0;
     }
 
+    public canView(): boolean {
+        return true;
+    }
+
     public canEdit(): boolean {
         // a distribution list can always be edited
         return true;

+ 4 - 0
src/controller_model/group.ts

@@ -93,6 +93,10 @@ export class GroupControllerModel implements threema.ControllerModel {
             }).length > 0;
     }
 
+    public canView(): boolean {
+        return true;
+    }
+
     public canEdit(): boolean {
         return this.group.access !== undefined && (
                 this.group.access.canChangeAvatar === true

+ 1 - 0
src/threema.d.ts

@@ -366,6 +366,7 @@ declare namespace threema {
         isLoading: boolean;
         save(): any;
         isValid(): boolean;
+        canView(): boolean;
         canEdit(): boolean;
         getMode(): number;
         setOnRemoved(callback: any): void;