Skip to content

Commit b772d7f

Browse files
authored
Implement alternative wasm caching (#36)
1 parent aecb261 commit b772d7f

File tree

9 files changed

+25
-308
lines changed

9 files changed

+25
-308
lines changed

.build/Build.ps1

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ param (
1515

1616
[switch]$BuildAgent,
1717

18-
[switch]$BuildDesktop
18+
[switch]$BuildDesktop,
19+
20+
[switch]$BuildServer
1921
)
2022

2123
#$InstallerDir = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer"
@@ -153,4 +155,9 @@ if ($BuildDesktop -or $BuildAgent) {
153155
}
154156
}
155157

156-
dotnet publish -p:ExcludeApp_Data=true --runtime linux-x64 --configuration $Configuration -p:Version=$CurrentVersion -p:FileVersion=$CurrentVersion --output $OutputPath --self-contained true "$Root\ControlR.Web.Server\"
158+
if ($BuildServer) {
159+
Write-Host "`n========================================" -ForegroundColor Cyan
160+
Write-Host "Building Server Publish" -ForegroundColor Cyan
161+
Write-Host "========================================" -ForegroundColor Cyan
162+
dotnet publish -p:ExcludeApp_Data=true --runtime linux-x64 --configuration $Configuration -p:Version=$CurrentVersion -p:FileVersion=$CurrentVersion --output $OutputPath --self-contained true "$Root\ControlR.Web.Server\"
163+
}

ControlR.Web.Client/Components/Pages/Settings.razor

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,13 @@
33
@attribute [Authorize]
44

55
@inject ISnackbar Snackbar
6-
@inject IUserSettingsProvider SettingsStore
7-
@inject ITenantSettingsProvider TenantSettingsProvider
6+
@inject IUserSettingsProvider UserSettings
7+
@inject ITenantSettingsProvider TenantSettings
88
@inject IClipboardManager ClipboardManager
99
@inject AuthenticationStateProvider AuthState
1010
@inject IMessenger Messenger
11+
@inject IJsInterop JsInterop
12+
@inject ILogger<Settings> Logger
1113

1214
<PageTitle>Settings</PageTitle>
1315

@@ -149,11 +151,11 @@
149151
}
150152

151153
// Check if tenant has enforced the notify user setting
152-
_tenantNotifySetting = await TenantSettingsProvider.GetNotifyUserOnSessionStart();
154+
_tenantNotifySetting = await TenantSettings.GetNotifyUserOnSessionStart();
153155

154-
_notifyUser = await SettingsStore.GetNotifyUserOnSessionStart();
155-
_userDisplayName = await SettingsStore.GetUserDisplayName();
156-
_themeMode = await SettingsStore.GetThemeMode();
156+
_notifyUser = await UserSettings.GetNotifyUserOnSessionStart();
157+
_userDisplayName = await UserSettings.GetUserDisplayName();
158+
_themeMode = await UserSettings.GetThemeMode();
157159

158160
// If tenant setting is enforced, override the user setting display
159161
if (_tenantNotifySetting.HasValue)
@@ -185,21 +187,21 @@
185187
}
186188

187189
_notifyUser = value;
188-
await SettingsStore.SetNotifyUserOnSessionStart(value);
190+
await UserSettings.SetNotifyUserOnSessionStart(value);
189191
}
190192

191193
private async Task SetThemeMode(ThemeMode value)
192194
{
193195
_themeMode = value;
194-
await SettingsStore.SetThemeMode(value);
196+
await UserSettings.SetThemeMode(value);
195197
await Messenger.Send(new ThemeChangedMessage(value));
196198
Snackbar.Add("Theme updated", Severity.Success);
197199
}
198200

199201
private async Task SetUserDisplayName(string value)
200202
{
201203
_userDisplayName = value;
202-
await SettingsStore.SetUserDisplayName(value);
204+
await UserSettings.SetUserDisplayName(value);
203205
Snackbar.Add("Display name updated", Severity.Success);
204206
}
205207

@@ -219,5 +221,4 @@
219221
? "Username can only contain letters, numbers, underscores, and hyphens."
220222
: null;
221223
}
222-
223224
}

ControlR.Web.Client/Services/JsInterop.cs

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,13 @@ public interface IJsInterop
1111

1212
ValueTask Alert(string message);
1313

14-
ValueTask<bool> ClearWasmCache();
15-
1614
ValueTask<bool> Confirm(string message);
1715
ValueTask<string?> CreateBlobUrl(byte[] imageData, string mimeType);
1816
ValueTask<string> GetClipboardText();
1917

2018
ValueTask<int> GetCursorIndex(ElementReference inputElement);
2119
ValueTask<int> GetCursorIndexById(string inputElementId);
2220
ValueTask<bool> GetSystemDarkMode();
23-
ValueTask<WasmCacheStatus?> GetWasmCacheStatus();
24-
2521
ValueTask InvokeClick(string elementId);
2622
ValueTask<bool> IsTouchScreen();
2723

@@ -65,11 +61,6 @@ public ValueTask Alert(string message)
6561
return jsRuntime.InvokeVoidAsync("invokeAlert", message);
6662
}
6763

68-
public ValueTask<bool> ClearWasmCache()
69-
{
70-
return jsRuntime.InvokeAsync<bool>("clearWasmCache");
71-
}
72-
7364
public ValueTask<bool> Confirm(string message)
7465
{
7566
return jsRuntime.InvokeAsync<bool>("invokeConfirm", message);
@@ -100,11 +91,6 @@ public ValueTask<bool> GetSystemDarkMode()
10091
return jsRuntime.InvokeAsync<bool>("getSystemDarkMode");
10192
}
10293

103-
public ValueTask<WasmCacheStatus?> GetWasmCacheStatus()
104-
{
105-
return jsRuntime.InvokeAsync<WasmCacheStatus?>("getWasmCacheStatus");
106-
}
107-
10894
public ValueTask InvokeClick(string elementId)
10995
{
11096
return jsRuntime.InvokeVoidAsync("invokeClick", elementId);
@@ -185,12 +171,3 @@ public ValueTask ToggleFullscreen(ElementReference? element = null)
185171
return jsRuntime.InvokeVoidAsync("toggleFullscreen", element);
186172
}
187173
}
188-
189-
/// <summary>
190-
/// Represents the status of the WASM cache service worker.
191-
/// </summary>
192-
public sealed class WasmCacheStatus
193-
{
194-
public string CacheName { get; set; } = string.Empty;
195-
public int EntryCount { get; set; }
196-
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export function onRuntimeConfigLoaded(config) {
2+
config.disableNoCacheFetch = true;
3+
}

ControlR.Web.Server/Components/App.razor

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
<meta charset="utf-8" />
66
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
77
<base href="/" />
8-
<script src="wasm-cache-init.js"></script>
98
<ResourcePreloader />
109
<link href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700&display=swap" rel="stylesheet" />
1110
<link rel="stylesheet" href="@Assets["_content/MudBlazor/MudBlazor.min.css"]" />

ControlR.Web.Server/appsettings.Development.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,6 @@
2727
"InMemoryDatabaseName": ""
2828
},
2929
"DeveloperOptions": {
30-
"RenderMode": "Server"
30+
"RenderMode": "Auto"
3131
}
3232
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.15.167.0
1+
0.15.177.0

ControlR.Web.Server/wwwroot/wasm-cache-init.js

Lines changed: 0 additions & 68 deletions
This file was deleted.

0 commit comments

Comments
 (0)