qml: defer intent handling at startup, otherwise it gets lost as the app is not handling the signal yet.
Also defer intent handling until a wallet is opened.
This commit is contained in:
@@ -14,6 +14,7 @@ Item {
|
|||||||
property string title: Daemon.currentWallet ? Daemon.currentWallet.name : ''
|
property string title: Daemon.currentWallet ? Daemon.currentWallet.name : ''
|
||||||
|
|
||||||
property var _sendDialog
|
property var _sendDialog
|
||||||
|
property string _intentUri
|
||||||
|
|
||||||
function openInvoice(key) {
|
function openInvoice(key) {
|
||||||
var dialog = invoiceDialog.createObject(app, { invoice: invoiceParser, invoice_key: key })
|
var dialog = invoiceDialog.createObject(app, { invoice: invoiceParser, invoice_key: key })
|
||||||
@@ -229,10 +230,24 @@ Item {
|
|||||||
Connections {
|
Connections {
|
||||||
target: AppController
|
target: AppController
|
||||||
function onUriReceived(uri) {
|
function onUriReceived(uri) {
|
||||||
|
console.log('uri received: ' + uri)
|
||||||
|
if (!Daemon.currentWallet) {
|
||||||
|
console.log('No wallet open, deferring')
|
||||||
|
_intentUri = uri
|
||||||
|
return
|
||||||
|
}
|
||||||
invoiceParser.recipient = uri
|
invoiceParser.recipient = uri
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Connections {
|
||||||
|
target: Daemon
|
||||||
|
function onWalletLoaded() {
|
||||||
|
if (_intentUri)
|
||||||
|
invoiceParser.recipient = _intentUri
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Component {
|
Component {
|
||||||
id: invoiceDialog
|
id: invoiceDialog
|
||||||
InvoiceDialog {
|
InvoiceDialog {
|
||||||
|
|||||||
@@ -56,8 +56,6 @@ class QEAppController(BaseCrashReporter, QObject):
|
|||||||
sendingBugreportSuccess = pyqtSignal(str)
|
sendingBugreportSuccess = pyqtSignal(str)
|
||||||
sendingBugreportFailure = pyqtSignal(str)
|
sendingBugreportFailure = pyqtSignal(str)
|
||||||
|
|
||||||
_crash_user_text = ''
|
|
||||||
|
|
||||||
def __init__(self, qedaemon, plugins):
|
def __init__(self, qedaemon, plugins):
|
||||||
BaseCrashReporter.__init__(self, None, None, None)
|
BaseCrashReporter.__init__(self, None, None, None)
|
||||||
QObject.__init__(self)
|
QObject.__init__(self)
|
||||||
@@ -65,6 +63,10 @@ class QEAppController(BaseCrashReporter, QObject):
|
|||||||
self._qedaemon = qedaemon
|
self._qedaemon = qedaemon
|
||||||
self._plugins = plugins
|
self._plugins = plugins
|
||||||
|
|
||||||
|
self._crash_user_text = ''
|
||||||
|
self._app_started = False
|
||||||
|
self._intent = ''
|
||||||
|
|
||||||
# set up notification queue and notification_timer
|
# set up notification queue and notification_timer
|
||||||
self.user_notification_queue = queue.Queue()
|
self.user_notification_queue = queue.Queue()
|
||||||
self.user_notification_last_time = 0
|
self.user_notification_last_time = 0
|
||||||
@@ -142,15 +144,23 @@ class QEAppController(BaseCrashReporter, QObject):
|
|||||||
self.logger.error(f'unable to bind intent: {repr(e)}')
|
self.logger.error(f'unable to bind intent: {repr(e)}')
|
||||||
|
|
||||||
def on_new_intent(self, intent):
|
def on_new_intent(self, intent):
|
||||||
|
if not self._app_started:
|
||||||
|
self._intent = intent
|
||||||
|
return
|
||||||
|
|
||||||
data = str(intent.getDataString())
|
data = str(intent.getDataString())
|
||||||
|
self.logger.debug(f'received intent: {repr(data)}')
|
||||||
scheme = str(intent.getScheme()).lower()
|
scheme = str(intent.getScheme()).lower()
|
||||||
if scheme == BITCOIN_BIP21_URI_SCHEME or scheme == LIGHTNING_URI_SCHEME:
|
if scheme == BITCOIN_BIP21_URI_SCHEME or scheme == LIGHTNING_URI_SCHEME:
|
||||||
self.uriReceived.emit(data)
|
self.uriReceived.emit(data)
|
||||||
|
|
||||||
|
def startupFinished(self):
|
||||||
|
self._app_started = True
|
||||||
|
if self._intent:
|
||||||
|
self.on_new_intent(self._intent)
|
||||||
|
|
||||||
@pyqtSlot(str, str)
|
@pyqtSlot(str, str)
|
||||||
def doShare(self, data, title):
|
def doShare(self, data, title):
|
||||||
#if platform != 'android':
|
|
||||||
#return
|
|
||||||
try:
|
try:
|
||||||
from jnius import autoclass, cast
|
from jnius import autoclass, cast
|
||||||
except ImportError:
|
except ImportError:
|
||||||
@@ -352,6 +362,7 @@ class ElectrumQmlApplication(QGuiApplication):
|
|||||||
if object is None:
|
if object is None:
|
||||||
self._valid = False
|
self._valid = False
|
||||||
self.engine.objectCreated.disconnect(self.objectCreated)
|
self.engine.objectCreated.disconnect(self.objectCreated)
|
||||||
|
self.appController.startupFinished()
|
||||||
|
|
||||||
def message_handler(self, line, funct, file):
|
def message_handler(self, line, funct, file):
|
||||||
# filter out common harmless messages
|
# filter out common harmless messages
|
||||||
|
|||||||
Reference in New Issue
Block a user