Implement removing push rules

This commit is contained in:
miruka 2021-02-22 11:39:55 -04:00
parent 765ce46aeb
commit 8c4e5deb66
3 changed files with 15 additions and 1 deletions

View File

@ -1,6 +1,5 @@
# TODO # TODO
- push popup cancel & remove
- right click on rule - right click on rule
- combo box custom item - combo box custom item
- explain pattern - explain pattern

View File

@ -1903,6 +1903,15 @@ class MatrixClient(nio.AsyncClient):
await asyncio.gather(*coros) await asyncio.gather(*coros)
async def remove_pushrule(
self, kind: Union[str, nio.PushRuleKind], rule_id: str,
) -> None:
"""Remove an existing non-builtin pushrule."""
kind = nio.PushRuleKind[kind] if isinstance(kind, str) else kind
await self.delete_pushrule("global", kind, rule_id)
# Functions to register/modify data into models # Functions to register/modify data into models
async def update_account_unread_counts(self) -> None: async def update_account_unread_counts(self) -> None:

View File

@ -49,6 +49,11 @@ HFlickableColumnPopup {
py.callClientCoro(userId, "edit_pushrule", args, root.close) py.callClientCoro(userId, "edit_pushrule", args, root.close)
} }
function remove() {
const args = [rule.kind, rule.rule_id]
py.callClientCoro(userId, "remove_pushrule", args, root.close)
}
page.implicitWidth: Math.min(maximumPreferredWidth, 550 * theme.uiScale) page.implicitWidth: Math.min(maximumPreferredWidth, 550 * theme.uiScale)
page.footer: AutoDirectionLayout { page.footer: AutoDirectionLayout {
@ -67,6 +72,7 @@ HFlickableColumnPopup {
icon.name: "pushrule-remove" icon.name: "pushrule-remove"
text: qsTr("Remove rule") text: qsTr("Remove rule")
enabled: ! root.rule.default enabled: ! root.rule.default
onClicked: root.remove()
} }
} }