fix: alot

This commit is contained in:
2026-10-19 21:41:34 +02:00
parent 30dd74af90
commit b0074aeb3f
40 changed files with 1979 additions and 405 deletions
@@ -37,6 +37,15 @@ class BarScreenViewModel extends ChangeNotifier {
BarTab? get selectedTab =>
_tabs.firstWhereOrNull((tab) => tab.id == _selectedTabId);
bool hasOpenTabNamed(String name, {String? exceptTabId}) {
final normalized = name.trim().toLowerCase();
return _tabs.any(
(tab) =>
tab.id != exceptTabId &&
tab.customerName.trim().toLowerCase() == normalized,
);
}
void ensureLoaded() {
if (_subscription != null) return;
+8 -1
View File
@@ -24,6 +24,11 @@ class RemoteSyncViewModel extends ChangeNotifier {
bool _isConfigured = false;
bool get isConfigured => _isConfigured;
bool _wasRevoked = false;
/// The server rejected this device's token; it needs to be linked again.
bool get wasRevoked => _wasRevoked;
DateTime? _lastSyncAt;
DateTime? get lastSyncAt => _lastSyncAt;
@@ -54,6 +59,7 @@ class RemoteSyncViewModel extends ChangeNotifier {
/// Called once registration stored new credentials.
Future<void> activate() async {
await _refreshStatus();
if (_isConfigured) _wasRevoked = false;
notifyListeners();
if (!_isConfigured) return;
@@ -90,6 +96,7 @@ class RemoteSyncViewModel extends ChangeNotifier {
syncService.stopPeriodicSync();
await syncService.clearCredentials();
_isConfigured = false;
_wasRevoked = false;
_venueId = null;
_lastSyncAt = null;
_lastError = null;
@@ -105,8 +112,8 @@ class RemoteSyncViewModel extends ChangeNotifier {
case RemoteSyncEventType.syncFailed:
_lastError = event.message;
case RemoteSyncEventType.unauthorized:
// The router sends the device back to registration.
_isConfigured = false;
_wasRevoked = true;
case RemoteSyncEventType.tabClosedRemotely:
case RemoteSyncEventType.conflict:
break;