diff --git a/src/backend/matrix_client.py b/src/backend/matrix_client.py index d70d4a9e..d1707146 100644 --- a/src/backend/matrix_client.py +++ b/src/backend/matrix_client.py @@ -1788,7 +1788,7 @@ class MatrixClient(nio.AsyncClient): notify: Optional[bool] = None, highlight: Optional[bool] = None, bubble: Optional[bool] = None, - sound: Optional[bool] = None, + sound: Optional[str] = None, urgency_hint: Optional[bool] = None, ) -> None: @@ -1811,9 +1811,8 @@ class MatrixClient(nio.AsyncClient): elif bubble is False or (bubble is None and not current.bubble): actions.append(nio.PushSetTweak("bubble", False)) - # XXX: don't always override with "default" if sound or (sound is None and current.sound): - actions.append(nio.PushSetTweak("sound", "default")) + actions.append(nio.PushSetTweak("sound", sound)) hint = urgency_hint diff --git a/src/backend/models/items.py b/src/backend/models/items.py index 30343f2b..7663f483 100644 --- a/src/backend/models/items.py +++ b/src/backend/models/items.py @@ -107,7 +107,7 @@ class PushRule(ModelItem): notify: bool = False highlight: bool = False bubble: bool = False - sound: bool = False + sound: str = "" # usually "default" when set urgency_hint: bool = False def __lt__(self, other: "PushRule") -> bool: diff --git a/src/backend/models/model.py b/src/backend/models/model.py index ce74e439..a821b922 100644 --- a/src/backend/models/model.py +++ b/src/backend/models/model.py @@ -108,7 +108,11 @@ class Model(MutableMapping): del self._sorted_data[index_then] self._sorted_data.add(new) - index_now = self._sorted_data.index(new) + try: + index_now = self._sorted_data.index(new) + except ValueError: + import remote_pdb; remote_pdb.RemotePdb("127.0.0.1", 4444).set_trace() + pass # Insert into dict data diff --git a/src/backend/nio_callbacks.py b/src/backend/nio_callbacks.py index f4204ce8..726f6f44 100644 --- a/src/backend/nio_callbacks.py +++ b/src/backend/nio_callbacks.py @@ -825,7 +825,7 @@ class NioCallbacks: high = tweaks.get("highlight", False) is not False bubble = tweaks.get("bubble", notify) is not False - sound = tweaks.get("sound", False) is not False + sound = str(tweaks.get("sound") or "") hint = tweaks.get("urgency_hint", high) is not False model[kind.value, rule.id] = PushRule( diff --git a/src/gui/Pages/AccountSettings/NotificationRuleButton.qml b/src/gui/Pages/AccountSettings/NotificationRuleButton.qml index 4d95b887..07aa0e84 100644 --- a/src/gui/Pages/AccountSettings/NotificationRuleButton.qml +++ b/src/gui/Pages/AccountSettings/NotificationRuleButton.qml @@ -5,14 +5,15 @@ import "../../Base" HButton { property string toggles: "" + property var nextValue: ! on readonly property bool on: toggles && page.pendingEdits[model.id] && toggles in page.pendingEdits[model.id] ? - page.pendingEdits[model.id][toggles] : + Boolean(page.pendingEdits[model.id][toggles]) : toggles ? - model[toggles] : + Boolean(model[toggles]) : true @@ -26,10 +27,10 @@ HButton { if (! (model.id in page.pendingEdits)) page.pendingEdits[model.id] = {} - if ((! on) === model[toggles]) + if ((! on) === Boolean(model[toggles])) delete page.pendingEdits[model.id][toggles] else - page.pendingEdits[model.id][toggles] = ! on + page.pendingEdits[model.id][toggles] = nextValue if (! Object.keys(page.pendingEdits[model.id]).length) delete page.pendingEdits[model.id] diff --git a/src/gui/Pages/AccountSettings/NotificationRuleDelegate.qml b/src/gui/Pages/AccountSettings/NotificationRuleDelegate.qml index 1e1b0121..87cd82c1 100644 --- a/src/gui/Pages/AccountSettings/NotificationRuleDelegate.qml +++ b/src/gui/Pages/AccountSettings/NotificationRuleDelegate.qml @@ -136,6 +136,11 @@ HTile { NotificationRuleButton { icon.name: "pushrule-action-sound" toggles: "sound" + nextValue: + on ? "" : + model[toggles] ? model[toggles] : + model.rule_id === ".m.rule.call" ? "ring" : + "default" } NotificationRuleButton {