Browse Source

Only show pin/unpin button if conversation exists

Danilo Bargen 6 năm trước cách đây
mục cha
commit
c8b3c3c13d
2 tập tin đã thay đổi với 10 bổ sung2 xóa
  1. 1 0
      src/partials/messenger.conversation.html
  2. 9 2
      src/partials/messenger.ts

+ 1 - 0
src/partials/messenger.conversation.html

@@ -29,6 +29,7 @@
         <div class="header-buttons">
             <toggle-button
                 flag="ctrl.conversation.isStarred"
+                ng-if="ctrl.conversation"
                 on-enable="ctrl.pinConversation()"
                 on-disable="ctrl.unpinConversation()"
                 label-enabled="messenger.PINNED_CONVERSATION"

+ 9 - 2
src/partials/messenger.ts

@@ -234,7 +234,7 @@ class ConversationController {
 
     // The conversation receiver
     public receiver: threema.Receiver;
-    public conversation: threema.Conversation;
+    public _conversation: threema.Conversation;  // Access through getter
     public type: threema.ReceiverType;
 
     // The conversation messages
@@ -347,7 +347,7 @@ class ConversationController {
         // Set receiver, conversation and type
         try {
             this.receiver = webClientService.receivers.getData({type: $stateParams.type, id: $stateParams.id});
-            this.conversation = this.webClientService.conversations.find(this.receiver);
+            this._conversation = this.webClientService.conversations.find(this.receiver);
             this.type = $stateParams.type;
 
             if (this.receiver.type === undefined) {
@@ -480,6 +480,13 @@ class ConversationController {
         });
     }
 
+    public get conversation(): threema.Conversation {
+        if (!hasValue(this._conversation)) {
+            this._conversation = this.webClientService.conversations.find(this.receiver);
+        }
+        return this._conversation;
+    }
+
     public isEnabled(): boolean {
         return this.type !== 'group'
             || !(this.receiver as threema.GroupReceiver).disabled;