Browse Source

Implement viewing of own profile

Danilo Bargen 8 năm trước cách đây
mục cha
commit
746cfbdd4d

+ 2 - 2
src/controller_model/contact.ts

@@ -101,7 +101,7 @@ export class ContactControllerModel implements threema.ControllerModel {
         return this.identity !== undefined && this.identity.length === 8;
     }
 
-    public canView(): boolean {
+    public canChat(): boolean {
         return this.contact.id !== this.webClientService.me.id;
     }
 
@@ -114,7 +114,7 @@ export class ContactControllerModel implements threema.ControllerModel {
     }
 
     public canClean(): boolean {
-        return this.canView();
+        return this.canChat();
     }
 
     public clean(ev: any): any {

+ 2 - 2
src/controller_model/distributionList.ts

@@ -84,11 +84,11 @@ export class DistributionListControllerModel implements threema.ControllerModel
 
     public isValid(): boolean {
         return this.members.filter((identity: string) => {
-                return identity !== this.webClientService.getMyIdentity().identity;
+                return identity !== this.webClientService.getProfile().identity;
             }).length > 0;
     }
 
-    public canView(): boolean {
+    public canChat(): boolean {
         return true;
     }
 

+ 4 - 4
src/controller_model/group.ts

@@ -96,11 +96,11 @@ export class GroupControllerModel implements threema.ControllerModel {
 
     public isValid(): boolean {
         return this.members.filter((identity: string) => {
-                return identity !== this.webClientService.getMyIdentity().identity;
+                return identity !== this.webClientService.getProfile().identity;
             }).length > 0;
     }
 
-    public canView(): boolean {
+    public canChat(): boolean {
         return true;
     }
 
@@ -113,7 +113,7 @@ export class GroupControllerModel implements threema.ControllerModel {
     }
 
     public canClean(): boolean {
-        return this.canView();
+        return this.canChat();
     }
 
     public clean(ev: any): any {
@@ -151,7 +151,7 @@ export class GroupControllerModel implements threema.ControllerModel {
         const confirm = this.$mdDialog.confirm()
             .title(this.$translate.instant('messenger.GROUP_LEAVE'))
             .textContent(this.$translate.instant(
-                this.group.administrator === this.webClientService.getMyIdentity().identity
+                this.group.administrator === this.webClientService.getProfile().identity
                     ? 'messenger.GROUP_REALLY_LEAVE_ADMIN'
                     : 'messenger.GROUP_REALLY_LEAVE'))
             .targetEvent(ev)

+ 178 - 0
src/controller_model/me.ts

@@ -0,0 +1,178 @@
+/**
+ * This file is part of Threema Web.
+ *
+ * Threema Web is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or (at
+ * your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with Threema Web. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+import {WebClientService} from '../services/webclient';
+import {AvatarControllerModel} from './avatar';
+
+import ControllerModelMode = threema.ControllerModelMode;
+
+export class MeControllerModel implements threema.ControllerModel {
+    private logTag: string = '[MeControllerModel]';
+
+    // Angular services
+    private $log: ng.ILogService;
+    private $translate: ng.translate.ITranslateService;
+    private $mdDialog: ng.material.IDialogService;
+
+    // Own services
+    private webClientService: WebClientService;
+
+    // Callbacks
+    private onRemovedCallback: threema.OnRemovedCallback;
+
+    // Own receiver instance
+    private me: threema.MeReceiver;
+
+    // Avatar controller
+    private avatarController: AvatarControllerModel;
+
+    // Controller model fields
+    public subject: string;
+    public isLoading = false;
+
+    // Data shown on page
+    public nickname: string;
+
+    // Editing mode
+    private mode = ControllerModelMode.VIEW;
+
+    constructor($log: ng.ILogService,
+                $translate: ng.translate.ITranslateService,
+                $mdDialog: ng.material.IDialogService,
+                webClientService: WebClientService,
+                mode: ControllerModelMode,
+                me?: threema.MeReceiver) {
+        this.$log = $log;
+        this.$translate = $translate;
+        this.$mdDialog = $mdDialog;
+        this.me = me;
+        this.webClientService = webClientService;
+        this.mode = mode;
+
+        switch (mode) {
+            /*case ControllerModelMode.EDIT:
+                this.subject = $translate.instant('messenger.EDIT_RECEIVER', {
+                    receiverName: '@NAME@',
+                }).replace('@NAME@', this.me.displayName);
+                this.firstName = this.me.firstName;
+                this.lastName = this.me.lastName;
+                this.avatarController = new AvatarControllerModel(
+                    this.$log, this.webClientService, this.me,
+                );
+
+                this.access = this.me.access;
+                this.firstNameLabel = this.access.canChangeLastName ?
+                    $translate.instant('messenger.FIRST_NAME') :
+                    $translate.instant('messenger.NAME');
+                break;*/
+            case ControllerModelMode.VIEW:
+                this.subject = $translate.instant('messenger.MY_THREEMA_ID');
+                this.nickname = webClientService.getProfile().publicNickname;
+                break;
+            default:
+                $log.error(this.logTag, 'Invalid controller model mode: ', this.getMode());
+        }
+    }
+
+    /**
+     * Set the on removed callback.
+     */
+    public setOnRemoved(callback: threema.OnRemovedCallback): void {
+        this.onRemovedCallback = callback;
+    }
+
+    /**
+     * Callback called when the members change.
+     */
+    public onChangeMembers(identities: string[]): void {
+        // Not possible
+    }
+
+    /**
+     * Return the members of this receiver.
+     */
+    public getMembers(): string[] {
+        return [this.me.id];
+    }
+
+    /**
+     * The editing mode, e.g. view or edit this receiver.
+     */
+    public getMode(): ControllerModelMode {
+        return this.mode;
+    }
+
+    /**
+     * Can this receiver be cleaned?
+     */
+    public canClean(): boolean {
+        return false;
+    }
+
+    /**
+     * Delete all messages in this conversation.
+     */
+    public clean(ev: any): any {
+        // No-op
+    }
+
+    /**
+     * Validate this receiver.
+     */
+    public isValid(): boolean {
+        return (this.me !== null
+             && this.me !== undefined
+             && this.me.id === this.webClientService.me.id);
+    }
+
+    /*
+     * Return whether this receiver can be chatted with.
+     */
+    public canChat(): boolean {
+        // You cannot chat with yourself
+        return false;
+    }
+
+    /**
+     * Can this receiver be edited?
+     */
+    public canEdit(): boolean {
+        // The own contact can always be edited
+        // TODO: Restrictions?
+        // return true;
+        return false;
+    }
+
+    /**
+     * Save the changes, return a promise with the receiver.
+     */
+    public save(): Promise<threema.ContactReceiver> {
+        /*
+        switch (this.getMode()) {
+            case ControllerModelMode.EDIT:
+                return this.webClientService.modifyProfile(
+                    this.nickname,
+                    this.avatarController.getAvatar(),
+                );
+            default:
+                this.$log.error(this.logTag, 'Not allowed to save profile: Invalid mode');
+
+        }
+        */
+        return Promise.reject(null);
+    }
+}

+ 2 - 4
src/directives.ts

@@ -43,7 +43,6 @@ import messageQuote from './directives/message_quote';
 import messageState from './directives/message_state';
 import messageText from './directives/message_text';
 import messageVoipStatus from './directives/message_voip_status';
-import myIdentity from './directives/my_identity';
 import searchbox from './directives/searchbox';
 import statusBar from './directives/status_bar';
 import verificationLevel from './directives/verification_level';
@@ -54,6 +53,7 @@ angular.module('3ema.directives').directive('avatarEditor', avatarEditor);
 angular.module('3ema.directives').directive('batteryStatus', batteryStatus);
 angular.module('3ema.directives').directive('clickAction', clickAction);
 angular.module('3ema.directives').directive('composeArea', composeArea);
+angular.module('3ema.directives').directive('dragFile', dragFile);
 angular.module('3ema.directives').directive('eeeAvatar', avatar);
 angular.module('3ema.directives').directive('eeeContactBadge', contactBadge);
 angular.module('3ema.directives').directive('eeeDistributionListBadge', distributionListBadge);
@@ -69,12 +69,10 @@ angular.module('3ema.directives').directive('eeeMessageQuote', messageQuote);
 angular.module('3ema.directives').directive('eeeMessageState', messageState);
 angular.module('3ema.directives').directive('eeeMessageText', messageText);
 angular.module('3ema.directives').directive('eeeMessageVoipStatus', messageVoipStatus);
-angular.module('3ema.directives').directive('eeeMyIdentity', myIdentity);
 angular.module('3ema.directives').directive('eeeVerificationLevel', verificationLevel);
 angular.module('3ema.directives').directive('includeReplace', includeReplace);
 angular.module('3ema.directives').directive('location', location);
-angular.module('3ema.directives').directive('memberListEditor', memberListEditor);
 angular.module('3ema.directives').directive('mediabox', mediabox);
+angular.module('3ema.directives').directive('memberListEditor', memberListEditor);
 angular.module('3ema.directives').directive('searchbox', searchbox);
 angular.module('3ema.directives').directive('statusBar', statusBar);
-angular.module('3ema.directives').directive('dragFile', dragFile);

+ 1 - 1
src/directives/member_list_editor.ts

@@ -73,7 +73,7 @@ export default [
                 };
 
                 this.onRemoveMember = (contact: threema.ContactReceiver): boolean => {
-                    if (contact.id === webClientService.getMyIdentity().identity) {
+                    if (contact.id === webClientService.getProfile().identity) {
                         return false;
                     }
 

+ 0 - 65
src/directives/my_identity.ts

@@ -1,65 +0,0 @@
-/**
- * This file is part of Threema Web.
- *
- * Threema Web is free software: you can redistribute it and/or modify it
- * under the terms of the GNU Affero General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or (at
- * your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero
- * General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with Threema Web. If not, see <http://www.gnu.org/licenses/>.
- */
-
-import {u8aToHex} from '../helpers';
-
-export default [
-    '$mdDialog',
-    function($mdDialog) {
-        return {
-            restrict: 'EA',
-            scope: {},
-            bindToController: {
-                identity: '=eeeIdentity',
-            },
-            controllerAs: 'ctrl',
-            controller: [function() {
-                this.showQRCode = () => {
-                    const identity: threema.Identity = this.identity;
-                    $mdDialog.show({
-                        controllerAs: 'ctrl',
-                        controller: [function() {
-                           this.cancel = () =>  {
-                               $mdDialog.cancel();
-                           };
-                           this.identity = identity;
-                           this.qrCode = {
-                                errorCorrectionLevel: 'L',
-                                size: '400px',
-                                data: '3mid:'
-                                + identity.identity
-                                + ','
-                                + u8aToHex(new Uint8Array(identity.publicKey)),
-                            };
-                        }],
-                        templateUrl: 'partials/dialog.myidentity.html',
-                        parent: angular.element(document.body),
-                        clickOutsideToClose: true,
-                        fullscreen: true,
-                    });
-                };
-            }],
-            template: `
-                <div class="my-threema-information" ng-click="ctrl.showQRCode()">
-                    <div class="nickname" ng-cloak
-                        ng-bind-html="ctrl.identity.publicNickname | emojify | emptyToPlaceholder: '-'">
-                    </div>
-                </div>
-            `,
-        };
-    },
-];

+ 7 - 4
src/partials/messenger.navigation.html

@@ -1,7 +1,10 @@
-<!-- My identity -->
-<div id="my-identity" ng-if="ctrl.showMyIdentity()">
-    <div class="my-identity-content" eee-my-identity
-            eee-identity="ctrl.getMyIdentity()"></div>
+<!-- Top header (nickname + menu) -->
+<div id="navigation-topheader">
+    <div class="my-identity">
+        <span ng-click="ctrl.showProfile()" ng-cloak translate-attr="{'title': 'messenger.MY_PUBLIC_NICKNAME'}">
+            {{ ctrl.getProfile().publicNickname || ctrl.getProfile().identity }}
+        </span>
+    </div>
 
     <battery-status></battery-status>
 

+ 2 - 2
src/partials/messenger.receiver.html

@@ -2,7 +2,7 @@
     <div id="receiver-detail-header" class="detail-header">
         <ng-include src="'partials/messenger.backbutton.html'"></ng-include>
         <div class="header-details">
-            <h2 ng-bind-html="ctrl.receiver.displayName | escapeHtml | emojify"></h2>
+            <h2 ng-bind-html="ctrl.controllerModel.subject | escapeHtml | emojify"></h2>
         </div>
 
         <div class="header-buttons">
@@ -10,7 +10,7 @@
                 <md-icon class="material-icons md-24">mode_edit</md-icon>
             </md-button>
 
-            <md-button aria-label="edit" class="md-icon-button" ng-click="ctrl.chat()">
+            <md-button aria-label="edit" class="md-icon-button" ng-show="ctrl.controllerModel.canChat()" ng-click="ctrl.chat()">
                 <md-icon class="material-icons md-24">message</md-icon>
             </md-button>
         </div>

+ 1 - 3
src/partials/messenger.receiver/distributionList.html

@@ -8,9 +8,7 @@
 		<md-card-content>
 			<ul class="member-list">
 				<li ng-repeat="memberIdentity in ctrl.receiver.members">
-					<eee-contact-badge
-							eee-identity="memberIdentity"
-							eee-linked="true"></eee-contact-badge>
+					<eee-contact-badge eee-identity="memberIdentity"></eee-contact-badge>
 				</li>
 			</ul>
 

+ 25 - 0
src/partials/messenger.receiver/me.html

@@ -0,0 +1,25 @@
+<div class="form-content">
+	<!-- information list card -->
+	<md-card class="two-row">
+		<div class="avatar">
+			<eee-avatar eee-type="'contact'"
+						eee-receiver="ctrl.receiver"
+						eee-resolution="'high'"></eee-avatar>
+		</div>
+		<md-card-content>
+			<dl class="key-values">
+				<dt>Threema ID</dt>
+				<dd>{{ctrl.receiver.id}}
+					<eee-verification-level
+							contact="ctrl.receiver">
+					</eee-verification-level></dd>
+
+				<dt><span translate>messenger.KEY_FINGERPRINT</span></dt>
+				<dd>{{ctrl.fingerPrint}}</dd>
+
+				<dt><span translate>messenger.MY_PUBLIC_NICKNAME</span></dt>
+				<dd>{{ ctrl.controllerModel.nickname || "-" }}</dd>
+			</dl>
+		</md-card-content>
+	</md-card>
+</div>

+ 35 - 37
src/partials/messenger.ts

@@ -233,7 +233,7 @@ class ConversationController {
 
     public static $inject = [
         '$stateParams', '$state', '$timeout', '$log', '$scope', '$rootScope',
-        '$mdDialog', '$mdToast', '$location', '$translate', '$filter',
+        '$mdDialog', '$mdToast', '$translate', '$filter',
         'WebClientService', 'StateService', 'ReceiverService', 'MimeService', 'VersionService',
         'ControllerModelService',
     ];
@@ -245,7 +245,6 @@ class ConversationController {
                 $rootScope: ng.IRootScopeService,
                 $mdDialog: ng.material.IDialogService,
                 $mdToast: ng.material.IToastService,
-                $location,
                 $translate: ng.translate.ITranslateService,
                 $filter: ng.IFilterService,
                 webClientService: WebClientService,
@@ -317,9 +316,9 @@ class ConversationController {
             const mode = ControllerModelMode.CHAT;
             switch (this.receiver.type) {
                 case 'me':
-                    $log.warn(this.logTag, 'Cannot chat with own contact');
-                    $state.go('messenger.home');
-                    return;
+                    this.controllerModel = controllerModelService.me(
+                        this.receiver as threema.MeReceiver, mode);
+                    break;
                 case 'contact':
                     this.controllerModel = controllerModelService.contact(
                         this.receiver as threema.ContactReceiver, mode);
@@ -339,9 +338,9 @@ class ConversationController {
                     return;
             }
 
-            // Check if this receiver may be viewed
-            if (this.controllerModel.canView() === false) {
-                $log.warn(this.logTag, 'Cannot view this receiver, redirecting to home');
+            // Check if this receiver may be chatted with
+            if (this.controllerModel.canChat() === false) {
+                $log.warn(this.logTag, 'Cannot chat with this receiver, redirecting to home');
                 $state.go('messenger.home');
                 return;
             }
@@ -897,6 +896,13 @@ class NavigationController {
         });
     }
 
+    /**
+     * Show profile.
+     */
+    public showProfile(ev): void {
+        this.$state.go('messenger.home.detail', this.webClientService.me);
+    }
+
     /**
      * Return whether a trusted key is available.
      */
@@ -964,6 +970,7 @@ class NavigationController {
             type: 'distributionList',
         });
     }
+
     /**
      * Toggle search bar.
      */
@@ -971,13 +978,13 @@ class NavigationController {
         this.searchVisible = !this.searchVisible;
     }
 
-    public getMyIdentity(): threema.Identity {
-        return this.webClientService.getMyIdentity();
+    /**
+     * Return the user profile.
+     */
+    public getProfile(): threema.Profile {
+        return this.webClientService.getProfile();
     }
 
-    public showMyIdentity(): boolean {
-        return this.getMyIdentity() !== undefined;
-    }
 }
 
 class MessengerController {
@@ -1035,7 +1042,7 @@ class MessengerController {
                             if ($state.params.type === receiver.type
                                 && $state.params.id === receiver.id) {
                                 // conversation or sub form is open, redirect to home!
-                                $state.go('messenger.home', null, {location: 'replace'});
+                                $state.go('messenger.home');
                             }
                         }
                         break;
@@ -1074,10 +1081,11 @@ class ReceiverDetailController {
     private controllerModel: threema.ControllerModel;
 
     public static $inject = [
-        '$log', '$stateParams', '$state', '$mdDialog',
+        '$log', '$stateParams', '$state', '$mdDialog', '$translate',
         'WebClientService', 'FingerPrintService', 'ContactService', 'ControllerModelService',
     ];
-    constructor($log: ng.ILogService, $stateParams, $state: ng.ui.IStateService, $mdDialog: ng.material.IDialogService,
+    constructor($log: ng.ILogService, $stateParams, $state: ng.ui.IStateService,
+                $mdDialog: ng.material.IDialogService, $translate: ng.translate.ITranslateService,
                 webClientService: WebClientService, fingerPrintService: FingerPrintService,
                 contactService: ContactService, controllerModelService: ControllerModelService) {
 
@@ -1089,7 +1097,7 @@ class ReceiverDetailController {
         this.receiver = webClientService.receivers.getData($stateParams);
         this.me = webClientService.me;
 
-        // Append members
+        // Append group membership
         if (this.receiver.type === 'contact') {
             const contactReceiver = this.receiver as threema.ContactReceiver;
 
@@ -1104,6 +1112,7 @@ class ReceiverDetailController {
 
             this.isWorkReceiver = contactReceiver.identityType === threema.IdentityType.Work;
             this.fingerPrint = this.fingerPrintService.generate(contactReceiver.publicKey);
+
             webClientService.groups.forEach((groupReceiver: threema.GroupReceiver) => {
                 // check if my identity is a member
                 if (groupReceiver.members.indexOf(contactReceiver.id) !== -1) {
@@ -1127,12 +1136,15 @@ class ReceiverDetailController {
 
         switch (this.receiver.type) {
             case 'me':
-                $log.warn(this.logTag, 'Cannot view own contact');
-                $state.go('messenger.home');
-                return;
+                const meReceiver = this.receiver as threema.MeReceiver;
+                this.fingerPrint = this.fingerPrintService.generate(meReceiver.publicKey);
+                this.controllerModel = controllerModelService.me(meReceiver, ControllerModelMode.VIEW);
+                break;
             case 'contact':
+                const contactReceiver = this.receiver as threema.ContactReceiver;
+                this.fingerPrint = this.fingerPrintService.generate(contactReceiver.publicKey);
                 this.controllerModel = controllerModelService
-                    .contact(this.receiver as threema.ContactReceiver, ControllerModelMode.VIEW);
+                    .contact(contactReceiver, ControllerModelMode.VIEW);
                 break;
             case 'group':
                 this.controllerModel = controllerModelService
@@ -1149,14 +1161,7 @@ class ReceiverDetailController {
                 return;
         }
 
-        // If this receiver may not be viewed, navigate to "home" view
-        if (this.controllerModel.canView() === false) {
-            $log.warn(this.logTag, 'Cannot view this receiver, redirecting to home');
-            this.$state.go('messenger.home');
-            return;
-        }
-
-        // If this receiver is removed, navigate to "home" view
+        // If this receiver was removed, navigate to "home" view
         this.controllerModel.setOnRemoved((receiverId: string) => {
             $log.warn(this.logTag, 'Receiver removed, redirecting to home');
             this.$state.go('messenger.home');
@@ -1253,13 +1258,6 @@ class ReceiverEditController {
         }
         this.type = receiver.type;
 
-        // If this receiver may not be viewed, navigate to "home" view
-        if (this.controllerModel.canView() === false) {
-            $log.warn(this.logTag, 'Cannot view this receiver, redirecting to home');
-            this.$state.go('messenger.home');
-            return;
-        }
-
         this.execute = new ExecuteService($log, $timeout, 1000);
     }
 
@@ -1399,7 +1397,7 @@ class ReceiverCreateController {
         // validate first
         this.execute.execute(this.controllerModel.save())
             .then((receiver: threema.Receiver) => {
-                this.$state.go('messenger.home.detail', receiver, {location: 'replace'});
+                this.$state.go('messenger.home.detail', receiver);
             })
             .catch((errorCode) => {
                 this.showAddError(errorCode);

+ 0 - 1
src/sass/app.scss

@@ -57,7 +57,6 @@
 @import "sections/compose_area";
 @import "sections/footer";
 @import "sections/status_bar";
-@import "sections/my_identity";
 @import "sections/noscript";
 
 // Vendors: Third party code.

+ 0 - 42
src/sass/sections/_my_identity.scss

@@ -1,42 +0,0 @@
-#my-identity {
-  background-color: #424242;
-  padding: 0 $main-padding 0 (2*$main-padding);
-  min-height: 68px;
-  display: flex;
-  flex-direction: row;
-  color: white;
-  box-shadow: -2px 2px 4px -2px rgba(0,0,0,0.4);
-  z-index: 21;
-  align-items: center;
-  justify-content: center;
-
-  .my-identity-content {
-    flex: 1;
-    display: flex;
-    flex-direction: row;
-    align-items: center;
-    text-shadow: 0.5px 0.5px 1px rgba(0,0,0,0.25);
-
-    .my-threema-information {
-      @include mouse-hand;
-      div {
-        white-space: nowrap;
-        overflow: hidden;
-        text-overflow: ellipsis;
-        word-wrap: break-word;
-        word-break: break-all;
-      }
-      .nickname {
-        font-size: 16pt;
-      }
-    }
-  }
-}
-
-#my-threema-id-dialog {
-  qrcode {
-    canvas {
-      max-width: 50%;
-    }
-  }
-}

+ 30 - 0
src/sass/sections/_navigation.scss

@@ -3,6 +3,36 @@
     border-bottom: 1px solid $border-grey;
 }
 
+#navigation-topheader {
+    background-color: #424242;
+    padding: 0 $main-padding 0 (2*$main-padding);
+    min-height: 68px;
+    display: flex;
+    flex-direction: row;
+    color: white;
+    box-shadow: -2px 2px 4px -2px rgba(0,0,0,0.8);
+    z-index: 21;
+    align-items: center;
+    justify-content: center;
+
+    .my-identity {
+        width: 85%;
+        flex-grow: 1;
+        span {
+            max-width: 100%;
+            display: inline-block;
+            text-shadow: 0.5px 0.5px 1px rgba(0,0,0,0.25);
+            font-size: 16pt;
+            white-space: nowrap;
+            overflow: hidden;
+            text-overflow: ellipsis;
+            word-wrap: break-word;
+            word-break: break-all;
+            @include mouse-hand;
+        }
+    }
+}
+
 #navigation-header {
     background-color: #f5f5f5;
     box-shadow: -2px 2px 4px -2px rgba(0,0,0,0.4);

+ 12 - 0
src/services/controller_model.ts

@@ -18,6 +18,7 @@
 import {ContactControllerModel} from '../controller_model/contact';
 import {DistributionListControllerModel} from '../controller_model/distributionList';
 import {GroupControllerModel} from '../controller_model/group';
+import {MeControllerModel} from '../controller_model/me';
 import {WebClientService} from './webclient';
 
 // Type aliases
@@ -41,6 +42,17 @@ export class ControllerModelService {
         this.webClientService = webClientService;
     }
 
+    public me(receiver: threema.MeReceiver, mode: ControllerModelMode): threema.ControllerModel {
+        return new MeControllerModel(
+            this.$log,
+            this.$translate,
+            this.$mdDialog,
+            this.webClientService,
+            mode,
+            receiver,
+        );
+    }
+
     public contact(receiver: threema.ContactReceiver, mode: ControllerModelMode): threema.ControllerModel {
         return new ContactControllerModel(
             this.$log,

+ 7 - 7
src/services/webclient.ts

@@ -182,7 +182,7 @@ export class WebClientService {
     public receivers: threema.Container.Receivers;
     public alerts: threema.Alert[] = [];
     public defaults: WebClientDefault;
-    private myIdentity: threema.Identity;
+    private profile: threema.Profile;
     private pushToken: string = null;
 
     // Other
@@ -411,7 +411,7 @@ export class WebClientService {
                             this.stateService.updateConnectionBuildupState('closed');
                             break;
                         default:
-                            this.$log.warn('Unknown signaling state:', state);
+                            this.$log.warn(this.logTag, 'Unknown signaling state:', state);
                     }
                 }
                 this.stateService.updateSignalingConnectionState(state);
@@ -1327,10 +1327,10 @@ export class WebClientService {
     }
 
     /**
-     * Return own identity.
+     * Return own profile.
      */
-    public getMyIdentity(): threema.Identity {
-        return this.myIdentity;
+    public getProfile(): threema.Profile {
+        return this.profile;
     }
 
     /**
@@ -2109,12 +2109,12 @@ export class WebClientService {
         }
 
         // Set own identity
-        this.myIdentity = {
+        this.profile = {
             identity: this.clientInfo.myAccount.identity,
             publicKey: this.clientInfo.myAccount.publicKey,
             publicNickname: this.clientInfo.myAccount.publicNickname,
             fingerprint: this.fingerPrintService.generate(this.clientInfo.myAccount.publicKey),
-        } as threema.Identity;
+        };
 
         this.registerInitializationStep(InitializationStep.ClientInfo);
     }

+ 5 - 5
src/threema.d.ts

@@ -391,7 +391,7 @@ declare namespace threema {
         text: string;
     }
 
-    interface Identity {
+    interface Profile {
         identity: string;
         publicNickname: string;
         publicKey: ArrayBuffer;
@@ -461,10 +461,10 @@ declare namespace threema {
          */
         isValid(): boolean;
 
-        /**
-         * Can this receiver be viewed?
+        /*
+         * Return whether this receiver can be chatted with.
          */
-        canView(): boolean;
+        canChat(): boolean;
 
         /**
          * Can this receiver be edited?
@@ -477,7 +477,7 @@ declare namespace threema {
         canClean(): boolean;
 
         /**
-         * The mode, e.g. view or edit this receiver.
+         * The editing mode, e.g. view or edit this receiver.
          */
         getMode(): ControllerModelMode;