diff options
author | TheArcaneBrony <myrainbowdash949@gmail.com> | 2023-05-27 00:39:49 +0200 |
---|---|---|
committer | TheArcaneBrony <myrainbowdash949@gmail.com> | 2023-05-27 00:39:49 +0200 |
commit | a67276252c8bfcd6b6c5344e70debc6d67d917a9 (patch) | |
tree | af2806e9729f1013a5db6fbda80a7ad1cd7126fa /MatrixRoomUtils.Web/Classes/LocalStorageWrapper.cs | |
parent | idk (diff) | |
download | MatrixUtils-a67276252c8bfcd6b6c5344e70debc6d67d917a9.tar.xz |
Been a while since I last committed
Diffstat (limited to 'MatrixRoomUtils.Web/Classes/LocalStorageWrapper.cs')
-rw-r--r-- | MatrixRoomUtils.Web/Classes/LocalStorageWrapper.cs | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/MatrixRoomUtils.Web/Classes/LocalStorageWrapper.cs b/MatrixRoomUtils.Web/Classes/LocalStorageWrapper.cs index 4a00a8a..bd44f7f 100644 --- a/MatrixRoomUtils.Web/Classes/LocalStorageWrapper.cs +++ b/MatrixRoomUtils.Web/Classes/LocalStorageWrapper.cs @@ -5,6 +5,7 @@ namespace MatrixRoomUtils.Web.Classes; public partial class LocalStorageWrapper { + private static SemaphoreSlim _semaphoreSlim = new(1); public static Settings Settings { get; set; } = new(); //some basic logic @@ -15,6 +16,9 @@ public partial class LocalStorageWrapper } public static async Task LoadFromLocalStorage(ILocalStorageService localStorage) { + await _semaphoreSlim.WaitAsync(); + if (RuntimeCache.WasLoaded) return; + RuntimeCache.WasLoaded = true; Settings = await localStorage.GetItemAsync<Settings>("rory.matrixroomutils.settings") ?? new(); //RuntimeCache stuff @@ -43,7 +47,8 @@ public partial class LocalStorageWrapper Console.WriteLine($"Loading generic cache entry {s}"); RuntimeCache.GenericResponseCache[s.Replace("rory.matrixroomutils.generic_cache:", "")] = await localStorage.GetItemAsync<ObjectCache<object>>(s); } - RuntimeCache.WasLoaded = true; + + _semaphoreSlim.Release(); } public static async Task SaveToLocalStorage(ILocalStorageService localStorage) @@ -70,7 +75,7 @@ public partial class LocalStorageWrapper if (key == "rory.matrixroomutils.user_cache") await localStorage.SetItemAsync(key, RuntimeCache.LoginSessions); if (key == "rory.matrixroomutils.last_used_token") await localStorage.SetItemAsync(key, RuntimeCache.LastUsedToken); if (key == "rory.matrixroomutils.homeserver_resolution_cache") await localStorage.SetItemAsync(key, RuntimeCache.HomeserverResolutionCache); - if (key == "rory.matrixroomutils.generic_cache") await localStorage.SetItemAsync(key, RuntimeCache.GenericResponseCache); + //if (key == "rory.matrixroomutils.generic_cache") await localStorage.SetItemAsync(key, RuntimeCache.GenericResponseCache); } } |