public async Task DeleteAllTrackedTimezones() { try { await JSR.StorageUtils.LocalStorageDeleteItem(TrackedTimezonesKey); } catch (Exception) { Logger.LogError("Failed to delete from local storage."); } // Save to firestore var user = await AuthService.GetCurrentUser(); if (user != null) { // Collection string collection = "users"; string docId = user.uid; UserDocument doc = new UserDocument(); FirestoreOperationResult <UserDocument> result = await FirestoreService.UpdateDocument <UserDocument, UserDocument>(collection, docId, doc); Logger.LogInformation($"Doc save result: {result.Success}"); } }
public async Task SaveTrackedTimezones(ISet <string> timezoneIds) { if (timezoneIds == null || timezoneIds.Count == 0) { Logger.LogError("No timezones to save."); return; } // Save to firestore var user = await AuthService.GetCurrentUser(); if (user != null) { // Collection string collection = "users"; string docId = user.uid; UserDocument doc = new UserDocument() { TrackedTimezoneIds = timezoneIds }; FirestoreOperationResult <UserDocument> result = await FirestoreService.UpdateDocument <UserDocument, UserDocument>(collection, docId, doc); Logger.LogInformation($"Doc save result: {result.Success}"); } // Let's save to local storage as well // We will retrieve this if user is not signed in try { await JSR.StorageUtils.LocalStorageSetItem( TrackedTimezonesKey, JsonSerializer.Serialize(timezoneIds)); } catch (Exception) { Logger.LogError("Failed to save to local storage."); } }