浏览代码

reduce adressbook change events and handling

... from four to one on avatar updates

Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
tags/v18.0.0beta1
Arthur Schiwon 4 年前
父节点
当前提交
3ce5d4e545
没有帐户链接到提交者的电子邮件
共有 2 个文件被更改,包括 6 次插入4 次删除
  1. 1
    1
      apps/user_ldap/lib/User_Proxy.php
  2. 5
    3
      lib/private/Avatar/UserAvatar.php

+ 1
- 1
apps/user_ldap/lib/User_Proxy.php 查看文件

@@ -253,7 +253,7 @@ class User_Proxy extends Proxy implements \OCP\IUserBackend, \OCP\UserInterface,
* @return boolean either the user can or cannot
*/
public function canChangeAvatar($uid) {
return $this->handleRequest($uid, 'canChangeAvatar', array($uid));
return $this->handleRequest($uid, 'canChangeAvatar', [$uid], true);
}

/**

+ 5
- 3
lib/private/Avatar/UserAvatar.php 查看文件

@@ -97,7 +97,7 @@ class UserAvatar extends Avatar {

$this->validateAvatar($img);

$this->remove();
$this->remove(true);
$type = $this->getAvatarImageType($img);
$file = $this->folder->newFile('avatar.' . $type);
$file->putContent($data);
@@ -193,7 +193,7 @@ class UserAvatar extends Avatar {
* @throws \OCP\Files\NotPermittedException
* @throws \OCP\PreConditionNotMetException
*/
public function remove() {
public function remove(bool $silent = false) {
$avatars = $this->folder->getDirectoryListing();

$this->config->setUserValue($this->user->getUID(), 'avatar', 'version',
@@ -203,7 +203,9 @@ class UserAvatar extends Avatar {
$avatar->delete();
}
$this->config->setUserValue($this->user->getUID(), 'avatar', 'generated', 'true');
$this->user->triggerChange('avatar', '');
if(!$silent) {
$this->user->triggerChange('avatar', '');
}
}

/**

正在加载...
取消
保存