Skip to content

Commit d4e1892

Browse files
committed
Logout
Fix logout when no service worker will be used
1 parent 9237ca9 commit d4e1892

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

DexieNETCloudSample/Dexie/Services/DexieCloudService.State.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,20 +89,22 @@ await DB.Transaction(async t =>
8989
if (NotificationsState.Value is NotificationState.Subscribed)
9090
{
9191
await UnsubscribePush();
92+
await Sync(new SyncOptions());
9293
}
9394
return Observable.Return(Unit.Default);
9495
});
9596

9697
var stopObservable = Observable
9798
.FromAsync(async _ =>
9899
{
99-
if (await DB.NumUnsyncedChanges() == 0 && SyncState.Value.ValidPhase())
100+
var unsyncedChanges = await DB.NumUnsyncedChanges();
101+
if (unsyncedChanges == 0 && SyncState.Value.ValidPhase())
100102
{
101103
await DB.Logout();
102104
}
103105
else
104106
{
105-
throw new InvalidOperationException($"Can not logout: {SyncState.Value?.Phase}");
107+
throw new InvalidOperationException($"Can not logout: {SyncState.Value?.Phase} - {unsyncedChanges} unsynced changes");
106108
}
107109

108110
return Observable.Return(Unit.Default);

0 commit comments

Comments
 (0)