From 4d04d12a39e384597838121f1916d0039dfa681b Mon Sep 17 00:00:00 2001 From: Marcel Baumgartner Date: Wed, 23 Aug 2023 12:35:30 +0200 Subject: [PATCH] Removed old js calls --- Moonlight/Shared/Layouts/MainLayout.razor | 45 ------------- Moonlight/Shared/Layouts/NotFoundLayout.razor | 1 - Moonlight/Shared/Layouts/ThemeInit.razor | 67 ------------------- 3 files changed, 113 deletions(-) delete mode 100644 Moonlight/Shared/Layouts/ThemeInit.razor diff --git a/Moonlight/Shared/Layouts/MainLayout.razor b/Moonlight/Shared/Layouts/MainLayout.razor index 0cf6370b..0a75b787 100644 --- a/Moonlight/Shared/Layouts/MainLayout.razor +++ b/Moonlight/Shared/Layouts/MainLayout.razor @@ -8,7 +8,6 @@ @using Moonlight.App.Services.Sessions @using Moonlight.App.Events -@layout ThemeInit @implements IDisposable @inherits LayoutComponentBase @@ -162,18 +161,6 @@ UserProcessed = true; await InvokeAsync(StateHasChanged); - try - { - await JsRuntime.InvokeVoidAsync("document.body.removeAttribute", "data-kt-app-reset-transition"); - await JsRuntime.InvokeVoidAsync("document.body.removeAttribute", "data-kt-app-page-loading"); - await JsRuntime.InvokeVoidAsync("KTMenu.createInstances"); - await JsRuntime.InvokeVoidAsync("KTDrawer.createInstances"); - } - catch (Exception) - { - /* ignore errors to make sure that the session call is executed */ - } - await SessionClientService.Start(); NavigationManager.LocationChanged += async (_, _) => @@ -198,11 +185,6 @@ await KeyListenerService.Initialize(); - RunDelayedMenu(0); - RunDelayedMenu(1); - RunDelayedMenu(3); - RunDelayedMenu(5); - if (ConfigService.Get().Moonlight.EnableLatencyCheck) { await JsRuntime.InvokeVoidAsync("moonlight.loading.checkConnection", @@ -228,31 +210,4 @@ await Event.Off($"supportChat.{IdentityService.User.Id}.message", this); } } - - private void AddBodyAttribute(string attribute, string value) - { - JsRuntime.InvokeVoidAsync("document.body.setAttribute", attribute, value); - } - - private void AddBodyClass(string className) - { - JsRuntime.InvokeVoidAsync("document.body.classList.add", className); - } - - private void RunDelayedMenu(int seconds) - { - Task.Run(async () => - { - try - { - await Task.Delay(TimeSpan.FromSeconds(seconds)); - await JsRuntime.InvokeVoidAsync("KTMenu.initHandlers"); - } - catch (Exception e) - { - //Logger.Warn("Delayed menu error"); - //Logger.Warn(e); - } - }); - } } \ No newline at end of file diff --git a/Moonlight/Shared/Layouts/NotFoundLayout.razor b/Moonlight/Shared/Layouts/NotFoundLayout.razor index 479866a0..08eb7df1 100644 --- a/Moonlight/Shared/Layouts/NotFoundLayout.razor +++ b/Moonlight/Shared/Layouts/NotFoundLayout.razor @@ -3,7 +3,6 @@ @using Moonlight.App.Extensions @using Moonlight.App.Services.Sessions -@layout ThemeInit @implements IDisposable @inherits LayoutComponentBase diff --git a/Moonlight/Shared/Layouts/ThemeInit.razor b/Moonlight/Shared/Layouts/ThemeInit.razor deleted file mode 100644 index 05ec097a..00000000 --- a/Moonlight/Shared/Layouts/ThemeInit.razor +++ /dev/null @@ -1,67 +0,0 @@ -@using Moonlight.App.Extensions -@inherits LayoutComponentBase -@inject IJSRuntime JS -@inject NavigationManager NavigationManager - -@Body - - - -@code -{ - protected override void OnAfterRender(bool firstRender) - { - JS.InvokeVoidSafe("KTThemeMode.init"); - JS.InvokeVoidSafe("emptyBody"); - - if (firstRender) - { - JS.InvokeVoidSafe("scrollTo", 0, 0); - JS.InvokeVoidSafe("KTDialer.init"); - JS.InvokeVoidSafe("KTDrawer.init"); - JS.InvokeVoidSafe("KTMenu.init"); - JS.InvokeVoidSafe("KTImageInput.init"); - JS.InvokeVoidSafe("KTPasswordMeter.init"); - JS.InvokeVoidSafe("KTScroll.init"); - JS.InvokeVoidSafe("KTScrolltop.init"); - JS.InvokeVoidSafe("KTSticky.init"); - JS.InvokeVoidSafe("KTSwapper.init"); - JS.InvokeVoidSafe("KTToggle.init"); - JS.InvokeVoidSafe("KTMenu.updateByLinkAttribute", $"/{NavigationManager.ToBaseRelativePath(NavigationManager.Uri)}"); - } - - JS.InvokeVoidAsync("KTLayoutSearch.init"); - JS.InvokeVoidAsync("KTAppSidebar.init"); - } - - - protected override void OnInitialized() - { - NavigationManager.LocationChanged += OnLocationChanged; - } - - private async void OnLocationChanged(object sender, LocationChangedEventArgs args) - { - await JS.InvokeVoidSafeAsync("scrollTo", 0, 0); - await JS.InvokeVoidSafeAsync("KTDrawer.createInstances"); - await JS.InvokeVoidSafeAsync("KTMenu.createInstances"); - await JS.InvokeVoidSafeAsync("KTImageInput.createInstances"); - await JS.InvokeVoidSafeAsync("KTPasswordMeter.createInstances"); - await JS.InvokeVoidSafeAsync("KTScroll.createInstances"); - await JS.InvokeVoidSafeAsync("KTScrolltop.createInstances"); - await JS.InvokeVoidSafeAsync("KTSticky.createInstances"); - await JS.InvokeVoidSafeAsync("KTSwapper.createInstances"); - await JS.InvokeVoidSafeAsync("KTToggle.createInstances"); - await JS.InvokeVoidSafeAsync("KTMenu.updateByLinkAttribute", $"/{NavigationManager.ToBaseRelativePath(args.Location)}"); - await JS.InvokeVoidSafeAsync("KTAppSidebar.init"); - } - - public void Dispose() - { - NavigationManager.LocationChanged -= OnLocationChanged; - } -} \ No newline at end of file