Optimize model upsert, ensure right type for roles
This commit is contained in:
@@ -81,10 +81,24 @@ SortFilterProxyModel {
|
||||
return model.get(model.count)
|
||||
}
|
||||
|
||||
if (update_if_exist != false) {
|
||||
model.set(indices[0], new_item)
|
||||
}
|
||||
return model.get(indices[0])
|
||||
var existing = model.get(indices[0])
|
||||
if (update_if_exist == false) { return existing }
|
||||
|
||||
// Really update only if existing and new item have a difference
|
||||
for (var role in existing) {
|
||||
if (Boolean(existing[role].getTime)) {
|
||||
if (existing[role].getTime() != new_item[role].getTime()) {
|
||||
model.set(indices[0], new_item)
|
||||
return existing
|
||||
}
|
||||
} else {
|
||||
if (existing[role] != new_item[role]) {
|
||||
model.set(indices[0], new_item)
|
||||
return existing
|
||||
}
|
||||
}
|
||||
}
|
||||
return existing
|
||||
}
|
||||
|
||||
function pop(index) {
|
||||
|
@@ -35,7 +35,7 @@ HColumnLayout {
|
||||
RoomHeader {
|
||||
id: roomHeader
|
||||
displayName: roomInfo.displayName
|
||||
topic: roomInfo.topic || ""
|
||||
topic: roomInfo.topic
|
||||
|
||||
Layout.fillWidth: true
|
||||
Layout.preferredHeight: HStyle.avatar.size
|
||||
|
@@ -72,7 +72,7 @@ function onTimelineEventReceived(
|
||||
"isLocalEcho": is_local_echo,
|
||||
"showNameLine": show_name_line,
|
||||
"translatable": translatable,
|
||||
"targetUserId": target_user_id || "",
|
||||
"targetUserId": target_user_id,
|
||||
}
|
||||
|
||||
// Replace any matching local echo
|
||||
|
@@ -6,7 +6,6 @@ function onAccountDeleted(user_id) {
|
||||
accounts.popWhere({"userId": user_id}, 1)
|
||||
}
|
||||
|
||||
// TODO: get updated from nio rooms
|
||||
function onUserUpdated(user_id, display_name, avatar_url, status_message) {
|
||||
users.upsert({"userId": user_id}, {
|
||||
"userId": user_id,
|
||||
|
@@ -40,7 +40,7 @@ Column {
|
||||
|
||||
HTextField {
|
||||
id: statusEdit
|
||||
text: user.statusMessage || ""
|
||||
text: user.statusMessage
|
||||
placeholderText: qsTr("Set status message")
|
||||
font.pixelSize: HStyle.fontSize.small
|
||||
background: null
|
||||
|
Reference in New Issue
Block a user