From a3368b091eae4a3008739cd6f050065219868c83 Mon Sep 17 00:00:00 2001 From: Andrei Smirnov Date: Thu, 9 Sep 2021 09:56:08 +0300 Subject: [PATCH] Fixing rebase. --- src/app/chat/core.nim | 7 ++++++- src/app/chat/view.nim | 12 +++++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/app/chat/core.nim b/src/app/chat/core.nim index 311b65acd9..159452e4ca 100644 --- a/src/app/chat/core.nim +++ b/src/app/chat/core.nim @@ -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): diff --git a/src/app/chat/view.nim b/src/app/chat/view.nim index f587d6957d..27083f44b3 100644 --- a/src/app/chat/view.nim +++ b/src/app/chat/view.nim @@ -562,4 +562,14 @@ QtObject: ) self.appService.osNotificationService.showNotification(title, message, - details, useOSNotifications) \ No newline at end of file + 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) + \ No newline at end of file