Merge pull request #174 from microsoft/danroth27/dotnet-7

Fix Blazor dispatch in Listen Together mode
pull/178/head^2
James Montemagno 2022-11-07 17:03:00 -08:00 committed by GitHub
commit ea56325188
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 8 deletions

View File

@ -24,6 +24,7 @@ public static class MauiProgram
builder.Services.AddHttpClient<PodcastService>(client => builder.Services.AddHttpClient<PodcastService>(client =>
{ {
client.BaseAddress = new Uri(APIUrl); client.BaseAddress = new Uri(APIUrl);
client.DefaultRequestHeaders.Add("api-version", "1.0");
}); });
#if WINDOWS #if WINDOWS

View File

@ -128,21 +128,27 @@
{ {
isRoomHost = true; isRoomHost = true;
roomCode = room.Code; roomCode = room.Code;
await OnJoinRoom.InvokeAsync(room.Code); await InvokeAsync(async () =>
await OnRoomCreated.InvokeAsync(); {
await OnJoinRoom.InvokeAsync(room.Code);
await OnRoomCreated.InvokeAsync();
});
} }
private async void OnRoomUpdated(Room room) private async void OnRoomUpdated(Room room)
{ {
if (currentRoom == null && !isRoomHost) await InvokeAsync(async () =>
{ {
await SetPlayerState(room); if (currentRoom == null && !isRoomHost)
} {
currentRoom = room; await SetPlayerState(room);
await InvokeAsync(StateHasChanged); }
currentRoom = room;
StateHasChanged();
});
} }
private async void OnPlayerStateUpdated(Room room) => await SetPlayerState(room); private async void OnPlayerStateUpdated(Room room) => await InvokeAsync(() => SetPlayerState(room));
private async Task SetPlayerState(Room room) private async Task SetPlayerState(Room room)
{ {