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 2f16263 commit 47aeb20126b282fbfed81cf008a42b39939a02e4
Showing with 2,687 additions and 4,263 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. +10 −10 addons/mail/static/src/js/wip/discuss/discuss.js
  5. +81 −0 addons/mail/static/src/js/wip/discuss/discuss_composer_emojis.js
  6. +57 −0 addons/mail/static/src/js/wip/discuss/discuss_composer_input.js
  7. +78 −0 addons/mail/static/src/js/wip/discuss/discuss_dm_editable_name.js
  8. +85 −0 addons/mail/static/src/js/wip/discuss/discuss_message.js
  9. +349 −37 addons/mail/static/src/js/wip/discuss/discuss_root.js
  10. +104 −0 addons/mail/static/src/js/wip/discuss/discuss_sidebar_add_channel_item.js
  11. +79 −0 addons/mail/static/src/js/wip/discuss/discuss_sidebar_add_dm_item.js
  12. +5 −11 addons/mail/static/src/js/wip/discuss/sidebar/channel/discuss_sidebar_channel_add_item.js
  13. +3 −3 addons/mail/static/src/js/wip/discuss/sidebar/channel/discuss_sidebar_channel_item.js
  14. +5 −6 addons/mail/static/src/js/wip/discuss/sidebar/channel/discuss_sidebar_channel_item_commands.js
  15. +1 −1 addons/mail/static/src/js/wip/discuss/sidebar/channel/discuss_sidebar_channel_item_type.js
  16. +7 −13 addons/mail/static/src/js/wip/discuss/sidebar/dm_chat/discuss_sidebar_dm_chat_add_item.js
  17. +3 −3 addons/mail/static/src/js/wip/discuss/sidebar/dm_chat/discuss_sidebar_dm_chat_item.js
  18. +3 −4 addons/mail/static/src/js/wip/discuss/sidebar/dm_chat/discuss_sidebar_dm_chat_item_commands.js
  19. +5 −8 addons/mail/static/src/js/wip/discuss/sidebar/dm_chat/discuss_sidebar_dm_chat_item_editable_name.js
  20. +4 −4 addons/mail/static/src/js/wip/discuss/sidebar/dm_chat/discuss_sidebar_dm_chat_item_status.js
  21. +501 −140 addons/mail/static/src/js/wip/lib/core.js
  22. +46 −50 addons/mail/static/src/js/wip/models/dm_chat.js
  23. +18 −22 addons/mail/static/src/js/wip/models/document_thread.js
  24. +14 −21 addons/mail/static/src/js/wip/models/mailbox.js
  25. +131 −161 addons/mail/static/src/js/wip/models/message.js
  26. +50 −62 addons/mail/static/src/js/wip/models/multi_user_channel.js
  27. +0 −181 addons/mail/static/src/js/wip/models/utils/cc_throttle_function.js
  28. +0 −69 addons/mail/static/src/js/wip/models/utils/timer.js
  29. +0 −82 addons/mail/static/src/js/wip/models/utils/timers.js
  30. +61 −106 addons/mail/static/src/js/wip/services/chat_window_manager.js
  31. +2 −1 addons/mail/static/src/js/wip/services/messaging_service.js
  32. +0 −3,254 addons/mail/static/src/js/wip/services/messaging_store.js
  33. +260 −0 addons/mail/static/src/js/wip/services/messaging_store/messaging_notifications.js
  34. +530 −0 addons/mail/static/src/js/wip/services/messaging_store/messaging_store.js
  35. +184 −0 addons/mail/static/src/js/wip/services/messaging_store/messaging_store_utils.js
  36. +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,
});
}
}
@@ -10,7 +10,7 @@ const core = require('web.core');
const _t = core._t;

