Auto-save push rule tab action changes

This commit is contained in:
miruka 2021-02-25 05:14:42 -04:00
parent 4306098692
commit 84567f1ffd
3 changed files with 14 additions and 21 deletions

View File

@ -1860,7 +1860,7 @@ class MatrixClient(nio.AsyncClient):
await self.enable_pushrule("global", kind, rule_id, enable)
async def tweak_pushrule(
async def tweak_pushrule_actions(
self,
kind: Union[nio.PushRuleKind, str],
rule_id: str,
@ -1870,7 +1870,7 @@ class MatrixClient(nio.AsyncClient):
sound: Optional[str] = None,
urgency_hint: Optional[bool] = None,
) -> None:
"""Set an existing pushrule's actions. Works for builtin rules."""
"""Edit individual actions for any existing push rule."""
kind = nio.PushRuleKind[kind] if isinstance(kind, str) else kind
@ -1903,8 +1903,8 @@ class MatrixClient(nio.AsyncClient):
await self.set_pushrule_actions("global", kind, rule_id, actions)
async def mass_tweak_pushrules(self, *tweaks_kwargs) -> None:
coros = [self.tweak_pushrule(**kwargs) for kwargs in tweaks_kwargs]
async def mass_tweak_pushrules_actions(self, *tweaks_kwargs) -> None:
coros = [self.tweak_pushrule_actions(**kws) for kws in tweaks_kwargs]
await asyncio.gather(*coros)

View File

@ -26,7 +26,6 @@ HButton {
onClicked: {
if (requiresOn !== null && ! requiresOn.on) {
requiresOn.clicked()
print(on, clicked)
if (! on) clicked()
return
}

View File

@ -36,7 +36,7 @@ HListView {
saveFutureId = py.callClientCoro(
userId,
"mass_tweak_pushrules",
"mass_tweak_pushrules_actions",
args,
() => {
if (! root) return
@ -119,23 +119,17 @@ HListView {
width: root.width
}
footer: AutoDirectionLayout {
z: 100
width: root.width
enabled: Object.keys(root.pendingEdits).length !== 0
onPendingEditsChanged:
utils.isEmptyObject(pendingEdits) ?
autoSaveTimer.stop() :
autoSaveTimer.restart()
ApplyButton {
onClicked: root.save()
loading: root.saveFutureId !== ""
Component.onDestruction: ! utils.isEmptyObject(pendingEdits) && save()
Layout.topMargin: theme.spacing
}
CancelButton {
onClicked: pendingEdits = {}
Layout.topMargin: theme.spacing
}
Timer {
id: autoSaveTimer
interval: 10000
onTriggered: root.save()
}
FlickShortcuts {