mirror of
https://github.com/cryptpad/cryptpad.git
synced 2026-09-14 11:05:41 +05:00
Implement review changes
This commit is contained in:
parent
944a5ebd06
commit
8caa3f0dea
@ -139,6 +139,7 @@ define([
|
||||
APP.teamEdPublic = null;
|
||||
APP.drive = null;
|
||||
APP.cryptor = null;
|
||||
delete APP.refreshTeamAvatarBlock;
|
||||
APP.toolbar.$bottomR.empty();
|
||||
APP.toolbar.$bottomM.empty();
|
||||
APP.toolbar.$bottomL.empty();
|
||||
@ -458,6 +459,7 @@ define([
|
||||
var secret = Hash.getSecrets('team', team.hash || team.roHash, team.password);
|
||||
APP.cryptor = UserObject.createCryptor(secret.keys.secondaryKey);
|
||||
// Load data
|
||||
delete APP.refreshTeamAvatarBlock;
|
||||
APP.team = id;
|
||||
APP.teamEdPublic = Util.find(team, ['keys', 'drive', 'edPublic']);
|
||||
buildUI(common, true, team.owner);
|
||||
@ -691,7 +693,9 @@ define([
|
||||
common.displayAvatar($headerAvatar, obj?.avatar, obj?.name);
|
||||
if ($name.length) { $headerAvatar.append($name); }
|
||||
}
|
||||
APP.refreshTeamAvatarBlock(obj);
|
||||
if (typeof APP.refreshTeamAvatarBlock === 'function') {
|
||||
APP.refreshTeamAvatarBlock(obj);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
@ -1189,6 +1193,20 @@ define([
|
||||
makeBlock('avatar', function (common, cb) { // Msg.team_avatarHint, .team_avatarTitle
|
||||
const block = h('div#cp-team-avatar-preview');
|
||||
const $avatar = $(h('span.cp-avatar')).appendTo($(block));
|
||||
const setAvatar = (url) => {
|
||||
APP.module.execCommand('GET_TEAM_METADATA', {
|
||||
teamId: APP.team
|
||||
}, (meta) => {
|
||||
if (meta?.error) { return void UI.warn(Messages.error); }
|
||||
meta.avatar = url;
|
||||
APP.module.execCommand('SET_TEAM_METADATA', {
|
||||
teamId: APP.team,
|
||||
metadata: meta
|
||||
}, () => {
|
||||
refreshTeamMetadataDisplay(common);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
const refreshAvatar = (obj) => {
|
||||
$avatar.empty();
|
||||
@ -1203,36 +1221,14 @@ define([
|
||||
}, Icons.get('close'));
|
||||
$avatar.append(delButton);
|
||||
$(delButton).click(() => {
|
||||
APP.module.execCommand('GET_TEAM_METADATA', {
|
||||
teamId: APP.team
|
||||
}, (meta) => {
|
||||
if (meta?.error) { return void UI.warn(Messages.error); }
|
||||
meta.avatar = '';
|
||||
APP.module.execCommand('SET_TEAM_METADATA', {
|
||||
teamId: APP.team,
|
||||
metadata: meta
|
||||
}, () => {
|
||||
refreshTeamMetadataDisplay(common);
|
||||
});
|
||||
});
|
||||
setAvatar('');
|
||||
});
|
||||
});
|
||||
};
|
||||
APP.refreshTeamAvatarBlock = refreshAvatar;
|
||||
const data = MT.addAvatar(common, (ev, upload) => {
|
||||
if (!upload.url) { return void UI.warn(Messages.error); }
|
||||
APP.module.execCommand('GET_TEAM_METADATA', {
|
||||
teamId: APP.team
|
||||
}, (obj) => {
|
||||
if (obj?.error) { return void UI.warn(Messages.error); }
|
||||
obj.avatar = upload.url;
|
||||
APP.module.execCommand('SET_TEAM_METADATA', {
|
||||
teamId: APP.team,
|
||||
metadata: obj
|
||||
}, () => {
|
||||
refreshTeamMetadataDisplay(common);
|
||||
});
|
||||
});
|
||||
setAvatar(upload.url);
|
||||
});
|
||||
const $upButton = common.createButton('upload', false, data);
|
||||
$upButton.addClass('cp-online');
|
||||
|
||||
Loading…
Reference in New Issue
Block a user