feat(@desktop/deep-links): integrated deep links with single-instance IPC

This commit is contained in:
Andrei Smirnov 2021-09-10 11:56:20 +03:00 committed by Iuri Matias
parent 75b08df03d
commit d159c0e61c
5 changed files with 17 additions and 5 deletions

View File

@ -563,7 +563,7 @@ QtObject:
self.appService.osNotificationService.showNotification(title, message, self.appService.osNotificationService.showNotification(title, message,
details, useOSNotifications) details, useOSNotifications)
proc handleProtocolUri*(self: ChatsView, uri: string) = proc handleProtocolUri*(self: ChatsView, uri: string) {.slot.} =
# for now this only supports links to 1-1 chats, e.g. # for now this only supports links to 1-1 chats, e.g.
# status-im://p/0x04ecb3636368be823f9c62e2871f8ea5b52eb3fac0132bdcf9e57907a9cb1024d81927fb3ce12fea6d9b9a8f1acb24370df756108170ab0e3454ae93aa601f3c33 # status-im://p/0x04ecb3636368be823f9c62e2871f8ea5b52eb3fac0132bdcf9e57907a9cb1024d81927fb3ce12fea6d9b9a8f1acb24370df756108170ab0e3454ae93aa601f3c33
# TODO: support other chat types # TODO: support other chat types

View File

@ -1,4 +1,4 @@
import NimQml, chronicles, os, strformat, times, md5 import NimQml, chronicles, os, strformat, times, md5, json
import app/chat/core as chat import app/chat/core as chat
import app/wallet/v1/core as wallet import app/wallet/v1/core as wallet
@ -66,7 +66,10 @@ proc mainProc() =
"/../resources.rcc" "/../resources.rcc"
QResource.registerResource(app.applicationDirPath & resources) QResource.registerResource(app.applicationDirPath & resources)
let singleInstance = newSingleInstance($toMD5(DATADIR)) var eventStr = ""
if OPENURI.len > 0:
eventStr = $(%* { "uri": OPENURI })
let singleInstance = newSingleInstance($toMD5(DATADIR), eventStr)
defer: singleInstance.delete() defer: singleInstance.delete()
if singleInstance.secondInstance(): if singleInstance.secondInstance():
info "Terminating the app as the second instance" info "Terminating the app as the second instance"

View File

@ -131,6 +131,15 @@ StatusWindow {
applicationWindow.raise() applicationWindow.raise()
applicationWindow.requestActivate() applicationWindow.requestActivate()
} }
onEventReceived: {
let event = JSON.parse(eventStr)
if (event.hasOwnProperty("uri")) {
chatsModel.handleProtocolUri(event.uri)
} else {
console.warn("Unknown event received: " + eventStr)
}
}
} }
// The easiest way to get current system theme (is it light or dark) without using // The easiest way to get current system theme (is it light or dark) without using

2
vendor/DOtherSide vendored

@ -1 +1 @@
Subproject commit 966fb752dd29876ac15fb31ab59fb017fba7a9b3 Subproject commit 22d40f37fcfe202b28acfecece045106bab05742

2
vendor/nimqml vendored

@ -1 +1 @@
Subproject commit f2f8f3a9e921e93b7f5d1961600919611b300066 Subproject commit 42b3b1af5bdb254a82998566f147ddb1156a5141