Drop kwargs support for callCoro/callClientCoro

This commit is contained in:
miruka 2019-07-07 23:38:37 -04:00
parent 4f0ba24373
commit 8dccfffc8b
6 changed files with 22 additions and 25 deletions

View File

@ -44,12 +44,11 @@ class App:
def call_backend_coro(self, def call_backend_coro(self,
name: str, name: str,
uuid: str, uuid: str,
args: Optional[List[str]] = None, args: Optional[List[str]] = None) -> None:
kwargs: Optional[Dict[str, Any]] = None) -> None:
self._call_coro( self._call_coro(
getattr(self.backend, name)(*args or [], **kwargs or {}), uuid getattr(self.backend, name)(*args or []), uuid
) )
@ -57,11 +56,10 @@ class App:
account_id: str, account_id: str,
name: str, name: str,
uuid: str, uuid: str,
args: Optional[List[str]] = None, args: Optional[List[str]] = None) -> None:
kwargs: Optional[Dict[str, Any]] = None) -> None:
client = self.backend.clients[account_id] client = self.backend.clients[account_id]
self._call_coro( self._call_coro(
getattr(client, name)(*args or [], **kwargs or {}), uuid getattr(client, name)(*args or []), uuid
) )

View File

@ -35,17 +35,17 @@ Banner {
"accept": function(button) { "accept": function(button) {
button.loading = true button.loading = true
py.callClientCoro( py.callClientCoro(
chatPage.userId, "join", [chatPage.roomId], {}, chatPage.userId, "join", [chatPage.roomId], function() {
function() { button.loading = false } button.loading = false
) })
}, },
"decline": function(button) { "decline": function(button) {
button.loading = true button.loading = true
py.callClientCoro( py.callClientCoro(
chatPage.userId, "room_leave", [chatPage.roomId], {}, chatPage.userId, "room_leave", [chatPage.roomId], function() {
function() { button.loading = false } button.loading = false
) })
} }
} }
} }

View File

@ -24,9 +24,9 @@ Banner {
"forget": function(button) { "forget": function(button) {
button.loading = true button.loading = true
py.callClientCoro( py.callClientCoro(
chatPage.userId, "room_forget", [chatPage.roomId], {}, chatPage.userId, "room_forget", [chatPage.roomId], function() {
function() { button.loading = false } button.loading = false
) })
} }
} }
} }

View File

@ -50,7 +50,6 @@ HRectangle {
chatPage.userId, chatPage.userId,
"load_past_events", "load_past_events",
[chatPage.roomId], [chatPage.roomId],
{},
function(more_to_load) { canLoad = more_to_load } function(more_to_load) { canLoad = more_to_load }
) )
} }

View File

@ -26,7 +26,7 @@ Item {
button.loading = true button.loading = true
var args = [idField.text, passwordField.text] var args = [idField.text, passwordField.text]
py.callCoro("login_client", args, {}, function(user_id) { py.callCoro("login_client", args, function(user_id) {
pageStack.showPage( pageStack.showPage(
"RememberAccount", "RememberAccount",
{"loginWith": loginWith, "userId": user_id} {"loginWith": loginWith, "userId": user_id}

View File

@ -16,18 +16,18 @@ Python {
return call_sync("APP.backend." + name, args) return call_sync("APP.backend." + name, args)
} }
function callCoro(name, args, kwargs, callback) { function callCoro(name, args, callback) {
var uuid = Math.random() + "." + name var uuid = Math.random() + "." + name
pendingCoroutines[uuid] = callback || function() {} pendingCoroutines[uuid] = callback || function() {}
call("APP.call_backend_coro", [name, uuid, args, kwargs]) call("APP.call_backend_coro", [name, uuid, args])
} }
function callClientCoro(account_id, name, args, kwargs, callback) { function callClientCoro(account_id, name, args, callback) {
var uuid = Math.random() + "." + name var uuid = Math.random() + "." + name
pendingCoroutines[uuid] = callback || function() {} pendingCoroutines[uuid] = callback || function() {}
call("APP.call_client_coro", [account_id, name, uuid, args, kwargs]) call("APP.call_client_coro", [account_id, name, uuid, args])
} }
Component.onCompleted: { Component.onCompleted: {
@ -43,13 +43,13 @@ Python {
call("APP.is_debug_on", [Qt.application.arguments], function(on) { call("APP.is_debug_on", [Qt.application.arguments], function(on) {
window.debug = on window.debug = on
callCoro("has_saved_accounts", [], {}, function(has) { callCoro("has_saved_accounts", [], function(has) {
py.ready = true py.ready = true
willLoadAccounts(has) willLoadAccounts(has)
if (has) { if (has) {
py.loadingAccounts = true py.loadingAccounts = true
py.callCoro("load_saved_accounts", [], {}, function() { py.callCoro("load_saved_accounts", [], function() {
py.loadingAccounts = false py.loadingAccounts = false
}) })
} }