diff options
author | TheArcaneBrony <myrainbowdash949@gmail.com> | 2023-06-28 10:38:45 +0200 |
---|---|---|
committer | TheArcaneBrony <myrainbowdash949@gmail.com> | 2023-06-28 10:38:45 +0200 |
commit | a331eb2f118e0051c6c6744a20d6b0934c4d6d6f (patch) | |
tree | a7798d94a3553106aad40507e2dc04ff9d2f9efd /MatrixRoomUtils.Web/Classes/LocalStorageWrapper.cs | |
parent | Dependency injection stuff (diff) | |
download | MatrixUtils-a331eb2f118e0051c6c6744a20d6b0934c4d6d6f.tar.xz |
Update stuff
Diffstat (limited to 'MatrixRoomUtils.Web/Classes/LocalStorageWrapper.cs')
-rw-r--r-- | MatrixRoomUtils.Web/Classes/LocalStorageWrapper.cs | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/MatrixRoomUtils.Web/Classes/LocalStorageWrapper.cs b/MatrixRoomUtils.Web/Classes/LocalStorageWrapper.cs index 59ec4db..59c1ab6 100644 --- a/MatrixRoomUtils.Web/Classes/LocalStorageWrapper.cs +++ b/MatrixRoomUtils.Web/Classes/LocalStorageWrapper.cs @@ -4,11 +4,11 @@ using MatrixRoomUtils.Core; namespace MatrixRoomUtils.Web.Classes; public class LocalStorageWrapper { - private static readonly SemaphoreSlim _semaphoreSlim = new(1); - public static Settings Settings { get; set; } = new(); + private readonly SemaphoreSlim _semaphoreSlim = new(1); + public Settings Settings { get; set; } = new(); //some basic logic - public static async Task InitialiseRuntimeVariables(ILocalStorageService localStorage) { + public async Task InitialiseRuntimeVariables(ILocalStorageService localStorage) { //RuntimeCache stuff // async Task Save() => await SaveToLocalStorage(localStorage); // async Task SaveObject(string key, object obj) => await localStorage.SetItemAsync(key, obj); @@ -26,7 +26,7 @@ public class LocalStorageWrapper { } } - public static async Task LoadFromLocalStorage(ILocalStorageService localStorage) { + public async Task LoadFromLocalStorage(ILocalStorageService localStorage) { await _semaphoreSlim.WaitAsync(); if (RuntimeCache.WasLoaded) { _semaphoreSlim.Release(); @@ -53,14 +53,14 @@ public class LocalStorageWrapper { _semaphoreSlim.Release(); } - public static async Task SaveToLocalStorage(ILocalStorageService localStorage) { + public async Task SaveToLocalStorage(ILocalStorageService localStorage) { Console.WriteLine("Saving to local storage..."); await localStorage.SetItemAsync("rory.matrixroomutils.settings", Settings); if (RuntimeCache.LoginSessions != null) await localStorage.SetItemAsync("rory.matrixroomutils.login_sessions", RuntimeCache.LoginSessions); if (RuntimeCache.LastUsedToken != null) await localStorage.SetItemAsync("rory.matrixroomutils.last_used_token", RuntimeCache.LastUsedToken); } - public static async Task SaveCacheToLocalStorage(ILocalStorageService localStorage, bool awaitSave = true, bool saveGenericCache = true) { + public async Task SaveCacheToLocalStorage(ILocalStorageService localStorage, bool awaitSave = true, bool saveGenericCache = true) { await localStorage.SetItemAsync("rory.matrixroomutils.homeserver_resolution_cache", RuntimeCache.HomeserverResolutionCache.DistinctBy(x => x.Key) .ToDictionary(x => x.Key, x => x.Value)); |