From c4d29740d29613ae91afc39aedd6b362f2ef7ce8 Mon Sep 17 00:00:00 2001 From: uvok Date: Fri, 1 Aug 2025 19:51:29 +0200 Subject: msvm: Fix motive select keep busy on error use try-finally. --- lib/view_model/badge_motive_view_model.dart | 36 ++++++++++++++++++----------- 1 file 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 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}"); + await _motivSelect.setCurrentMotive(motive); + logger.t(" 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(); + } } } -- cgit v1.2.3