New backend work
Models, account connection, fetching user profiles, show connected accounts in sidebar
This commit is contained in:
@@ -1,2 +1,5 @@
|
||||
// FIXME: Obsolete method, but need Qt 5.12+ for standard JS modules import
|
||||
Qt.include("app.js")
|
||||
Qt.include("users.js")
|
||||
Qt.include("rooms.js")
|
||||
Qt.include("rooms_timeline.js")
|
||||
|
60
src/qml/EventHandlers/rooms.js
Normal file
60
src/qml/EventHandlers/rooms.js
Normal file
@@ -0,0 +1,60 @@
|
||||
function clientId(user_id, category, room_id) {
|
||||
return user_id + " " + room_id + " " + category
|
||||
}
|
||||
|
||||
|
||||
function onRoomUpdated(user_id, category, room_id, display_name, avatar_url,
|
||||
topic, last_event_date, inviter, left_event) {
|
||||
|
||||
var client_id = clientId(user_id, category, room_id)
|
||||
var rooms = models.rooms
|
||||
|
||||
if (category == "Invites") {
|
||||
rooms.popWhere("clientId", clientId(user_id, "Rooms", room_id))
|
||||
rooms.popWhere("clientId", clientId(user_id, "Left", room_id))
|
||||
}
|
||||
else if (category == "Rooms") {
|
||||
rooms.popWhere("clientId", clientId(user_id, "Invites", room_id))
|
||||
rooms.popWhere("clientId", clientId(user_id, "Left", room_id))
|
||||
}
|
||||
else if (category == "Left") {
|
||||
var old_room =
|
||||
rooms.popWhere("clientId", clientId(user_id, "Rooms", room_id)) ||
|
||||
rooms.popWhere("clientId", clientId(user_id, "Invites", room_id))
|
||||
|
||||
if (old_room) {
|
||||
display_name = old_room.displayName
|
||||
avatar_url = old_room.avatarUrl
|
||||
topic = old_room.topic
|
||||
inviter = old_room.topic
|
||||
}
|
||||
}
|
||||
|
||||
rooms.upsert("clientId", client_id , {
|
||||
"clientId": client_id,
|
||||
"userId": user_id,
|
||||
"category": category,
|
||||
"roomId": room_id,
|
||||
"displayName": display_name,
|
||||
"avatarUrl": avatar_url,
|
||||
"topic": topic,
|
||||
"lastEventDate": last_event_date,
|
||||
"inviter": inviter,
|
||||
"leftEvent": left_event
|
||||
})
|
||||
//print("room up", rooms.toJson())
|
||||
}
|
||||
|
||||
|
||||
function onRoomDeleted(user_id, category, room_id) {
|
||||
var client_id = clientId(user_id, category, room_id)
|
||||
return models.rooms.popWhere("clientId", client_id, 1)
|
||||
}
|
||||
|
||||
|
||||
function onRoomMemberUpdated(room_id, user_id, typing) {
|
||||
}
|
||||
|
||||
|
||||
function onRoomMemberDeleted(room_id, user_id) {
|
||||
}
|
0
src/qml/EventHandlers/rooms_timeline.js
Normal file
0
src/qml/EventHandlers/rooms_timeline.js
Normal file
24
src/qml/EventHandlers/users.js
Normal file
24
src/qml/EventHandlers/users.js
Normal file
@@ -0,0 +1,24 @@
|
||||
function onAccountUpdated(user_id) {
|
||||
models.accounts.append({"userId": user_id})
|
||||
}
|
||||
|
||||
function AccountDeleted(user_id) {
|
||||
models.accounts.popWhere("userId", user_id, 1)
|
||||
}
|
||||
|
||||
function onUserUpdated(user_id, display_name, avatar_url, status_message) {
|
||||
models.users.upsert("userId", user_id, {
|
||||
"userId": user_id,
|
||||
"displayName": display_name,
|
||||
"avatarUrl": avatar_url,
|
||||
"statusMessage": status_message
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
function onDeviceUpdated(user_id, device_id, ed25519_key, trust, display_name,
|
||||
last_seen_ip, last_seen_date) {
|
||||
}
|
||||
|
||||
function onDeviceDeleted(user_id, device_id) {
|
||||
}
|
Reference in New Issue
Block a user