Fixing rebase.

This commit is contained in:
Andrei Smirnov 2021-09-09 09:56:08 +03:00 committed by Iuri Matias
parent 03022742d8
commit a3368b091e
2 changed files with 17 additions and 2 deletions

View File

@ -15,11 +15,13 @@ type ChatController* = ref object
status*: Status
variant*: QVariant
appService: AppService
uriToOpen: string
proc newController*(status: Status, appService: AppService): ChatController =
proc newController*(status: Status, appService: AppService, uriToOpen: string): ChatController =
result = ChatController()
result.status = status
result.appService = appService
result.uriToOpen = uriToOpen
result.view = newChatsView(status, appService)
result.variant = newQVariant(result.view)
@ -65,6 +67,9 @@ proc init*(self: ChatController) =
self.status.events.on("network:connected") do(e: Args):
self.view.stickers.clearStickerPacks()
self.view.stickers.obtainAvailableStickerPacks()
if self.uriToOpen != "":
self.view.handleProtocolUri(self.uriToOpen)
self.uriToOpen = ""
proc loadInitialMessagesForChannel*(self: ChatController, channelId: string) =
if (channelId.len == 0):

View File

@ -562,4 +562,14 @@ QtObject:
)
self.appService.osNotificationService.showNotification(title, message,
details, useOSNotifications)
details, useOSNotifications)
proc handleProtocolUri*(self: ChatsView, uri: string) =
# for now this only supports links to 1-1 chats, e.g.
# status-im://0x04ecb3636368be823f9c62e2871f8ea5b52eb3fac0132bdcf9e57907a9cb1024d81927fb3ce12fea6d9b9a8f1acb24370df756108170ab0e3454ae93aa601f3c33
# TODO: support other chat types
let pubKey = uri.replace("status-im://", "").replace("/", "")
if pubKey.startsWith("0x"):
self.status.chat.createOneToOneChat(pubKey)
self.setActiveChannel(pubKey)