@page "/export"
@using MatrixRoomUtils.Web.Classes
@using MatrixRoomUtils.Web.Shared.IndexComponents
@using Blazored.LocalStorage
@using MatrixRoomUtils.Authentication
@using System.Text.Json
@using Microsoft.AspNetCore.Components.Rendering
@inject NavigationManager NavigationManager
@inject ILocalStorageService LocalStorage
@user.LoginResponse.UserId[1..].Split(":")[0]\auth\access_token=@token @user.LoginResponse.UserId[1..].Split(":")[0]\auth\device_id=@user.LoginResponse.DeviceId @user.LoginResponse.UserId[1..].Split(":")[0]\auth\home_server=@(RuntimeCache.HomeserverResolutionCache.ContainsKey(user.LoginResponse.HomeServer) ? RuntimeCache.HomeserverResolutionCache[user.LoginResponse.HomeServer].Result : "loading...") @user.LoginResponse.UserId[1..].Split(":")[0]\auth\user_id=@@@user.LoginResponse.UserId @user.LoginResponse.UserId[1..].Split(":")[0]\user\automatically_share_keys_with_trusted_users=true @user.LoginResponse.UserId[1..].Split(":")[0]\user\muted_tags=global @user.LoginResponse.UserId[1..].Split(":")[0]\user\online_key_backup=true @user.LoginResponse.UserId[1..].Split(":")[0]\user\only_share_keys_with_verified_users=false} } else {
Loading...
@resolvedHomeservers/@totalHomeservers homeservers resolved...
} @code { private bool _isLoaded; private int resolvedHomeservers; private int totalHomeservers; protected override async Task OnInitializedAsync() { await base.OnInitializedAsync(); if (!RuntimeCache.WasLoaded) { await LocalStorageWrapper.LoadFromLocalStorage(LocalStorage); var homeservers = RuntimeCache.LoginSessions.Values.Select(x => x.LoginResponse.HomeServer).Distinct(); totalHomeservers = homeservers.Count(); StateHasChanged(); foreach (var hs in homeservers) { if (LocalStorageWrapper.HomeserverResolutionCache.ContainsKey(hs)) continue; var resolvedHomeserver = await MatrixAuth.ResolveHomeserverFromWellKnown(hs); if (LocalStorageWrapper.HomeserverResolutionCache.ContainsKey(hs)) LocalStorageWrapper.HomeserverResolutionCache.Remove(hs); LocalStorageWrapper.HomeserverResolutionCache.Add(hs, new() { Result = resolvedHomeserver, ResolutionTime = DateTime.Now }); await LocalStorageWrapper.SaveToLocalStorage(LocalStorage); Console.WriteLine("Saved to local storage:"); Console.WriteLine(JsonSerializer.Serialize(LocalStorageWrapper.HomeserverResolutionCache, new JsonSerializerOptions() { WriteIndented = true })); resolvedHomeservers++; StateHasChanged(); } StateHasChanged(); } _isLoaded = true; } }