Skip to content

Commit

Permalink
save notes whenever modified, using 10s rate limiter. fixes #8951
Browse files Browse the repository at this point in the history
  • Loading branch information
ecdsa committed Mar 27, 2024
1 parent 88843f2 commit 17599de
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion electrum/gui/qt/main_window.py
Expand Up @@ -74,6 +74,7 @@
from electrum.lnaddr import lndecode
from electrum.submarine_swaps import SwapServerError

from .rate_limiter import rate_limited
from .exception_window import Exception_Hook
from .amountedit import BTCAmountEdit
from .qrcodewidget import QRDialog
Expand Down Expand Up @@ -1573,8 +1574,17 @@ def create_notes_tab(self):
notes_tab.setFont(QtGui.QFont(MONOSPACE_FONT, 10, QtGui.QFont.Normal))
notes_tab.setPlainText(self.wallet.db.get('notes_text', ''))
notes_tab.is_shown_cv = self.config.cv.GUI_QT_SHOW_TAB_NOTES
notes_tab.textChanged.connect(self.maybe_save_notes_text)
return notes_tab

@rate_limited(10, ts_after=True)
def maybe_save_notes_text(self):
self.save_notes_text()

def save_notes_text(self):
self.logger.info('saving notes')
self.wallet.db.put('notes_text', self.notes_tab.toPlainText())

def update_console(self):
console = self.console
console.history = self.wallet.db.get_stored_item("qt-console-history", [])
Expand Down Expand Up @@ -2521,7 +2531,7 @@ def clean_up(self):
fut.cancel()
self.unregister_callbacks()
self.config.GUI_QT_WINDOW_IS_MAXIMIZED = self.isMaximized()
self.wallet.db.put('notes_text', self.notes_tab.toPlainText())
self.save_notes_text()
if not self.isMaximized():
g = self.geometry()
self.wallet.db.put("winpos-qt", [g.left(),g.top(),
Expand Down

0 comments on commit 17599de

Please sign in to comment.