Fix getUser binding loops & coro race conditions
This commit is contained in:
@@ -7,15 +7,13 @@ HListModel {
|
||||
var found = getWhere({"userId": user_id}, 1)
|
||||
if (found.length > 0) { return found[0] }
|
||||
|
||||
append({
|
||||
py.callCoro("request_user_update_event", [user_id])
|
||||
|
||||
return {
|
||||
"userId": user_id,
|
||||
"displayName": "",
|
||||
"avatarUrl": "",
|
||||
"statusMessage": ""
|
||||
})
|
||||
|
||||
py.callCoro("request_user_update_event", [user_id])
|
||||
|
||||
return getWhere({"userId": user_id}, 1)[0]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -17,17 +17,17 @@ Python {
|
||||
}
|
||||
|
||||
function callCoro(name, args, kwargs, callback) {
|
||||
call("APP.call_backend_coro", [name, args, kwargs], function(uuid){
|
||||
pendingCoroutines[uuid] = callback || function() {}
|
||||
})
|
||||
var uuid = Math.random() + "." + name
|
||||
|
||||
pendingCoroutines[uuid] = callback || function() {}
|
||||
call("APP.call_backend_coro", [name, uuid, args, kwargs])
|
||||
}
|
||||
|
||||
function callClientCoro(account_id, name, args, kwargs, callback) {
|
||||
var args = [account_id, name, args, kwargs]
|
||||
var uuid = Math.random() + "." + name
|
||||
|
||||
call("APP.call_client_coro", args, function(uuid){
|
||||
pendingCoroutines[uuid] = callback || function() {}
|
||||
})
|
||||
pendingCoroutines[uuid] = callback || function() {}
|
||||
call("APP.call_client_coro", [account_id, name, uuid, args, kwargs])
|
||||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
|
@@ -6,9 +6,7 @@ Column {
|
||||
id: accountDelegate
|
||||
width: parent.width
|
||||
|
||||
// Avoid binding loop by using Component.onCompleted
|
||||
property var userInfo: null
|
||||
Component.onCompleted: userInfo = users.getUser(model.userId)
|
||||
property var userInfo: users.getUser(model.userId)
|
||||
|
||||
property bool expanded: true
|
||||
|
||||
@@ -19,6 +17,7 @@ Column {
|
||||
|
||||
HUserAvatar {
|
||||
id: avatar
|
||||
// Need to do this because conflict with the model property
|
||||
Component.onCompleted: userId = model.userId
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user