summaryrefslogtreecommitdiff
path: root/addons/mail/static/src/js/thread_windows/abstract_thread_window.js
AgeCommit message (Collapse)Author
2020-06-15[REF] mail, *: refactor messaging with OWLSébastien Theys
This commit is a significant rewriting of client-side discuss, chatter, chat window, and messaging menu using OWL. The behavior should be broadly the same, with some slight functional changes here and there. From a technical standpoint, the code of messaging is mainly organized in 2 main groups of modules: - models, which are logical entities that depict the client-side state of messaging as a whole. - components, which are in charge of displaying information from models. This refactoring also introduces new JS guidelines regarding folder structure (/static) and naming rules for JS modules. Community PR: https://github.com/odoo/odoo/pull/39023 Enterprise PR: https://github.com/odoo/enterprise/pull/6249 Task-1914207 This PR is a collaborative work by Alexandre, Julien, Sébastien and Xavier, with the precious help of Lucas to speed it up towards the end. closes odoo/odoo#39023 Related: odoo/enterprise#6249 Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com> Co-authored-by: Alexandre Kühn <aku@odoo.com> Co-authored-by: Julien Giannone <jgi@odoo.com> Co-authored-by: Lucas Perais <lpe@odoo.com> Co-authored-by: Sébastien Theys <seb@odoo.com> Co-authored-by: Xavier Dubuc <xdu@odoo.com>
2020-04-17[IMP] mail, sms, snailmail, test_mail_full: adapt mail.notificationSébastien Theys
The purpose is to have more common code for failure and notifications, with less override in `sms` and `snailmail`. task-2176017 closes odoo/odoo#44170 Related: odoo/enterprise#9140 Related: odoo/upgrade#918 Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
2019-12-09[REV] mail: prevent message loss during connection issueAlexandre Kühn
This reverts commit e5479fcfdb76bdbf9301fb140d873483bafdb9e4. This commit prevented an issue of losing messages on post in case of connectivity loss. The implementation consists of keeping the content in the composer until the server acknowledges handling the message. However, this solution introduces significant issues. For instance, sending messages in quick succession will likely loose or duplicate some content, based on how fast/slow the RPC `message_post` is resolved. Plus, there was an issue on mobile because the input focus was lost during the RPC. As a consequence, the virtual keyboard flickered. The intent was to fix a rare issue, and since the problems of this solution clearly outweigh the gain, we decided to revert. closes odoo/odoo#41544 X-original-commit: 36b2e99e08bfc6d92a821d0346e783695580abf9 Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
2019-11-29[IMP] mail: show out of office ribbon on discussmgh-odoo
This commit adds the out-of-office ribbon at the top of the conversation in the discuss app. Task-2066672 closes odoo/odoo#39362 Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com> Co-authored-by: Mohammed Shekha <msh@odoo.com>
2019-07-16[FIX] mail : fix post message callback errorDavid Beguin
When posting a message (here is the livechat use case), the _postMessage function can call the callback function. but this parameter is not mandatory. If the caller of this function doesn't need a callback function to be called after execution, the _postMessage function was crashing as callback is not defined. This commit fix this _postMessage function by checking that callback is defined before calliing it. Pre-required for Task ID: 2028059 Fix Task : 2037048 PR #34917 Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2019-04-23[IMP] mail: prevent message loss during connection issueJulien Giannone
Before the changes, when a message was posted (on Discuss or in the chat window), the composer was cleared directly as it didn't wait for the rpc response. If there was latency or a connection loss, the message disappeared from the composer but took time to appear in the content window or didn't appear at all and was lost. Now, the composer waits for the rpc response and then is cleared. Task #1957856 closes odoo/odoo#32422 Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
2019-04-15[IMP] mail: improve document chat windowPrakash Prajapati
1. In the systray messaging menu, when hovering on a notification linked to a document chat, it now shows an "expand" icon. Clicking on icon opens the corresponding form view with the chatter. 2. Messages in a document chat window no longer show linked document in their header, as this is redundant with title of chat window. 3. Font size of words "on" and "from" in header of message in chat windows have been reduced in order to closely match font size of document link. Task-ID 1929169 closes odoo/odoo#30957 Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
2019-03-06[REF] mail: stop using jQuery animateAaron Bohy
Problem is that jQuery animate uses jQuery deferreds, so it may happen in tests that we fold a thread window, and we have to wait for 2 (?) nextTick to see that the window is actually folded. We use a css transition instead, which produces the exact same result.
2019-03-06[REF] mail: adapt code after jQuery updateVincent Schippefilt
Part of task 1896658 Co-authored-by: Aaron Bohy <aab@odoo.com> Co-authored-by: Christophe Matthieu <chm@odoo.com> Co-authored-by: Mathieu Duckerts-Antoine <dam@odoo.com> Co-authored-by: David Monjoie <dmo@odoo.com> Co-authored-by: Martin Geubelle <mge@odoo.com> Co-authored-by: svs-odoo <svs@odoo.com> Co-authored-by: Vincent Schippefilt <vsc@odoo.com>
2019-02-07[IMP] mail, hr_holidays: use leaves to compute im_statusXavierDo
When on leave, the im_status can be either leave_online or leave_offline. This will allow to display a specific icon and a default message when the user is not at the office. The leave can have an out of office message. This message will be displayed in the chat window instead of the user ooo message, and the end date of the leave will be displayed too. Technical details. Right now the im_status access leaves directly to know if a user is on leave or not. An index has been added to optimise this request (thanks to rco). A solution to optimise this would be to compute part of the information in a cron. Task: 1856205
2019-02-07[IMP] mail: add ooo status in chats windows.XavierDo
In a chat window with a single usert (dm_chat) the ooo status of the other user is displayed on the top when set. Task: 1856205
2018-12-06[IMP] im_livechat, mail: improved "is typing" notificationAlexandre Kühn
With this commit, the UI for "is typing..." notifications has changed. ** before **: In Discuss & chat windows, "is typing..." notification bar at the bottom of the thread, inside the conversation. ** after ** In chat windows, animated '...' next to conversation name. In Discuss, animated '...' next to conversation name in sidebar, and text below the composer. Task-ID 1881001
2018-11-22[FIX] mail: no autofocus when spawning a livechat windowLucas Perais (lpe)
Have a user A having the focus on the search bar, minding his own business Have a user B send a direct message to user A Before this commit, the chat window on user A's browser took the focus manu militari After this commit, the focus stays on user A's search bar OPW 1911553 closes odoo/odoo#28915
2018-11-16[FIX] mail: show message document link in chat windowAlexandre Kühn
Revision on https://github.com/odoo/odoo/commit/cd34f6de727d5b3858420cff3c9d3c5995c4e75c The commit above consisted of refactoring the JS mail module. A small regression was introduced on messages linked to a document from a chat window: it was no longer displaying the link to redirect to the document that this message originates from. This issue was only isolated to chat windows: it was working fine in the Discuss app. This commit re-introduces the displaying of the document link on messages from chat windows. Task-ID 1910119
2018-09-12[FIX] im_livechat, mail: any thread window has an IDAlexandre Kühn
Before this commit, only thread windows in the backend had the method `getID`. However, it should also be the case for the thread windows in the frontend (website livechat), as the template of any thread window makes use of this method.
2018-08-30[FIX] mail: correctly handle (non-)passive thread windowsAlexandre Kühn
Definition of '(non-)passive' thread window: Thread windows can be either 'passive' or 'active' (default: 'active'). - When opening a thread window in 'active' mode, the messages are marked as read, and the focus is on the thread window. - When opening a thread window in 'passive' mode, the messages are not marked as read and there is no focus on the thread window. Messages are kept unread until the user interacts with the thread window (e.g. by clicking on composer). When the user intentionally opens a thread window, it should be open in active mode. However, when a thread window is open without any user iteractions, it should open in passive mode. The later case is useful in some cases. For instance, when receiving a new message from a DM conversation, it should automatically open the corresponding thread window. However, it should not automatically mark messages as read. This commit contains 2 bug fixes: 1. When receiving a new message on an active thread window, it no longer increments the unread counter. (When the focus is on the composer of the thread window, the user is immediately reading newly received messages.) 2. When receiving a new message from an unpinned DM conversation, the newly open thread window is always passive. (This was not the case before, so when receiving new messages, it did not increment the unread counter.)
2018-08-30[REF] mail: clean some JS codeAlexandre Kühn
1. Removed `getLocalMessages` method in mailbox, and replaced with an override on `getMessages`. (This method was used before the distinction was made between `getMessages` and `fetchMessages`) 2. Removed unused method `_warnUpdatedUnreadCounter` in abstract thread window. (Leftover from an early POC) 3. Set the default value `''` for the status of a thread. (The method `getStatus` should always return a string) 4. Enforce default value `false` for detached status of channel. (The method `isDetached` should always return a boolean) 5. Improve readability of some tests. (removed useless variables and/or redundant code)
2018-08-27[FIX][REF] mail: several thread windows fixesAlexandre Kühn
This commit fixes some bugs on thread windows, and make some improvements on tests related to thread windows. Fixes: 1. Correctly position last visible thread window when there are more open thread windows than available slots. 2. Closing a thread window now marks it as read. 3. Can now fold/unfold the blank thread window (aka 'New' thread window). Tests cleaning: 1. Removed unnecessary 'before assertions' in thread window tests. > Solved with this: https://github.com/odoo/odoo/commit/9b1daa1218f7adf9d741afba607ef5b55b16e3e6 1. Added basic rendering test for a (non-blank) thread window. 2. Cleaned thread window tests > Split in different files. > Grouped in 'Thread Window' QUnit module.
2018-08-13[IMP] mail, im_livechat: 'is typing...' indicator on mail channelsAlexandre Kühn
With this commit, most threads show an indicator when a member is typing something. e.g. "Mitchell Stephens is typing..." Supported threads: - DM - (public & private) channels - Livechat (Website & Backend) Unsupported threads: - mailboxes (e.g. 'Inbox') - document thread (= 'Chatter') - support channel (with `im_support` module) Some technical details: - This is a mix between 'start'/'stop' and 'regular notify' strategies. - On typing text in composer: notify 'start typing' to all members of thread. - On clearing text in composer: notify 'stop typing' to all members of thread. - A member can only notify once every 2.5 seconds to the server when he starts or stops typing something (throttled, buffered notify call). - On receiving a message from someone that is typing: determine that he is no longer typing. - On non-empty and unchanged composer text for 5.0 seconds: automatically notifies all members of thread that he is no longer typing anything. (This is like a 'soft / cooperative sender' timeout). - On non-receiving a typing notification of someone after 60 seconds: determine that he is not longer typing something (This is like a 'hard / receiver assumption' timeout). - When some types for more than 50 seconds straight: notify that he is still typing something (again and again every 50 seconds). - When two or more people are typing something (Multi-User channels), it displays at most 2 typing users (ordering rule: longer typers first): "Mitchell Stephens, Marc Brown and more are typing..." - Timing summary: - Usually 2.5 seconds uncertainty. - Up to 5.0 seconds uncertainty on typer inactivity. - Up to 60 seconds uncertainty on typer page reload / browser tab closed / etc. Future Improvements: - Detect page reload or browser tab close with loose of longpolling connection Task-ID 28188
2018-08-13[REF][FIX] mail, im_livechat: various improvements (JS)Alexandre Kühn
This commit makes a lot of small improvements of the JS of mail and related modules. A. Mail Manager --------------- im_support: - [REF] Slightly more robust way to determine a support message, so that it more reliably falls back on default kind of message (i.e. support channel UUID should be clearly set). mail: - [REF] Improved method names for readability purposes. Some examples: - `fetchFromServer` becomes `fetchMailStateFromServer` - `_initialize{*}` becomes `_update{*}FromServer` - `_isModerator` becomes `_isMyselfModerator` - [REF] Use 'template' pattern design to make Include on Mail Manager much more robust. In particular, the flow is always as follow: 1. Initialize internal state. 2. Listen on buses. 3. Fetch mail data from server. - [REF] Improved workflow for thread window workflow (Shorter & more readable). B. Mail Tests ------------- - [REF] Thread Window Tests crashes with clean message when there are some thread windows open before running the tests. C. (Model) Message ------------------ - [REF] Improved method names for readability purposes (e.g. `isAuthor` becomes `isMyselfAuthor`). D. (Model) Thread ----------------- - [REF] Improved `init` parameters on each kind of thread. - [REF] 'Thread With Cache' has been renamed to 'Searchable Thread': it embraces all kinds of threads that can be used with the search view. - [REF] 'DM' has been renamed to 'DM Chat' (for clarity). - [IMP] New Livechat model in the backend. - [REF] No more direct instances of the Channel class: public and private channels are now 'Multi-User' channels, while DM Chat and Livechat are 'Two-User' channels: This change has been made so that instances of classes always have direct classes as "leaf" in the Class modeling. It eases making changes to a certain model without being too constrained by another model. - [REF] As a consequence of above changed, the method `isChat` has been renamed to `isTwoUserThread`. This is to avoid confusion with the terminology 'chat', which is more like a shortcut for 'quick real- time conversation'. In other words, the property of 'chat' depends of the way to interact on a thread, not of the intrinsic type of the thread. Still, some parts have kept the terminology 'chat', such as in the systray messagin menu. - [IMP] Added `message_added` and `message_posted` hooks, which may be useful to easily hook on those events. E. Thread Widget ---------------- - [REF] Now uses a `mail.model.AbstractThread` for the rendering of a thread, instead of a list of `{mail.model.AbstractMessage}`. - [FIX] Stick thread scroll height to bottom on new rendering, if it was previously at the bottom of the thread. - [REF] Option ORDER has its meaning changed: it now refers to the chronological order of messages in the thread, in which DESC means 'from top to bottom', while ASC means 'from bottom to top'. - [REF] Improved doc on templates, in particular with the option `ORDER`. F. Thread Window ---------------- - [REF] Moved more logic to thread windows, which were previously in Mail Window Manager. - [REF] Now hides the thread widget attribute. So instead of `threadWindow.threadWidget.isAtBottom()`, it uses `threadWindow.isAtBottom()`. - [FIX] New received messages when not having focus on Odoo tab should always make the corresponding thread windows "passive" (i.e. windows that keep threads unread until click on them). - [FIX] Blank thread window (i.e. 'New message' TW) correctly opens Discuss with 'Inbox' when clicking on 'Expand' Button in the title - [FIX] Do not display the composer for channels with property 'mass-mailing' set in thread windows. G. (Website) Livechat --------------------- - [REF] Some `trigger` have been turned into `trigger_up`. - [REF] Some logic has been moved to models (e.g. `{im_livechat.model.WebsiteLivechat}`), from `{im_livechat.im_livechat.LivechatButton}`. - [FIX] New messages should be received in real-time. The longpolling was broken with a recent refactoring on bus service (6448420c5dd160470e465dee7729d19d8d5e7bab).
2018-08-10[REF] *: add support for RTL languagesMartin Trigaux
מזל טוב The direction parameter will now have a real impact on the web interface and completly switch the direction of the interface. Add the dependency rtlcss to switch the direction with a css postprocessor. Two different assets will be generated for ltr or rtl /web/content/<...>/web.assets_backend.0.css and /web/content/<...>/rtl/web.assets_backend.0.css to be able to differentiate it easily Adapt the css and views to be easier to switch direction Render graph as it is, do not move y-axis right side, as per mathematical rule value goes left from origin are considered negative, so keep graph as it is for right to left language add test cases for language direction specific assets bundle if language direction is rtl then we also store css files in assets bundle now we store two assets bundle, one for ltr and one for rtl language direction test two assets bundles generated, also test two assets bundle generated for en_US and ar_SY
2018-07-19[FIX] im_livechat,mail: clean thread models and windowsAlexandre Kühn
- Cleaning website livechat window so that some behaviour are in website livechat instead. - More shared code in abstract thread / abstract thread windows, thanks to the introduction of website_livechat model.
2018-07-19[IMP] mail, *: template rendering with abstract thread, adapt thread ↵Alexandre Kühn
instantiation, thread `getMessages`/`fetchMessages`, and create mode document thread. * = im_livechat, im_support - thread widget now uses abstract thread in `render` method - thread models have their `init` parameters changed, so that the parent may be optional - reworked 'creating a new record...' in chatter in create mode: > new model CreateModeDocumentThread, which basically is a fake document thread with a fake message for its rendering in create mode of the chatter > special rendering method of thread_widget for such case: `renderChatterCreateMode` - renamed thread methods previously named `getMessages` to `fetchMessages`: > in order to not conflict with `getMessages`, used for rendering > now, `getMessages` always get messages that are locally, while `fetchMessages` may fetch messages. TODO: - special thread model for im_livechat (rendering is broken ATM)
2018-07-19[REF] im_livechat,mail: renamed "livechat" to "website livechat"Alexandre Kühn
Renamed "livechat" model into "website livechat", in order to avoid confusion with backend livechat. - `im_livechat.model.LivechatMessage` becomes `im_livechat.model.WebsiteLivechatMessage` - `im_livechat.LivechatWindow` becomes `im_livechat.WebsiteLivechatWindow`
2018-07-19[FIX] mail: improve names of option parameter, classname, and template nameAlexandre Kühn
- `displayEmptyChannel` thread rendering options becomes `displayEmptyThread` - classname `o_chat_content` becomes `o_thread-window_content`, as it is used only for thread windows. - template `mail.EmptyChannel` has been renamed to `mail.widget.Thread.Empty`
2018-07-02[REF] mail: JS mail refactoringAlexandre Kühn
---------------------- Summary ---------------------- The purpose of this commit is to improve the JS code of the `mail` module. It applies the new coding guidelines and makes some changes on the design of some modules, such as the old ChatManager module. Here is a short summary of the changes that have been made: 1. New coding guidelines - snake_case to camelCase - prefix private attributes and methods with '_' - jsdoc on most methods - one class per module 2. Rename/Merge some classes - 'chat manager' becomes 'mail manager' (internal) and 'mail service' (external) - 'chat window manager' is now included in mail manager - 'thread' widget now named 'thread widget' 3. New model abstraction for mail objects: - modules 'mail.model.*' - modeling: 0..1 0..1 * * ThreadWindow <------> Thread <-------> Message / \ / \ Thread With Cache Document Thread / | \ / | \ Mailbox Channel Support Channel | | DM - Thread: the superclass of threads. - ThreadWindow: the window component of a thread. - Message: mail objects representing messages. - Thread With Cache: threads that can be used with search view (Discuss app compatible). - Document Thread: represents the thread part of a chatter. - Mailbox: represents what was previously called 'static' channel, e.g. 'Inbox'. - Channel: mail objects representing channels, including livechat. - DM: special kind of Channel for 1:1 communication in the backend. - Support Channel: special channel for im_support module. This new modeling approach let us easily add features on all threads, such as the possibility to put any thread in a small window. ---------------------- Known issues ---------------------- [Already Present in Master] 1. When the Discuss app is in the background with 'Inbox' as the selected Thread, when clicking on a document thread preview in the messaging menu of the systray, the rainbow man appears. 2. When a document with the chatter is in the background, when receiving an inbox notification from this document thread, the document thread is automatically marked as read, which removes the notification right away. 3. Sometimes, opening a DM window from the "blank" thread window does not work. 4. Reply-to feature on Inbox is not working: no message is sent in the document thread. 5. On the first login of admin user with demo data, the inbox counter is wrong (it displays 6, instead of 3). Explanation after investigation: > On page load, it fetches the correct number of Inbox messages (3), but the server notifies of 3 needaction messages right away, so it wrongly assumes these are new needaction messages. > Not possible for web client to detect that these messages should not increment the Inbox counter while keeping same API. 6. Notifications for new document thread messages only work when the user sets 'handle with Odoo' for the Notification Management in the preferences. > due to notifications on the longpoll bus for document thread messages that come from needaction notifications. > requires server-side changes to send notification on the longpoll bus to mentionned user. [New] 7. When receiving a message on a unjoined channel, thread window flickers ('open' > 'close' > 'open') Explanation after investigation: > JS logic: a) On auto-join, ask server to join the channel and get channel infos. b) The info tells the channel is not detached, but JS code makes decision to detach it, and tells server the channel is now detached. c) From (a), server notifies on longpoll bus the state of channel, which is not detached. The web client thinks that the window state of the channel has been changed somewhere else, and the channel is now closed. d) From (b), server notifies on longpoll bus the state of channel, which is detached. The web client opens the thread window of this channel. > The flicker didn't occur before refactoring because the web client was only updating the model of channel when it receives the longpoll notification. > Server behaviour on 1st longpoll notification is necessary for cross-tab synchronization for channel window state. > New design implies that model and view should be synchronized, hence the issue now. > Solution: remove server-side thread window synchronization and replace with client-side synchronization. ---------------------- Hacks ---------------------- The module `im_livechat` now uses mail objects that are compatible with Message and Window objects: Modeling for messages: AbstractMessage / \ / \ LivechatMessage Message - AbstractMessage: message compatible with the thread widget. - LivechatMessage: message used by im_livechat. - Message: message used with the mail manager. Modeling for thread windows: AbstractThreadWindow / \ / \ LivechatWindow ThreadWindow - AbstractThreadWindow: behaviour share between all types of thread windows. - LivechatWindow: window used by im_livechat. - ThreadWindow: window used with mail_manager. The reason for these hacks are twofold: 1. Use the thread widget in the frontend and livechat external lib bundles. 2. Do not have a dependency with the mail manager in the frontend and external lib bundles.