Browse Source

update channel listmodel when channel opened

patch-4
Sander van Grieken 3 years ago
parent
commit
7a26ab259c
  1. 4
      electrum/gui/qml/components/OpenChannel.qml
  2. 12
      electrum/gui/qml/qechannellistmodel.py
  3. 4
      electrum/gui/qml/qechannelopener.py

4
electrum/gui/qml/components/OpenChannel.qml

@ -176,9 +176,11 @@ Pane {
onChannelOpenSuccess: {
var message = 'success!'
if (!has_backup)
message = message = ' (but no backup. TODO: show QR)'
message = message + ' (but no backup. TODO: show QR)'
var dialog = app.messageDialog.createObject(root, { 'text': message })
dialog.open()
channelopener.wallet.channelModel.new_channel(cid)
app.stack.pop()
}
}

12
electrum/gui/qml/qechannellistmodel.py

@ -129,3 +129,15 @@ class QEChannelListModel(QAbstractListModel):
mi = self.createIndex(modelindex, 0)
self.dataChanged.emit(mi, mi, self._ROLE_KEYS)
@pyqtSlot(str)
def new_channel(self, cid):
lnchannels = self.wallet.lnworker.channels
for channel in lnchannels.values():
self._logger.debug(repr(channel))
if cid == channel.channel_id.hex():
item = self.channel_to_model(channel)
self._logger.debug(item)
self.beginInsertRows(QModelIndex(), 0, 0)
self.channels.insert(0,item)
self.endInsertRows()

4
electrum/gui/qml/qechannelopener.py

@ -25,7 +25,7 @@ class QEChannelOpener(QObject):
validationError = pyqtSignal([str,str], arguments=['code','message'])
conflictingBackup = pyqtSignal([str], arguments=['message'])
channelOpenError = pyqtSignal([str], arguments=['message'])
channelOpenSuccess = pyqtSignal([bool], arguments=['has_backup'])
channelOpenSuccess = pyqtSignal([str,bool], arguments=['cid','has_backup'])
dataChanged = pyqtSignal() # generic notify signal
@ -160,7 +160,7 @@ class QEChannelOpener(QObject):
self.channelOpenError.emit(_('Problem opening channel: ') + '\n' + repr(e))
return
self.channelOpenSuccess.emit(chan.has_onchain_backup())
self.channelOpenSuccess.emit(chan.channel_id.hex(), chan.has_onchain_backup())
# TODO: it would be nice to show this before broadcasting
#if chan.has_onchain_backup():

Loading…
Cancel
Save