소스 검색

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;