Skip to content
Permalink
Browse files

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

[TEMP] removal of "is typing" & "seen" features
[TEMP] (in progress) removal of "moderation" feature
  • Loading branch information...
alexkuhn committed Mar 15, 2019
1 parent 53abcb3 commit b96466de282f94d958d9ebb94bf8aa8e6379b926
Showing with 1,851 additions and 4,226 deletions.
  1. +3 −6 addons/mail/static/src/js/wip/discuss/content/composer/discuss_content_composer_input.js
  2. +1 −1 addons/mail/static/src/js/wip/discuss/content/thread_view/discuss_content_thread_view.js
  3. +2 −3 addons/mail/static/src/js/wip/discuss/content/thread_view/discuss_content_thread_view_message.js
  4. +7 −10 addons/mail/static/src/js/wip/discuss/discuss_root.js
  5. +5 −11 addons/mail/static/src/js/wip/discuss/sidebar/channel/discuss_sidebar_channel_add_item.js
  6. +3 −3 addons/mail/static/src/js/wip/discuss/sidebar/channel/discuss_sidebar_channel_item.js
  7. +5 −6 addons/mail/static/src/js/wip/discuss/sidebar/channel/discuss_sidebar_channel_item_commands.js
  8. +1 −1 addons/mail/static/src/js/wip/discuss/sidebar/channel/discuss_sidebar_channel_item_type.js
  9. +7 −13 addons/mail/static/src/js/wip/discuss/sidebar/dm_chat/discuss_sidebar_dm_chat_add_item.js
  10. +3 −3 addons/mail/static/src/js/wip/discuss/sidebar/dm_chat/discuss_sidebar_dm_chat_item.js
  11. +3 −4 addons/mail/static/src/js/wip/discuss/sidebar/dm_chat/discuss_sidebar_dm_chat_item_commands.js
  12. +5 −8 addons/mail/static/src/js/wip/discuss/sidebar/dm_chat/discuss_sidebar_dm_chat_item_editable_name.js
  13. +4 −4 addons/mail/static/src/js/wip/discuss/sidebar/dm_chat/discuss_sidebar_dm_chat_item_status.js
  14. +501 −140 addons/mail/static/src/js/wip/lib/core.js
  15. +46 −50 addons/mail/static/src/js/wip/models/dm_chat.js
  16. +18 −22 addons/mail/static/src/js/wip/models/document_thread.js
  17. +14 −21 addons/mail/static/src/js/wip/models/mailbox.js
  18. +131 −161 addons/mail/static/src/js/wip/models/message.js
  19. +50 −62 addons/mail/static/src/js/wip/models/multi_user_channel.js
  20. +0 −181 addons/mail/static/src/js/wip/models/utils/cc_throttle_function.js
  21. +0 −69 addons/mail/static/src/js/wip/models/utils/timer.js
  22. +0 −82 addons/mail/static/src/js/wip/models/utils/timers.js
  23. +61 −106 addons/mail/static/src/js/wip/services/chat_window_manager.js
  24. +2 −1 addons/mail/static/src/js/wip/services/messaging_service.js
  25. +0 −3,254 addons/mail/static/src/js/wip/services/messaging_store.js
  26. +260 −0 addons/mail/static/src/js/wip/services/messaging_store/messaging_notifications.js
  27. +530 −0 addons/mail/static/src/js/wip/services/messaging_store/messaging_store.js
  28. +184 −0 addons/mail/static/src/js/wip/services/messaging_store/messaging_store_utils.js
  29. +5 −4 addons/mail/views/mail_templates.xml
