From a526369210bebe885ebd075d49a3b200ae059546 Mon Sep 17 00:00:00 2001 From: Miquel Alzanillas Date: Wed, 18 Mar 2026 00:25:58 +0100 Subject: [PATCH] [ADD] mail_discuss_channel_hide_sidebar: New module --- .pre-commit-config.yaml | 2 +- mail_discuss_channel_hide_sidebar/README.rst | 92 ++++ mail_discuss_channel_hide_sidebar/__init__.py | 3 + .../__manifest__.py | 23 + .../models/__init__.py | 4 + .../models/discuss_channel.py | 46 ++ .../models/discuss_channel_member.py | 24 + .../pyproject.toml | 3 + .../readme/CONTRIBUTORS.md | 2 + .../readme/DESCRIPTION.md | 4 + .../readme/USAGE.md | 6 + .../static/description/icon.png | Bin 0 -> 10307 bytes .../static/description/index.html | 437 ++++++++++++++++++ .../common/channel_member_model_patch.esm.js | 10 + .../discuss_sidebar_categories_patch.esm.js | 43 ++ .../web/discuss_sidebar_categories_patch.xml | 21 + .../discuss_core_common_service_patch.esm.js | 19 + 17 files changed, 738 insertions(+), 1 deletion(-) create mode 100644 mail_discuss_channel_hide_sidebar/README.rst create mode 100644 mail_discuss_channel_hide_sidebar/__init__.py create mode 100644 mail_discuss_channel_hide_sidebar/__manifest__.py create mode 100644 mail_discuss_channel_hide_sidebar/models/__init__.py create mode 100644 mail_discuss_channel_hide_sidebar/models/discuss_channel.py create mode 100644 mail_discuss_channel_hide_sidebar/models/discuss_channel_member.py create mode 100644 mail_discuss_channel_hide_sidebar/pyproject.toml create mode 100644 mail_discuss_channel_hide_sidebar/readme/CONTRIBUTORS.md create mode 100644 mail_discuss_channel_hide_sidebar/readme/DESCRIPTION.md create mode 100644 mail_discuss_channel_hide_sidebar/readme/USAGE.md create mode 100644 mail_discuss_channel_hide_sidebar/static/description/icon.png create mode 100644 mail_discuss_channel_hide_sidebar/static/description/index.html create mode 100644 mail_discuss_channel_hide_sidebar/static/src/core/common/channel_member_model_patch.esm.js create mode 100644 mail_discuss_channel_hide_sidebar/static/src/core/web/discuss_sidebar_categories_patch.esm.js create mode 100644 mail_discuss_channel_hide_sidebar/static/src/core/web/discuss_sidebar_categories_patch.xml create mode 100644 mail_discuss_channel_hide_sidebar/static/src/discuss/core/common/discuss_core_common_service_patch.esm.js diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 53161f0a03..44298cbb8a 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -22,7 +22,7 @@ exclude: | (LICENSE.*|COPYING.*) default_language_version: python: python3 - node: "16.17.0" + node: system repos: - repo: local hooks: diff --git a/mail_discuss_channel_hide_sidebar/README.rst b/mail_discuss_channel_hide_sidebar/README.rst new file mode 100644 index 0000000000..05c4fb264d --- /dev/null +++ b/mail_discuss_channel_hide_sidebar/README.rst @@ -0,0 +1,92 @@ +================================= +Mail Discuss Channel Hide Sidebar +================================= + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:ce66e5e1521809c0aa1260386bb2d48a121a174c1cd67c6b0a3b3d0ba2db5fa4 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png + :target: https://odoo-community.org/page/development-status + :alt: Beta +.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 +.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fsocial-lightgray.png?logo=github + :target: https://github.com/OCA/social/tree/17.0/mail_discuss_channel_hide_sidebar + :alt: OCA/social +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/social-17-0/social-17-0-mail_discuss_channel_hide_sidebar + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png + :target: https://runboat.odoo-community.org/builds?repo=OCA/social&target_branch=17.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module adds a "Hide from list" action in Discuss sidebar channels. + +The action hides the channel for the current user without unsubscribing. +If a new message arrives in that channel, it appears again +automatically. + +**Table of contents** + +.. contents:: + :local: + +Usage +===== + +Go to Discuss and open the Channels sidebar section. + +Hover a channel and click the new eye-slash icon to hide it from the +list. You remain subscribed to the channel. + +When a new message is posted in that channel, it becomes visible again. + +Bug Tracker +=========== + +Bugs are tracked on `GitHub Issues `_. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us to smash it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +------- + +* APSL-Nagarro + +Contributors +------------ + +- `APSL Nagarro `__ + + - Miquel Alzanillas + +Maintainers +----------- + +This module is maintained by the OCA. + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use. + +This module is part of the `OCA/social `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/mail_discuss_channel_hide_sidebar/__init__.py b/mail_discuss_channel_hide_sidebar/__init__.py new file mode 100644 index 0000000000..31660d6a96 --- /dev/null +++ b/mail_discuss_channel_hide_sidebar/__init__.py @@ -0,0 +1,3 @@ +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from . import models diff --git a/mail_discuss_channel_hide_sidebar/__manifest__.py b/mail_discuss_channel_hide_sidebar/__manifest__.py new file mode 100644 index 0000000000..6eb65d15ec --- /dev/null +++ b/mail_discuss_channel_hide_sidebar/__manifest__.py @@ -0,0 +1,23 @@ +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +{ + "name": "Mail Discuss Channel Hide Sidebar", + "summary": ( + "Hide subscribed channels from Discuss sidebar " "until a new message arrives" + ), + "version": "17.0.1.0.0", + "category": "Discuss", + "author": "APSL-Nagarro, Odoo Community Association (OCA)", + "website": "https://github.com/OCA/social", + "license": "AGPL-3", + "depends": ["mail"], + "assets": { + "web.assets_backend": [ + "mail_discuss_channel_hide_sidebar/static/src/core/common/channel_member_model_patch.esm.js", + "mail_discuss_channel_hide_sidebar/static/src/discuss/core/common/discuss_core_common_service_patch.esm.js", + "mail_discuss_channel_hide_sidebar/static/src/core/web/discuss_sidebar_categories_patch.esm.js", + "mail_discuss_channel_hide_sidebar/static/src/core/web/discuss_sidebar_categories_patch.xml", + ], + }, + "installable": True, +} diff --git a/mail_discuss_channel_hide_sidebar/models/__init__.py b/mail_discuss_channel_hide_sidebar/models/__init__.py new file mode 100644 index 0000000000..4184e13dcd --- /dev/null +++ b/mail_discuss_channel_hide_sidebar/models/__init__.py @@ -0,0 +1,4 @@ +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from . import discuss_channel +from . import discuss_channel_member diff --git a/mail_discuss_channel_hide_sidebar/models/discuss_channel.py b/mail_discuss_channel_hide_sidebar/models/discuss_channel.py new file mode 100644 index 0000000000..b6e0bad6bd --- /dev/null +++ b/mail_discuss_channel_hide_sidebar/models/discuss_channel.py @@ -0,0 +1,46 @@ +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo import api, models + + +class DiscussChannel(models.Model): + _inherit = "discuss.channel" + + def _get_self_member(self): + self.ensure_one() + current_partner, current_guest = self.env["res.partner"]._get_current_persona() + domain = [("channel_id", "=", self.id)] + if current_partner: + domain.append(("partner_id", "=", current_partner.id)) + elif current_guest: + domain.append(("guest_id", "=", current_guest.id)) + else: + return self.env["discuss.channel.member"] + return self.env["discuss.channel.member"].search(domain, limit=1) + + def action_set_sidebar_hidden(self, hidden=True): + self.ensure_one() + member = self._get_self_member() + if not member: + return + vals = {"is_sidebar_hidden": bool(hidden)} + if hidden: + vals["is_pinned"] = False + member.write(vals) + if hidden: + # Keep native unpin bus behavior for immediate UI feedback. + self.env["bus.bus"]._sendone( + self.env.user.partner_id, "discuss.channel/unpin", {"id": self.id} + ) + else: + self.env["bus.bus"]._sendone( + self.env.user.partner_id, + "mail.record/insert", + {"Thread": self._channel_info()[0]}, + ) + + @api.returns("mail.message", lambda value: value.id) + def message_post(self, *, message_type="notification", **kwargs): + # Any new activity makes hidden channels visible again for members. + self.sudo().channel_member_ids.write({"is_sidebar_hidden": False}) + return super().message_post(message_type=message_type, **kwargs) diff --git a/mail_discuss_channel_hide_sidebar/models/discuss_channel_member.py b/mail_discuss_channel_hide_sidebar/models/discuss_channel_member.py new file mode 100644 index 0000000000..056547858d --- /dev/null +++ b/mail_discuss_channel_hide_sidebar/models/discuss_channel_member.py @@ -0,0 +1,24 @@ +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo import fields, models + + +class DiscussChannelMember(models.Model): + _inherit = "discuss.channel.member" + + is_sidebar_hidden = fields.Boolean( + string="Hidden in Discuss sidebar", + default=False, + help=( + "If enabled, this channel is hidden from the Discuss sidebar " + "for this member." + ), + ) + + def _discuss_channel_member_format(self, fields=None): + include_sidebar_hidden = not fields or fields.get("is_sidebar_hidden") + member_data = super()._discuss_channel_member_format(fields=fields) + if include_sidebar_hidden: + for member, values in member_data.items(): + values["is_sidebar_hidden"] = member.is_sidebar_hidden + return member_data diff --git a/mail_discuss_channel_hide_sidebar/pyproject.toml b/mail_discuss_channel_hide_sidebar/pyproject.toml new file mode 100644 index 0000000000..4231d0cccb --- /dev/null +++ b/mail_discuss_channel_hide_sidebar/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/mail_discuss_channel_hide_sidebar/readme/CONTRIBUTORS.md b/mail_discuss_channel_hide_sidebar/readme/CONTRIBUTORS.md new file mode 100644 index 0000000000..60601749f0 --- /dev/null +++ b/mail_discuss_channel_hide_sidebar/readme/CONTRIBUTORS.md @@ -0,0 +1,2 @@ +- [APSL Nagarro](https://nagarro.com) + - Miquel Alzanillas diff --git a/mail_discuss_channel_hide_sidebar/readme/DESCRIPTION.md b/mail_discuss_channel_hide_sidebar/readme/DESCRIPTION.md new file mode 100644 index 0000000000..374f79deca --- /dev/null +++ b/mail_discuss_channel_hide_sidebar/readme/DESCRIPTION.md @@ -0,0 +1,4 @@ +This module adds a "Hide from list" action in Discuss sidebar channels. + +The action hides the channel for the current user without unsubscribing. +If a new message arrives in that channel, it appears again automatically. diff --git a/mail_discuss_channel_hide_sidebar/readme/USAGE.md b/mail_discuss_channel_hide_sidebar/readme/USAGE.md new file mode 100644 index 0000000000..7702f26468 --- /dev/null +++ b/mail_discuss_channel_hide_sidebar/readme/USAGE.md @@ -0,0 +1,6 @@ +Go to Discuss and open the Channels sidebar section. + +Hover a channel and click the new eye-slash icon to hide it from the list. +You remain subscribed to the channel. + +When a new message is posted in that channel, it becomes visible again. diff --git a/mail_discuss_channel_hide_sidebar/static/description/icon.png b/mail_discuss_channel_hide_sidebar/static/description/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..e78da4cfd0f864b31c0136004d654c2597def206 GIT binary patch literal 10307 zcmV-JD7@E+P)Px#L}ge>W=%~1DgXcg2mk?xX#fNO00031000^Q000001E2u_0{{R30RRC20H6W@ z1ONa40RR91fS>~a1ONa40RR91fB*mh07#AmcK`qo6REQZDT+t{( z+yDhcWfKG%8W0f#7eql|&hK^qKMt4oy1)Lu*G+fJ)z|0VbI-Z=+gk51* z5A5oJT|Ka?2X^(qt{(U{_CTv|W24pPs;a6Xty;Aj{pqKlR_wLcUSYT0cAI4B;Rhag zV5MkUI&9t28<^I<4?p~{V#SITPqb~@b|T9E=%bH<;UFEdb?er}%a<>|C5^8o;=WZL zVDaL`o%Yycj}bP?eTL`ty{MaW&lZ+!OAULwhTY?&_gGQwk5)E zjRCA$wQ86t6~$MeNHc=4=bn28Gl*b{PSU_HzW5?++_({v#2Acc%%)A7t~>nj!`CIq z7WSvb8-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;K4F9gp+ z5N&m;1^?BkXu(ZPZJOGxH%d^rlrEUc*wT>dh?dr_V%y`}|E*Gdu^qIFu7&r&{{xs= VKsJHY%OU^(002ovPDHLkV1hYe78w8l literal 0 HcmV?d00001 diff --git a/mail_discuss_channel_hide_sidebar/static/description/index.html b/mail_discuss_channel_hide_sidebar/static/description/index.html new file mode 100644 index 0000000000..f1aecf1764 --- /dev/null +++ b/mail_discuss_channel_hide_sidebar/static/description/index.html @@ -0,0 +1,437 @@ + + + + + +Mail Discuss Channel Hide Sidebar + + + +
+

