diff options
author | uvok | 2025-08-01 19:51:29 +0200 |
---|---|---|
committer | uvok | 2025-08-01 19:51:29 +0200 |
commit | c4d29740d29613ae91afc39aedd6b362f2ef7ce8 (patch) | |
tree | ff10866f49b07a7fa0dc4196bcd547910957fa0f | |
parent | 20b327cdd003d087cfeee4c4a89bb6034b0406f3 (diff) |
msvm: Fix motive select keep busy on error
use try-finally.
-rw-r--r-- | lib/view_model/badge_motive_view_model.dart | 36 |
1 files changed, 22 insertions, 14 deletions
diff --git a/lib/view_model/badge_motive_view_model.dart b/lib/view_model/badge_motive_view_model.dart index 87060f8..28acf42 100644 --- a/lib/view_model/badge_motive_view_model.dart +++ b/lib/view_model/badge_motive_view_model.dart @@ -37,22 +37,28 @@ class BadgeMotiveViewModel extends ChangeNotifier { _busy = true; notifyListeners(); - _motives = await _motivSelect.getMotives(); - _busy = false; - notifyListeners(); + try { + _motives = await _motivSelect.getMotives(); + } finally { + _busy = false; + notifyListeners(); + } } Future<void> setMotive(BadgeMotive motive) async { if (_busy) return; - _busy = true; notifyListeners(); - logger.t(">Set motive to ${motive.id}"); - await _motivSelect.setCurrentMotive(motive); - logger.t("<Set motive to ${motive.id}"); - _busy = false; - currentMotive = motive; - notifyListeners(); + + try { + logger.t(">Set motive to ${motive.id}"); + await _motivSelect.setCurrentMotive(motive); + logger.t("<Set motive to ${motive.id}"); + currentMotive = motive; + } finally { + _busy = false; + notifyListeners(); + } } Future<void> getCurrentMotive() async { @@ -60,9 +66,11 @@ class BadgeMotiveViewModel extends ChangeNotifier { _busy = true; notifyListeners(); - currentMotive = await _motivSelect.getCurrentMotive(); - - _busy = false; - notifyListeners(); + try { + currentMotive = await _motivSelect.getCurrentMotive(); + } finally { + _busy = false; + notifyListeners(); + } } } |