Parcourir la source

Profile editing fixes

Danilo Bargen il y a 7 ans
Parent
commit
1608c5772f

+ 1 - 2
src/controller_model/me.ts

@@ -155,11 +155,10 @@ export class MeControllerModel implements threema.ControllerModel<threema.MeRece
             case ControllerModelMode.EDIT:
                 return this.webClientService.modifyProfile(
                     this.nickname,
-                    this.avatarController.getAvatar(),
+                    this.avatarController.avatarChanged ? this.avatarController.getAvatar() : undefined,
                 ).then((val) => {
                     // Profile was successfully updated. Update local data.
                     this.webClientService.me.publicNickname = this.nickname;
-                    this.webClientService.me.displayName = this.nickname;
                     if (this.avatarController.avatarChanged) {
                         this.webClientService.me.avatar.high = this.avatarController.getAvatar();
                     }

+ 3 - 11
src/directives/avatar_area.ts

@@ -26,14 +26,12 @@ export default [
     '$window',
     '$timeout',
     '$translate',
-    '$filter',
     '$mdDialog',
     function($rootScope: ng.IRootScopeService,
              $log: ng.ILogService,
              $window: ng.IWindowService,
              $timeout: ng.ITimeoutService,
              $translate: ng.translate.ITranslateService,
-             $filter: ng.IFilterService,
              $mdDialog: ng.material.IDialogService) {
         return {
             restrict: 'EA',
@@ -47,20 +45,14 @@ export default [
             controllerAs: 'ctrl',
             controller: [function() {
                 this.isLoading = false;
-                this.avatar = null;
+                this.avatar = null; // Type: String
 
                 this.imageChanged = function(image: ArrayBuffer, notify = true) {
                     this.isLoading = true;
                     if (notify === true && this.onChange !== undefined) {
                         this.onChange(image);
                     }
-
-                    // convert to a url
-                    if (image === null) {
-                        this.avatar = null;
-                    } else {
-                        this.avatar = $filter<any>('bufferToUrl')(image, 'image/png');
-                    }
+                    this.avatar = image;
                     this.isLoading = false;
                 };
 
@@ -150,7 +142,7 @@ export default [
                                     md-diameter="96"></md-progress-circular>
 
                         </div>
-                        <img ng-src="{{ ctrl.avatar | bufferToUrl:'image/png' }}" ng-show="ctrl.avatar !== null" />
+                        <img ng-src="{{ ctrl.avatar | bufferToUrl:'image/png' }}" ng-if="ctrl.avatar !== null" />
                     </div>
                     <div class="avatar-area-navigation"  layout="row" layout-wrap layout-margin layout-align="center">
 

+ 1 - 1
src/partials/messenger.navigation.html

@@ -2,7 +2,7 @@
 <div id="navigation-topheader">
     <div class="my-identity">
         <span ng-click="ctrl.showProfile()" ng-cloak translate-attr="{'title': 'messenger.MY_PUBLIC_NICKNAME'}">
-            {{ ctrl.getMe().displayName }}
+            {{ ctrl.getMe().publicNickname || ctrl.getMe().id }}
         </span>
     </div>
 

+ 1 - 1
src/services/webclient.ts

@@ -1305,7 +1305,7 @@ export class WebClientService {
         if (nickname !== undefined && nickname !== null) {
             data[WebClientService.ARGUMENT_NICKNAME] = nickname;
         }
-        if (avatar !== undefined && avatar !== null) {
+        if (avatar !== undefined) {
             data[WebClientService.ARGUMENT_AVATAR] = avatar;
         }