Skip to content

Commit 5bd4f1a

Browse files
committed
Move session nav back to page
1 parent 5fcd4bc commit 5bd4f1a

4 files changed

Lines changed: 13 additions & 12 deletions

File tree

PocketDDD.BlazorClient/PocketDDD.BlazorClient/Features/Home/Components/EventData.razor

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
@using PocketDDD.BlazorClient.Features.Session.Store;
44
@inherits FluxorComponent
55

6+
@inject NavigationManager NavigationManager
67
@inject IState<HomeState> State
78
@inject IDispatcher Dispatcher
89

@@ -23,8 +24,7 @@
2324
}
2425
@foreach(var sessionItem in timeSlot.Sessions.Select((session, index) => (session, index)))
2526
{
26-
<MudListItem
27-
OnClick="() => ViewSession(sessionItem.session.Id)">
27+
<MudListItem OnClick="() => HandleViewSession(sessionItem.session.Id)">
2828
<MudPaper Class="pa-4">
2929
<MudText Typo="Typo.subtitle1">
3030
@WhenBookmarkedShowIcon(sessionItem.session)
@@ -52,5 +52,5 @@
5252
}
5353

5454
@code {
55-
void ViewSession(int sessionId) => Dispatcher.Dispatch(new ViewSessionAction(sessionId));
55+
void HandleViewSession(int sessionId) => NavigationManager.NavigateTo($"session/{sessionId}");
5656
}

PocketDDD.BlazorClient/PocketDDD.BlazorClient/Features/Session/Components/Session.razor

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,19 @@
4848

4949
protected override void OnInitialized()
5050
{
51-
if (State.Value.Session?.Id != Id)
52-
Dispatcher.Dispatch(new ViewSessionAction(Id));
53-
5451
SubscribeToAction<NavigateBackAction>(_ => HandleNavigateHome());
5552
SubscribeToAction<ViewFeedbackAction>(_ => HandleShowSessionFeedback());
5653

5754
base.OnInitialized();
5855
}
5956

57+
protected override void OnParametersSet()
58+
{
59+
Dispatcher.Dispatch(new FetchSessionAction(Id));
60+
61+
base.OnParametersSet();
62+
}
63+
6064
void HandleNavigateHome() => Navigation.NavigateTo("/", false, true);
6165

6266
void HandleToggleSessionBookmarked()

PocketDDD.BlazorClient/PocketDDD.BlazorClient/Features/Session/Store/SessionActions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace PocketDDD.BlazorClient.Features.Session.Store;
44

5-
public record ViewSessionAction(int SessionId);
5+
public record FetchSessionAction(int SessionId);
66
public record SetSessionAction(
77
PocketDDD.Shared.API.ResponseDTOs.SessionDTO Session,
88
PocketDDD.Shared.API.ResponseDTOs.TrackDTO Track,

PocketDDD.BlazorClient/PocketDDD.BlazorClient/Features/Session/Store/SessionEffects.cs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,16 @@ public class SessionEffects
1111
private readonly IState<SessionState> _state;
1212
private readonly LocalStorageContext _localStorage;
1313
private readonly IPocketDDDApiService _pocketDDDAPI;
14-
private readonly NavigationManager _navigation;
1514

16-
public SessionEffects(IState<SessionState> state, LocalStorageContext localStorage, IPocketDDDApiService pocketDDDAPI, NavigationManager navigation)
15+
public SessionEffects(IState<SessionState> state, LocalStorageContext localStorage, IPocketDDDApiService pocketDDDAPI)
1716
{
1817
_state = state;
1918
_localStorage = localStorage;
2019
_pocketDDDAPI = pocketDDDAPI;
21-
_navigation = navigation;
2220
}
2321

2422
[EffectMethod]
25-
public async Task OnViewSession(ViewSessionAction action, IDispatcher dispatcher)
23+
public async Task OnFetchSessionAction(FetchSessionAction action, IDispatcher dispatcher)
2624
{
2725
var eventData = await _localStorage.EventData.GetAsync();
2826
if (eventData is null)
@@ -39,7 +37,6 @@ public async Task OnViewSession(ViewSessionAction action, IDispatcher dispatcher
3937
dispatcher.Dispatch(new SetHeaderBarTitleAction(title));
4038
dispatcher.Dispatch(new SetBackButtonVisabilityAction(true));
4139
dispatcher.Dispatch(new SetSessionAction(session, track, timeSlot, isBookmarked));
42-
_navigation.NavigateTo($"session/{action.SessionId}");
4340
}
4441

4542
[EffectMethod]

0 commit comments

Comments
 (0)