From 383f7b633471dedf515907cb8a8752bc5885ae64 Mon Sep 17 00:00:00 2001 From: TheArcaneBrony Date: Thu, 4 May 2023 20:34:16 +0200 Subject: Add room manager, profile caching --- .../Pages/PolicyList/PolicyListRoomList.razor | 40 +--------------------- 1 file changed, 1 insertion(+), 39 deletions(-) (limited to 'MatrixRoomUtils.Web/Pages/PolicyList/PolicyListRoomList.razor') diff --git a/MatrixRoomUtils.Web/Pages/PolicyList/PolicyListRoomList.razor b/MatrixRoomUtils.Web/Pages/PolicyList/PolicyListRoomList.razor index 5656af9..e9d1be4 100644 --- a/MatrixRoomUtils.Web/Pages/PolicyList/PolicyListRoomList.razor +++ b/MatrixRoomUtils.Web/Pages/PolicyList/PolicyListRoomList.razor @@ -57,7 +57,7 @@ else totalRoomCount = xxxrooms.Count; StateHasChanged(); - var xxxsemaphore = new SemaphoreSlim(256); + var xxxsemaphore = new SemaphoreSlim(1000); var xxxtasks = new List>(); foreach (var room in xxxrooms) { @@ -68,44 +68,6 @@ else Console.WriteLine($"Detected policy lists: {PolicyRoomList.ToJson()}"); return; - /* - using HttpClient wc = new(); - wc.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", LocalStorageWrapper.AccessToken); - - - - //get room list - //temporary hack until rooms get enumerated... - string[] rooms = { "!fTjMjIzNKEsFlUIiru:neko.dev" }; - var _rooms = await wc.GetAsync($"{LocalStorageWrapper.CurrentHomeserver}/_matrix/client/v3/joined_rooms"); - Console.WriteLine($"Got {_rooms.StatusCode}..."); - if (!_rooms.IsSuccessStatusCode) - { - Console.WriteLine($"Failed to get rooms: {await _rooms.Content.ReadAsStringAsync()}"); - return; - } - var _rooms_o = await _rooms.Content.ReadFromJsonAsync(); - if (_rooms_o.TryGetProperty("joined_rooms", out JsonElement _rooms_j)) - { - rooms = _rooms_j.EnumerateArray().Select(x => x.GetString()).ToArray(); - } - - totalRoomCount = rooms.Length; - StateHasChanged(); - - var semaphore = new SemaphoreSlim(256); - var tasks = new List>(); - foreach (string room in rooms) - { - tasks.Add(GetPolicyRoomInfo(room, semaphore)); - } - var results = await Task.WhenAll(tasks); - PolicyRoomList.AddRange(results.Where(x => x != null).Select(x => x.Value)); - - - //print to console - Console.WriteLine($"Detected policy lists: {PolicyRoomList.ToJson()}"); - */ } private async Task GetPolicyRoomInfo(string room, SemaphoreSlim semaphore) -- cgit 1.4.1