start of activity center function calls

This commit is contained in:
Jonathan Rainville 2021-05-28 14:34:32 -04:00 committed by Iuri Matias
parent bee54e628f
commit 18b26a1c67
3 changed files with 42 additions and 2 deletions

View File

@ -59,6 +59,7 @@ type
channels*: Table[string, Chat]
msgCursor*: Table[string, string]
pinnedMsgCursor*: Table[string, string]
activityCenterCursor*: string
emojiCursor*: Table[string, string]
lastMessageTimestamps*: Table[string, int64]
@ -176,6 +177,21 @@ proc requestMissingCommunityInfos*(self: ChatModel) =
for communityId in self.communitiesToFetch:
status_chat.requestCommunityInfo(communityId)
proc activityCenterNotification*(self: ChatModel, initialLoad:bool = true) =
# Notifications were already loaded, since cursor will
# be nil/empty if there are no more notifs
if(not initialLoad and self.activityCenterCursor == ""): return
status_chat.activityCenterNotification(self.activityCenterCursor)
# self.activityCenterCursor[chatId] = messageTuple[0];
# if messageTuple[1].len > 0:
# let lastMsgIndex = messageTuple[1].len - 1
# let ts = times.convert(Milliseconds, Seconds, messageTuple[1][lastMsgIndex].whisperTimestamp.parseInt())
# self.lastMessageTimestamps[chatId] = ts
# self.events.emit("messagesLoaded", MsgsLoadedArgs(messages: messageTuple[1]))
proc init*(self: ChatModel, pubKey: string, messagesFromContactsOnly: bool) =
self.publicKey = pubKey
self.messagesFromContactsOnly = messagesFromContactsOnly
@ -186,6 +202,8 @@ proc init*(self: ChatModel, pubKey: string, messagesFromContactsOnly: bool) =
if (messagesFromContactsOnly):
chatList = self.cleanSpamChatGroups(chatList, contacts)
# self.activityCenterNotification()
let profileUpdatesChatIds = chatList.filter(c => c.chatType == ChatType.Profile).map(c => c.id)
if chatList.filter(c => c.chatType == ChatType.Timeline).len == 0:

View File

@ -508,4 +508,26 @@ proc setPinMessage*(messageId: string, chatId: string, pinned: bool) =
"message_id": messageId,
"pinned": pinned,
"chat_id": chatId
}])
}])
proc rpcActivityCenterNotifications*(cursorVal: JsonNode, limit: int, success: var bool): string =
success = true
try:
result = callPrivateRPC("activityCenterNotifications".prefix, %* [cursorVal, limit])
except RpcException as e:
success = false
result = e.msg
proc activityCenterNotification*(cursor: string = "") =
var cursorVal: JsonNode
if cursor == "":
cursorVal = newJNull()
else:
cursorVal = newJString(cursor)
var success: bool
let callResult = rpcActivityCenterNotifications(cursorVal, 20, success)
debug "Activity center", callResult
# if success:
# result = parseChatMessagesResponse(chatId, callResult.parseJson()["result"])

2
vendor/status-go vendored

@ -1 +1 @@
Subproject commit 71f66f68064e9897cd17b6bcecba426a91405034
Subproject commit 3cb9db2ac8c4ead31beac8f29b1e9b5d8620bb9e