@@ -26,12 +26,9 @@ class Input extends odoo.core.Component {
if (!this.el.value) {
return;
}
this.env.store.messaging.dispatch({
type: 'POST_MESSAGE_ON_THREAD',
data: {
threadID: this.props.activeThreadID,
messageData: { content: this.el.value },
},
this.env.store.messaging.dispatch('postMessageOnThread', {
threadID: this.props.activeThreadID,
data: { content: this.el.value },
});
this.el.value = '';
}
@@ -7,7 +7,7 @@ class ThreadView extends odoo.core.Component {
widgets = { Message };
inlineTemplate = `
<div class="o_mail_wip_discuss_content_thread_view">
<div t-if="!thread.caches['[]'].loaded"
<div t-if="!thread.caches['[]'].isLoaded"
class="o_mail_wip_discuss_content_thread_view_loading">
<span>
<i aria-label="Loading..."
@@ -62,9 +62,8 @@ class Message extends odoo.core.Component {
}
_onClickCommandStar(ev) {
ev.stopPropagation();
this.env.store.messaging.dispatch({
type: 'TOGGLE_MESSAGE_STAR_STATUS',
data: { messageID: this.props.message.id },
return this.env.store.messaging.dispatch('toggleMessageStarStatus', {
messageID: this.props.message.id,
});
}
}
@@ -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];
if (!thread.caches['[]'].loaded) {
setTimeout(() => this.env.store.messaging.dispatch({
type: 'LOAD_MESSAGES_FROM_THREAD',
data: { threadID: thread.id },
}), 3*1000);
_selectThread(payload) {
this.updateState({ activeThreadID: payload.threadID });
const thread = this.env.store.messaging.state.threads[payload.threadID];
if (!thread.caches['[]'].isLoaded) {
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,
public: 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');
}
@@ -14,15 +14,15 @@ class ChannelItem extends odoo.core.Component {
<t t-widget="Type"
t-props="{channel}"/>
<div class="o_mail_wip_discuss_sidebar_channel_item_name"
t-att-class="channel.unreadCounter > 0 ? 'o_unread' : ''">
t-att-class="channel.message_unread_counter > 0 ? 'o_unread' : ''">
<t t-esc="channel.name"/>
</div>
<div class="o_mail_wip_autogrow"/>
<t t-widget="Commands"
t-props="{channel}"/>
<div t-if="channel.needactionCounter > 0"
<div t-if="channel.message_needaction_counter > 0"
class="o_mail_wip_discuss_sidebar_channel_item_counter badge badge-pill">
<t t-esc="channel.needactionCounter"/>
<t t-esc="channel.message_needaction_counter"/>
</div>
</div>`;
get channel() {
@@ -14,7 +14,7 @@ class ChannelItemCommands extends odoo.core.Component {
role="img"
title="Channel settings"
t-on-click="_onClickSettings"/>
<div t-if="!props.channel.needactionCounter"
<div t-if="!props.channel.message_needaction_counter"
aria-label="Leave this channel"
class="o_mail_wip_discuss_sideebar_channel_item_commands_leave o_command fa fa-times"
role="img"
@@ -44,16 +44,15 @@ class ChannelItemCommands extends odoo.core.Component {
} else {
prom = Promise.resolve();
}
prom.then(() =>
this.env.store.messaging.dispatch({
type: 'UNSUBSCRIBE_FROM_CHANNEL',
data: { channelID: this.props.channel.id },
return prom.then(() =>
this.env.store.messaging.dispatch('unsubscribeFromChannel', {
channelID: this.props.channel.id,
})
);
}
_onClickSettings(ev) {
ev.stopPropagation();
this.env.do_action({
return this.env.do_action({
type: 'ir.actions.act_window',
res_model: 'mail.channel',
res_id: this.props.channel.id,
@@ -4,7 +4,7 @@ odoo.define('mail.wip.discuss.sidebar.channel.item.Type', function (require) {
class ChannelItemType extends odoo.core.Component {
inlineTemplate = `
<div class="o_mail_wip_discuss_sidebar_channel_item_type">
<div t-if="props.channel.publicStatus === 'private'" class="fa fa-lock"/>
<div t-if="props.channel.public === 'private'" class="fa fa-lock"/>
<div t-else="" class="fa fa-hashtag"/>
</div>`;
}
@@ -27,25 +27,19 @@ 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');
return false;
}
_onAutocompleteSource(req, res) {
this.env.store.messaging.dispatch({
type: 'SEARCH_PARTNER',
data: {
callback: res,
limit: 10,
value: _.escape(req.term),
},
return this.env.store.messaging.dispatch('searchPartner', {
callback: res,
limit: 10,
value: _.escape(req.term),
});
}
_onBlur(ev) {
@@ -23,7 +23,7 @@ class DmChatItem extends odoo.core.Component {
t-key="editable_name"/>
<div t-else=""
class="o_mail_wip_discuss_sidebar_dm_chat_item_name"
t-att-class="dmChat.unreadCounter > 0 ? 'o_unread' : ''"
t-att-class="dmChat.message_unread_counter > 0 ? 'o_unread' : ''"
t-key="name">
<t t-esc="dmChat.name"/>
</div>
@@ -33,10 +33,10 @@ class DmChatItem extends odoo.core.Component {
t-props="{dmChat}"
t-on-start-renaming="_onStartRenaming"
t-key="commands"/>
<div t-if="dmChat.unreadCounter > 0"
<div t-if="dmChat.message_unread_counter > 0"
class="o_mail_wip_discuss_sidebar_dm_chat_item_counter badge badge-pill"
t-key="counter">
<t t-esc="dmChat.unreadCounter"/>
<t t-esc="dmChat.message_unread_counter"/>
</div>
</div>`;
constructor(...args) {
@@ -9,7 +9,7 @@ class DmChatItemCommands extends odoo.core.Component {
role="img"
title="Rename conversation"
t-on-click="onClickRename"/>
<div t-if="!props.dmChat.unreadCounter"
<div t-if="!props.dmChat.message_unread_counter"
aria-label="Unpin conversation"
class="o_mail_wip_discuss_sidebar_dm_chat_item_commands_unpin o_command fa fa-times"
role="img"
@@ -22,9 +22,8 @@ class DmChatItemCommands extends odoo.core.Component {
}
onClickUnpin(ev) {
ev.stopPropagation();
this.env.store.messaging.dispatch({
type: 'UNSUBSCRIBE_FROM_CHANNEL',
data: { channelID: this.props.dmChat.id },
return this.env.store.messaging.dispatch('unsubscribeFromChannel', {
channelID: this.props.dmChat.id,
});
}
}
@@ -4,7 +4,7 @@ odoo.define('mail.wip.discuss.sidebar.dm_chat.item.EditableName', function (requ
class DmChatItemEditableName extends odoo.core.Component {
inlineTemplate = `
<input class="o_mail_wip_discuss_sidebar_dm_chat_item_editable_name"
t-att-placeholder="props.dmChat.originalName"
t-att-placeholder="props.dmChat.directPartnerName"
t-att-value="props.dmChat.name"
t-on-blur="_onBlur"
t-on-click="_onClick"
@@ -42,14 +42,11 @@ class DmChatItemEditableName extends odoo.core.Component {
_onKeydownEnter(ev) {
const dmChat = this.props.dmChat;
const value = this.el.value;
const newName = value || dmChat.originalName;
const newName = value || dmChat.directPartnerName;
if (dmChat.name !== newName) {
this.env.store.messaging.dispatch({
type: 'RENAME_THREAD',
data: {
threadID: dmChat.id,
name: newName,
},
this.env.store.messaging.dispatch('renameThread', {
threadID: dmChat.id,
name: newName,
});
} else {
this._cancelRenaming();
@@ -4,16 +4,16 @@ odoo.define('mail.wip.discuss.sidebar.dm_chat.item.Status', function (require) {
class DmChatItemStatus extends odoo.core.Component {
inlineTemplate = `
<div class="o_mail_wip_discuss_sidebar_dm_chat_item_status">
<div t-if="props.dmChat.status === 'online'"
<div t-if="props.dmChat.directPartnerImStatus === 'online'"
class="fa fa-circle o_user_online"
title="Online"/>
<div t-elif="props.dmChat.status === 'offline'"
<div t-elif="props.dmChat.directPartnerImStatus === 'offline'"
class="fa fa-circle-o"
title="Offline"/>
<div t-elif="props.dmChat.status === 'away'"
<div t-elif="props.dmChat.directPartnerImStatus === 'away'"
class="fa fa-circle o_user_away"
title="Away"/>
<div t-elif="props.dmChat.status === 'typing'"
<div t-elif="props.dmChat.directPartnerImStatus === 'typing'"
t-class="o_user_typing"
title="Is typing...">
<span class="o_typing_dot"/>
Oops, something went wrong.

0 comments on commit b96466d

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