Skip to content
Permalink
Browse files

wip ref store into dispatch(action)/commit(mutation)

continue turn onDispatch into action(s)/mutation(s)
  • Loading branch information...
alexkuhn committed Mar 15, 2019
1 parent 34a09cb commit 83d6b4ff79390fb29e01f0092d439654d9f24d45
@@ -38,17 +38,14 @@ class Root extends odoo.core.Component {

/**
* @private
* @param {Object} data
* @param {string|integer} data.threadID
* @param {Object} payload
* @param {string|integer} payload.threadID
*/
_selectThread(data) {
this.updateState({ activeThreadID: data.threadID });
const thread = this.env.store.messaging.state.threads[data.threadID];
_selectThread(payload) {
this.updateState({ activeThreadID: payload.threadID });
const thread = this.env.store.messaging.state.threads[payload.threadID];
if (!thread.caches['[]'].loaded) {
setTimeout(() => this.env.store.messaging.dispatch({
type: 'LOAD_MESSAGES_FROM_THREAD',
data: { threadID: thread.id },
}), 3*1000);
setTimeout(() => this.env.store.messaging.dispatch('loadMessagesFromThread', { threadID: thread.id }), 3*1000);
}
}

@@ -44,19 +44,13 @@ class ChannelAddItem extends odoo.core.Component {
return;
}
if (ui.item.special) {
this.env.store.messaging.dispatch({
type: 'CREATE_CHANNEL',
data: {
name: this._lastSearchVal,
publicStatus: ui.item.special,
type: 'multi_user_channel',
},
this.env.store.messaging.dispatch('createChannel', {
name: this._lastSearchVal,
publicStatus: ui.item.special,
type: 'multi_user_channel',
});
} else {
this.env.store.messaging.dispatch({
type: 'JOIN_CHANNEL',
data: { channelID: ui.item.id },
});
this.env.store.messaging.dispatch('joinChannel', { channelID: ui.item.id });
}
this.trigger('hide');
}
@@ -27,12 +27,9 @@ class DmChatAddItem extends odoo.core.Component {
data: { threadID: dmChat.id },
});
} else {
this.env.store.messaging.dispatch({
type: 'CREATE_CHANNEL',
data: {
partnerID,
type: 'dm_chat',
},
this.env.store.messaging.dispatch('createChannel', {
partnerID,
type: 'dm_chat',
});
}
this.trigger('hide');
@@ -72,18 +72,12 @@ class ChatWindowManager extends odoo.core.Component {
this._placeNewThreadWindow(threadWindow, data.options.passively);
await threadWindow.appendTo($(this.THREAD_WINDOW_APPENDTO));
this._repositionThreadWindows();
return await this.env.store.messaging.dispatch({
type: 'LOAD_MESSAGES_FROM_THREAD',
data: { threadID: thread.id },
});
return await this.env.store.messaging.dispatch('loadMessagesFromThread', { threadID: thread.id });
} catch (err) {
// thread window could not be open, which may happen due to
// access error while fetching messages to the document.
// abort opening the thread window in this case.
this.env.store.messaging.dispatch({
type: 'CLOSE_THREAD',
data: { threadID: thread.id },
});
this.env.store.messaging.dispatch('closeThread', { threadID: thread.id });
}
thread.isCreatingWindow = false;
} else if (!data.options.passively) {
Oops, something went wrong.

0 comments on commit 83d6b4f

Please sign in to comment.
You can’t perform that action at this time.