[IMP] mail: turn 'ComposerView/currentPartnerAvatar' into field

Task-2793280

closes odoo/odoo#86438

Signed-off-by: Ooming <wil@odoo.com>
This commit is contained in:
Alexandre Kühn
2022-03-16 13:16:32 +01:00
parent 10adbacd8a
commit df8d0b5ea3
3 changed files with 21 additions and 17 deletions
@@ -34,22 +34,6 @@ export class Composer extends Component {
return this.messaging && this.messaging.models['ComposerView'].get(this.props.localId);
}
/**
* Get the current partner image URL.
*
* @returns {string}
*/
get currentPartnerAvatar() {
const avatar = this.messaging.currentUser
? this.env.session.url('/web/image', {
field: 'avatar_128',
id: this.messaging.currentUser.id,
model: 'res.users',
})
: '/web/static/img/user_menu_avatar.png';
return avatar;
}
/**
* Determine whether composer should display a footer.
*
@@ -55,7 +55,7 @@
<t t-if="props.hasCurrentPartnerAvatar">
<div class="o_Composer_sidebarMain">
<t t-if="!messaging.currentGuest or composerView.composer.activeThread.model !== 'mail.channel'">
<img class="o_Composer_currentPartnerAvatar rounded-circle" t-att-src="currentPartnerAvatar" alt="Avatar of user"/>
<img class="o_Composer_currentPartnerAvatar rounded-circle" t-att-src="composerView.currentPartnerAvatar" alt="Avatar of user"/>
</t>
<t t-if="messaging.currentGuest and composerView.composer.activeThread.model === 'mail.channel'">
<img class="o_Composer_currentPartnerAvatar rounded-circle" t-attf-src="/mail/channel/{{ composerView.composer.activeThread.id }}/guest/{{ messaging.currentGuest.id }}/avatar_128?unique={{ messaging.currentGuest.name }}" alt="Avatar of guest"/>
@@ -539,6 +539,20 @@ registerModel({
}
return clear();
},
/**
* @private
* @returns {string}
*/
_computeCurrentPartnerAvatar() {
if (this.messaging.currentUser) {
return this.env.session.url('/web/image', {
field: 'avatar_128',
id: this.messaging.currentUser.id,
model: 'res.users',
});
}
return '/web/static/img/user_menu_avatar.png';
},
/**
* Clears the extra suggested record on closing mentions, and ensures
* the extra list does not contain any element already present in the
@@ -951,6 +965,12 @@ registerModel({
inverse: 'composerViews',
required: true,
}),
/**
* Current partner image URL.
*/
currentPartnerAvatar: attr({
compute: '_computeCurrentPartnerAvatar',
}),
/**
* Determines whether this composer should be focused at next render.
*/