diff --git a/src/status/chat.nim b/src/status/chat.nim index c303d548d5..7fc4f889bc 100644 --- a/src/status/chat.nim +++ b/src/status/chat.nim @@ -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: diff --git a/src/status/libstatus/chat.nim b/src/status/libstatus/chat.nim index a15a9ce162..a62095f084 100644 --- a/src/status/libstatus/chat.nim +++ b/src/status/libstatus/chat.nim @@ -508,4 +508,26 @@ proc setPinMessage*(messageId: string, chatId: string, pinned: bool) = "message_id": messageId, "pinned": pinned, "chat_id": chatId - }]) \ No newline at end of file + }]) + +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"]) diff --git a/vendor/status-go b/vendor/status-go index 71f66f6806..3cb9db2ac8 160000 --- a/vendor/status-go +++ b/vendor/status-go @@ -1 +1 @@ -Subproject commit 71f66f68064e9897cd17b6bcecba426a91405034 +Subproject commit 3cb9db2ac8c4ead31beac8f29b1e9b5d8620bb9e