Move models to their own files
This commit is contained in:
@@ -1,13 +1,11 @@
|
||||
function onRoomUpdated(user_id, category, room_id, display_name, avatar_url,
|
||||
topic, inviter, left_event) {
|
||||
|
||||
models.roomCategories.upsert({"userId": user_id, "name": category}, {
|
||||
roomCategories.upsert({"userId": user_id, "name": category}, {
|
||||
"userId": user_id,
|
||||
"name": category
|
||||
})
|
||||
|
||||
var rooms = models.rooms
|
||||
|
||||
function roles(for_category) {
|
||||
return {"userId": user_id, "roomId": room_id, "category": for_category}
|
||||
}
|
||||
@@ -47,7 +45,7 @@ function onRoomUpdated(user_id, category, room_id, display_name, avatar_url,
|
||||
|
||||
function onRoomDeleted(user_id, category, room_id) {
|
||||
var roles = {"userId": user_id, "roomId": room_id, "category": category}
|
||||
models.rooms.popWhere(roles, 1)
|
||||
rooms.popWhere(roles, 1)
|
||||
}
|
||||
|
||||
|
||||
@@ -78,19 +76,19 @@ function onTimelineEventReceived(
|
||||
}
|
||||
|
||||
// Replace any matching local echo
|
||||
var found = models.timelines.getIndices({
|
||||
var found = timelines.getIndices({
|
||||
"roomId": room_id,
|
||||
"senderId": sender_id,
|
||||
"content": content,
|
||||
"isLocalEcho": true
|
||||
}, 1, 500)
|
||||
if (found.length > 0) {
|
||||
models.timelines.set(found[0], item)
|
||||
timelines.set(found[0], item)
|
||||
return
|
||||
}
|
||||
|
||||
// Multiple clients will emit duplicate events with the same eventId
|
||||
models.timelines.upsert({"eventId": event_id}, item, true, 500)
|
||||
timelines.upsert({"eventId": event_id}, item, true, 500)
|
||||
}
|
||||
|
||||
|
||||
|
@@ -1,14 +1,14 @@
|
||||
function onAccountUpdated(user_id) {
|
||||
models.accounts.append({"userId": user_id})
|
||||
accounts.append({"userId": user_id})
|
||||
}
|
||||
|
||||
function onAccountDeleted(user_id) {
|
||||
models.accounts.popWhere({"userId": user_id}, 1)
|
||||
accounts.popWhere({"userId": user_id}, 1)
|
||||
}
|
||||
|
||||
// TODO: get updated from nio rooms
|
||||
function onUserUpdated(user_id, display_name, avatar_url, status_message) {
|
||||
models.users.upsert({"userId": user_id}, {
|
||||
users.upsert({"userId": user_id}, {
|
||||
"userId": user_id,
|
||||
"displayName": display_name,
|
||||
"avatarUrl": avatar_url,
|
||||
|
Reference in New Issue
Block a user