const Discuss = AbstractAction.extend(MessagingMixin, {
DEBUG_MODE: true,
DEBUG: true,
template: 'mail.wip.Discuss',
hasControlPanel: true,
loadControlPanel: true,
@@ -23,9 +23,9 @@ const Discuss = AbstractAction.extend(MessagingMixin, {
this._super.apply(this, arguments);

this.controlPanelParams.modelName = 'mail.message';
this._root = undefined;
this.root = undefined;

if (this.DEBUG_MODE) {
if (this.DEBUG) {
window.discuss = this;
}
},
@@ -40,8 +40,8 @@ const Discuss = AbstractAction.extend(MessagingMixin, {
* @override {web.AbstractAction}
*/
destroy: function () {
if (this._root) {
this._root.destroy();
if (this.root) {
this.root.destroy();
}
this._super.apply(this, arguments);
},
@@ -50,7 +50,7 @@ const Discuss = AbstractAction.extend(MessagingMixin, {
*/
on_attach_callback() {
this._super.apply(this, arguments);
if (this._root) {
if (this.root) {
// prevent twice call to on_attach_callback (AKU FIXME)
return;
}
@@ -64,16 +64,16 @@ const Discuss = AbstractAction.extend(MessagingMixin, {
rpc: (...args) => this._rpc(...args),
_t,
};
this._root = new Root(env);
this._root.mount(this.$el[0]);
this.root = new Root(env);
this.root.mount(this.$el[0]);
},
/**
* @override {web.AbstractAction}
*/
on_detach_callback: function () {
this._super.apply(this, arguments);
if (this._root) {
this._root.destroy();
if (this.root) {
this.root.destroy();
}
},
});
@@ -0,0 +1,81 @@
odoo.define('mail.wip.discuss.ComposerEmojis', function (require) {
"use strict";

const PopoverContent = require('mail.wip.discuss.EmojisPopoverContent');

const { Component } = odoo.core;

class ComposerEmojis extends Component {
inlineTemplate = `
<button class="o_emojis o_command btn btn-secondary fa fa-smile" aria-label="Emojis" title="Emojis" type="button" data-selector="true" data-toggle="popover"/>`;

constructor(...args) {
super(...args);
this._documentListenerID = _.uniqueId('composer_emojis_');
this._popover = undefined;
this._popoverID = undefined;
}
mounted() {
const $div = $('<div>', { 'class': 'o_mail_wip_discuss_emojis_popover_container' });
const popoverContent = new PopoverContent(this);
popoverContent.on('emoji-selected', this, ev => this._onEmojiSelected(ev));
popoverContent.appendTo($div).then(() => {
const self = this;
this._popover = $(this.el).popover({
html: true,
boundary: 'viewport',
placement: 'top',
trigger: 'click',
offset: '0, 1',
content: function () {
const $this = $(this);
self._popoverID = $this.attr('aria-describedby');
return $div;
},
});
});
$(document).on('click.' + this._documentListenerID, ev => this._onDocumentClick(ev));
}

willUnmount() {
this._hidePopover();
$(document).off('click.' + this._documentListenerID);
}

//--------------------------------------------------------------------------
// Private
//--------------------------------------------------------------------------

_hidePopover() {
this._popover.popover('hide');
this._popoverID = undefined;
}

//--------------------------------------------------------------------------
// Handlers
//--------------------------------------------------------------------------

_onDocumentClick(ev) {
if (ev.target === this.el) {
return;
}
if (!this._popoverID) {
return;
}
const $target = $(ev.target);
if ($target.closest('#' + this._popoverID).length) {
return;
}
this._popover.popover('hide');
}

_onEmojiSelected(ev) {
ev.stopPropagation();
this._hidePopover();
this.trigger('emoji-selected', { source: ev.data.source });
}
}

return ComposerEmojis;

});
@@ -0,0 +1,57 @@
odoo.define('mail.wip.discuss.ComposerInput', function (require) {
"use strict";

const dom = require('web.dom');

const { Component } = odoo.core;

class ComposerInput extends Component {
inlineTemplate = `
<textarea class="o_input" placeholder="Write something..." t-on-keydown="_onKeydown"/>`;

mounted() {
dom.autoresize($(this.el), { min_height: 30 });
}

//--------------------------------------------------------------------------
// Public
//--------------------------------------------------------------------------

insertEmoji({ source }) {
const cursorPosition = dom.getSelectionRange(this.el);
const inputVal = this.el.value;
const leftSubstring = inputVal.substring(0, cursorPosition.start);
const rightSubstring = inputVal.substring(cursorPosition.end);
const newInputVal = [leftSubstring , source, rightSubstring].join(" ");
const newCursorPosition = newInputVal.length - rightSubstring.length;
this.el.value = newInputVal;
this.el.focus();
this.el.setSelectionRange(newCursorPosition, newCursorPosition);
}

postMessage() {
if (!this.el.value) {
return;
}
this.env.store.messaging.dispatch('postMessageOnThread', {
threadID: this.props.activeThreadID,
data: { content: this.el.value },
});
this.el.value = '';
}

//--------------------------------------------------------------------------
// Handlers
//--------------------------------------------------------------------------

_onKeydown(ev) {
if (ev.which === $.ui.keyCode.ENTER) {
this.postMessage();
ev.preventDefault();
}
}
}

return ComposerInput;

});
@@ -0,0 +1,78 @@
odoo.define('mail.wip.discuss.DmEditableName', function (require) {
"use strict";

const { connect, Component } = odoo.core;

function mapStateToProps(state) {
return {
threads: state.threads,
};
}

class DmEditableName extends Component {
inlineTemplate = `
<input class="o_editable_name" t-att-placeholder="dm.directPartnerName" t-att-value="dm.name" t-on-blur="_onBlur" t-on-click="_onClick" t-on-keydown="_onKeydown"/>`;

mounted() {
this.el.focus();
this.el.setSelectionRange(0, (this.el.value && this.el.value.length) || 0);
}

willUnmount() {
this.trigger('cancel');
}

get dm() {
return this.threads[this.props.dmID];
}


//--------------------------------------------------------------------------
// Private
//--------------------------------------------------------------------------

_cancel() {
this.trigger('cancel', { dmID: this.props.dmID });
}

//--------------------------------------------------------------------------
// Handlers
//--------------------------------------------------------------------------

_onBlur(ev) {
this._cancel();
}

_onClick(ev) {
ev.stopPropagation();
}

_onKeydown(ev) {
switch (ev.which) {
case $.ui.keyCode.ENTER:
this._onKeydownEnter(ev);
break;
case $.ui.keyCode.ESCAPE:
this._cancel();
break;
}
}

_onKeydownEnter(ev) {
const dmChat = this.props.dmChat;
const value = this.el.value;
const newName = value || dmChat.directPartnerName;
if (dmChat.name !== newName) {
this.env.store.messaging.dispatch('renameThread', {
threadID: dmChat.id,
name: newName,
});
} else {
this._cancel();
}
}
}

return connect(mapStateToProps)(DmEditableName);

});
Oops, something went wrong.

0 comments on commit 47aeb20

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