Mail Discuss Channel Hide Sidebar

+ + +

Beta License: AGPL-3 OCA/social Translate me on Weblate Try me on Runboat

+

This module adds a “Hide from list” action in Discuss sidebar channels.

+

The action hides the channel for the current user without unsubscribing. +If a new message arrives in that channel, it appears again +automatically.

+

Table of contents

+ +
+

Usage

+

Go to Discuss and open the Channels sidebar section.

+

Hover a channel and click the new eye-slash icon to hide it from the +list. You remain subscribed to the channel.

+

When a new message is posted in that channel, it becomes visible again.

+
+
+

Bug Tracker

+

Bugs are tracked on GitHub Issues. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us to smash it by providing a detailed and welcomed +feedback.

+

Do not contact contributors directly about support or help with technical issues.

+
+
+

Credits

+
+

Authors

+
    +
  • APSL-Nagarro
  • +
+
+
+

Contributors

+ +
+
+

Maintainers

+

This module is maintained by the OCA.

+ +Odoo Community Association + +

OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use.

+

This module is part of the OCA/social project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+ + diff --git a/mail_discuss_channel_hide_sidebar/static/src/core/common/channel_member_model_patch.esm.js b/mail_discuss_channel_hide_sidebar/static/src/core/common/channel_member_model_patch.esm.js new file mode 100644 index 0000000000..dff6b747ec --- /dev/null +++ b/mail_discuss_channel_hide_sidebar/static/src/core/common/channel_member_model_patch.esm.js @@ -0,0 +1,10 @@ +/* @odoo-module */ + +import {ChannelMember} from "@mail/core/common/channel_member_model"; +import {Record} from "@mail/core/common/record"; + +import {patch} from "@web/core/utils/patch"; + +patch(ChannelMember.prototype, { + is_sidebar_hidden: Record.attr(false), +}); diff --git a/mail_discuss_channel_hide_sidebar/static/src/core/web/discuss_sidebar_categories_patch.esm.js b/mail_discuss_channel_hide_sidebar/static/src/core/web/discuss_sidebar_categories_patch.esm.js new file mode 100644 index 0000000000..71654eb577 --- /dev/null +++ b/mail_discuss_channel_hide_sidebar/static/src/core/web/discuss_sidebar_categories_patch.esm.js @@ -0,0 +1,43 @@ +/* @odoo-module */ + +import {DiscussSidebarCategories} from "@mail/discuss/core/web/discuss_sidebar_categories"; + +import {patch} from "@web/core/utils/patch"; + +patch(DiscussSidebarCategories.prototype, { + filteredThreads(category) { + const threads = super.filteredThreads(category); + if (category.id !== "channels") { + return threads; + } + return threads.filter((thread) => { + const selfMember = thread.selfMember; + const isHidden = selfMember && selfMember.is_sidebar_hidden; + if (!isHidden) { + return true; + } + return ( + (thread.message_unread_counter || 0) > 0 || + (thread.message_needaction_counter || 0) > 0 + ); + }); + }, + + async hideChannel(thread) { + await this.orm.call( + "discuss.channel", + "action_set_sidebar_hidden", + [[thread.id]], + { + hidden: true, + } + ); + thread.is_pinned = false; + if (thread.selfMember) { + thread.selfMember.is_sidebar_hidden = true; + } + if (thread.eq(this.store.discuss.thread)) { + this.threadService.setDiscussThread(this.store.discuss.inbox); + } + }, +}); diff --git a/mail_discuss_channel_hide_sidebar/static/src/core/web/discuss_sidebar_categories_patch.xml b/mail_discuss_channel_hide_sidebar/static/src/core/web/discuss_sidebar_categories_patch.xml new file mode 100644 index 0000000000..fb2144d831 --- /dev/null +++ b/mail_discuss_channel_hide_sidebar/static/src/core/web/discuss_sidebar_categories_patch.xml @@ -0,0 +1,21 @@ + + + + +
+ + + diff --git a/mail_discuss_channel_hide_sidebar/static/src/discuss/core/common/discuss_core_common_service_patch.esm.js b/mail_discuss_channel_hide_sidebar/static/src/discuss/core/common/discuss_core_common_service_patch.esm.js new file mode 100644 index 0000000000..fa67c56ffb --- /dev/null +++ b/mail_discuss_channel_hide_sidebar/static/src/discuss/core/common/discuss_core_common_service_patch.esm.js @@ -0,0 +1,19 @@ +/* @odoo-module */ + +import {DiscussCoreCommon} from "@mail/discuss/core/common/discuss_core_common_service"; + +import {patch} from "@web/core/utils/patch"; + +patch(DiscussCoreCommon.prototype, { + async _handleNotificationNewMessage(notif) { + await super._handleNotificationNewMessage(notif); + const channel = this.store.Thread.get({ + id: notif.payload.id, + model: "discuss.channel", + }); + if (channel && channel.selfMember) { + channel.is_pinned = true; + channel.selfMember.is_sidebar_hidden = false; + } + }, +});