Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ exclude: |
(LICENSE.*|COPYING.*)
default_language_version:
python: python3
node: "16.17.0"
node: system
repos:
- repo: local
hooks:
Expand Down
92 changes: 92 additions & 0 deletions mail_discuss_channel_hide_sidebar/README.rst
Original file line number Diff line number Diff line change
@@ -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 <https://github.com/OCA/social/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 <https://github.com/OCA/social/issues/new?body=module:%20mail_discuss_channel_hide_sidebar%0Aversion:%2017.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

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

Credits
=======

Authors
-------

* APSL-Nagarro

Contributors
------------

- `APSL Nagarro <https://nagarro.com>`__

- 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 <https://github.com/OCA/social/tree/17.0/mail_discuss_channel_hide_sidebar>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
3 changes: 3 additions & 0 deletions mail_discuss_channel_hide_sidebar/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from . import models
23 changes: 23 additions & 0 deletions mail_discuss_channel_hide_sidebar/__manifest__.py
Original file line number Diff line number Diff line change
@@ -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,
}
4 changes: 4 additions & 0 deletions mail_discuss_channel_hide_sidebar/models/__init__.py
Original file line number Diff line number Diff line change
@@ -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
46 changes: 46 additions & 0 deletions mail_discuss_channel_hide_sidebar/models/discuss_channel.py
Original file line number Diff line number Diff line change
@@ -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)
24 changes: 24 additions & 0 deletions mail_discuss_channel_hide_sidebar/models/discuss_channel_member.py
Original file line number Diff line number Diff line change
@@ -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
3 changes: 3 additions & 0 deletions mail_discuss_channel_hide_sidebar/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["whool"]
build-backend = "whool.buildapi"
2 changes: 2 additions & 0 deletions mail_discuss_channel_hide_sidebar/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- [APSL Nagarro](https://nagarro.com)
- Miquel Alzanillas
4 changes: 4 additions & 0 deletions mail_discuss_channel_hide_sidebar/readme/DESCRIPTION.md
Original file line number Diff line number Diff line change
@@ -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.
6 changes: 6 additions & 0 deletions mail_discuss_channel_hide_sidebar/readme/USAGE.md
Original file line number Diff line number Diff line change
@@ -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.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading