Skip to content

Commit da31a8d

Browse files
committed
Undo sample changes
1 parent fbd0c10 commit da31a8d

File tree

7 files changed

+11
-65
lines changed

7 files changed

+11
-65
lines changed

src/Components/Samples/BlazorUnitedApp/App.razor

Lines changed: 2 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -14,33 +14,7 @@
1414
<HeadOutlet />
1515
</head>
1616
<body>
17-
<Routes @rendermode="InteractiveServer" />
18-
<script src="@Assets["_framework/blazor.web.js"]" autostart="false"></script>
19-
<script>
20-
Blazor.start();
21-
// Blazor.start({
22-
// circuit: {
23-
// reconnectionHandler: {
24-
// onConnectionDown: () => (),
25-
// onConnectionUp: () => {
26-
// // revertState();
27-
// }
28-
// },
29-
// detailedErrors: true
30-
// }
31-
// });
32-
33-
function disconnect() {
34-
console.log("Disconnecting")
35-
Blazor._internal.forceCloseConnection();
36-
document.getElementById("reconnect-button").style.visibility = "visible";
37-
document.getElementById("close-connection").style.visibility = "hidden";
38-
}
39-
function revertState() {
40-
console.log("Restoring connection")
41-
document.getElementById("reconnect-button").style.visibility = "hidden";
42-
document.getElementById("close-connection").style.visibility = "visible";
43-
}
44-
</script>
17+
<Routes />
18+
<script src="@Assets["_framework/blazor.web.js"]"></script>
4519
</body>
4620
</html>
Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the MIT license.
33

4-
using System.Diagnostics;
5-
64
namespace BlazorUnitedApp.Data;
75

8-
[DebuggerDisplay($"{{{nameof(GetDebuggerDisplay)}(),nq}}")]
96
public class WeatherForecast
107
{
118
public DateOnly Date { get; set; }
@@ -15,7 +12,4 @@ public class WeatherForecast
1512
public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
1613

1714
public string? Summary { get; set; }
18-
19-
private string GetDebuggerDisplay() =>
20-
$"{Date:yyyy-MM-dd}: {TemperatureC}°C ({TemperatureF}°F) - {Summary ?? "No summary"}";
2115
}

src/Components/Samples/BlazorUnitedApp/Data/WeatherForecastService.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,13 @@ public class WeatherForecastService
1010
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
1111
};
1212

13-
public async Task<WeatherForecast[]> GetForecastAsync(DateOnly startDate)
13+
public Task<WeatherForecast[]> GetForecastAsync(DateOnly startDate)
1414
{
15-
await Task.Delay(1000);
16-
return [.. Enumerable.Range(1, 5).Select(index => new WeatherForecast
15+
return Task.FromResult(Enumerable.Range(1, 5).Select(index => new WeatherForecast
1716
{
1817
Date = startDate.AddDays(index),
1918
TemperatureC = Random.Shared.Next(-20, 55),
2019
Summary = Summaries[Random.Shared.Next(Summaries.Length)]
21-
})];
20+
}).ToArray());
2221
}
2322
}

src/Components/Samples/BlazorUnitedApp/Pages/FetchData.razor

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,9 @@
66

77
<h1>Weather forecast</h1>
88

9-
@_guid
10-
119
<p>This component demonstrates fetching data from a service.</p>
1210

13-
@if (Forecasts == null)
11+
@if (forecasts == null)
1412
{
1513
<p><em>Loading...</em></p>
1614
}
@@ -26,7 +24,7 @@ else
2624
</tr>
2725
</thead>
2826
<tbody>
29-
@foreach (var forecast in Forecasts)
27+
@foreach (var forecast in forecasts)
3028
{
3129
<tr>
3230
<td>@forecast.Date.ToShortDateString()</td>
@@ -40,14 +38,10 @@ else
4038
}
4139

4240
@code {
43-
44-
[SupplyParameterFromPersistentComponentState] public WeatherForecast[]? Forecasts { get; set; }
45-
46-
private string _guid;
41+
private WeatherForecast[]? forecasts;
4742

4843
protected override async Task OnInitializedAsync()
4944
{
50-
_guid = Guid.NewGuid().ToString();
51-
Forecasts ??= await ForecastService.GetForecastAsync(DateOnly.FromDateTime(DateTime.Now));
45+
forecasts = await ForecastService.GetForecastAsync(DateOnly.FromDateTime(DateTime.Now));
5246
}
5347
}

src/Components/Samples/BlazorUnitedApp/Program.cs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,7 @@
99
// Add services to the container.
1010
builder.Services.AddRazorComponents()
1111
.AddInteractiveWebAssemblyComponents()
12-
.AddInteractiveServerComponents(o =>
13-
{
14-
o.DisconnectedCircuitMaxRetained = 0;
15-
o.DisconnectedCircuitRetentionPeriod = TimeSpan.FromSeconds(0);
16-
});
12+
.AddInteractiveServerComponents();
1713

1814
builder.Services.AddSingleton<WeatherForecastService>();
1915

src/Components/Samples/BlazorUnitedApp/Properties/launchSettings.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@
2222
"commandName": "Project",
2323
"dotnetRunMessages": true,
2424
"launchBrowser": true,
25-
"launchUrl": "fetchdata",
26-
"applicationUrl": "http://localhost:5265",
25+
"applicationUrl": "https://localhost:7247;http://localhost:5265",
2726
//"inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}",
2827
"environmentVariables": {
2928
"ASPNETCORE_ENVIRONMENT": "Development"

src/Components/Samples/BlazorUnitedApp/Shared/NavMenu.razor

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,6 @@
2929
<span class="bi bi-list-nested" aria-hidden="true"></span> Web assembly
3030
</NavLink>
3131
</div>
32-
<div class="nav-item px-3 mt-3">
33-
<button id="reconnect-button" style="visibility:hidden" onclick="Blazor.reconnect();" class="btn btn-sm btn-outline-success">
34-
<span class="bi bi-arrow-repeat" aria-hidden="true"></span> Reconnect manually
35-
</button>
36-
</div>
37-
<div class="nav-item px-3 mt-2">
38-
<button id="close-connection" onclick="disconnect();" class="btn btn-sm btn-primary">
39-
<span class="bi bi-x-circle" aria-hidden="true"></span> Close Connection
40-
</button>
41-
</div>
4232
</nav>
4333
</div>
4434

0 commit comments

Comments
 (0)