Skip to content

Commit

Permalink
[REF] mail_tracking: Modified MessagingInitializer inheritance
Browse files Browse the repository at this point in the history
Refactored MessagingInitializer's Init method so that it does not
conflict with other modules; see original PR:

OCA#1091

Co-authored-by: filoquin <filoquin@gmail.com>
  • Loading branch information
payen000 and filoquin committed Sep 11, 2023
1 parent e5f4058 commit 721ced0
Showing 1 changed file with 4 additions and 65 deletions.
69 changes: 4 additions & 65 deletions mail_tracking/static/src/models/messaging_initializer.esm.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,73 +5,12 @@ import {registerPatch} from "@mail/model/model_core";
registerPatch({
name: "MessagingInitializer",
recordMethods: {
async _init({
channels,
companyName,
current_partner,
currentGuest,
current_user_id,
current_user_settings,
hasLinkPreviewFeature,
internalUserGroupId,
mail_failures = [],
menu_id,
needaction_inbox_counter = 0,
partner_root,
public_partners,
shortcodes = [],
starred_counter = 0,
failed_counter = 0,
}) {
const discuss = this.messaging.discuss;
// Partners first because the rest of the code relies on them
this._initPartners({
currentGuest,
current_partner,
current_user_id,
partner_root,
public_partners,
});
// Mailboxes after partners and before other initializers that might
// manipulate threads or messages
this._initMailboxes({
needaction_inbox_counter,
starred_counter,
failed_counter,
});
// Init mail user settings
if (current_user_settings) {
this.messaging.models["res.users.settings"].insert(
current_user_settings
);
}
// Various suggestions in no particular order
this._initCannedResponses(shortcodes);
// FIXME: guests should have (at least some) commands available
if (!this.messaging.isCurrentUserGuest) {
this._initCommands();
}
// Channels when the rest of messaging is ready
if (channels) {
await this._initChannels(channels);
}
if (!this.exists()) {
return;
}
// Failures after channels
this._initMailFailures(mail_failures);
discuss.update({menu_id});
// Company related data
this.messaging.update({
companyName,
hasLinkPreviewFeature,
internalUserGroupId,
});
async _init({failed_counter = 0}) {
await this._super(...arguments);
this._initFailedMailboxes(failed_counter);
},

_initMailboxes({needaction_inbox_counter, starred_counter, failed_counter}) {
this.messaging.inbox.update({counter: needaction_inbox_counter});
this.messaging.starred.update({counter: starred_counter});
_initFailedMailboxes(failed_counter) {
this.messaging.failedmsg.update({counter: failed_counter});
},
},
Expand Down

0 comments on commit 721ced0

Please sign in to comment.