# MainHubLayout

- File ID: file:1ain1yo:mainhublayout-razor
- Path: NexusReader.UI.Shared/Layout/MainHubLayout.razor
- Role: ui-component
- Layer: frontend

## Purpose

Renders the main application hub layout (sidebar + main content) for authenticated users and coordinates initial identity sync and logout behavior.

## Key Details

Uses an _isSyncing flag to avoid concurrent profile-sync attempts. On init, checks authentication state and if unauthenticated attempts a server-side profile sync (cookie-based). Logout calls the identity service and then forces navigation to an account logout form.

## Symbols

- MainHubLayout: Renders the main application hub layout (sidebar + main content) for authenticated users and coordinates initial identity sync and logout behavior.
- OnInitializedAsync(): Component initialization: avoids duplicate syncs, checks authentication state, and attempts to sync profile from server if the user is not authenticated.
- HandleLogout(): Performs logout via the identity service and redirects the browser to a logout form route.

## Dependencies

- No resolved dependencies.

## Calls

- No resolved calls.

## Unresolved References

- dependency-target: NexusReader.Application.Abstractions.Services/IIdentityService.cs
- dependency-target: NexusReader.UI.Shared.Components/Molecules/NexusIcon.razor
- call-target: NexusReader.Application.Abstractions.Services/IIdentityService.cs
- call-target: NexusReader.Application.Abstractions.Services/IIdentityService.cs
- interaction-target: await AuthStateProvider.GetAuthenticationStateAsync() (framework call)
- interaction-target: await IdentityService.GetProfileAsync(); (project service)
- interaction-target: await IdentityService.LogoutAsync(); (project service)
- interaction-target: NavigationManager.NavigateTo("/account/logout-form", true) (framework navigation)

## Coverage

- Symbols: 3
- Executable symbols: 2
- Executable symbols with control flow: 2
- Grounded edges: 3
- Unresolved references: 8
- Control-flow fragments: 2
- Unresolved jumps: 2
- Unsupported constructs: 0
- Control-flow coverage: 100%
- Required diagrams: 2
- Generated diagrams: 4

## Control Flow Fragments

- OnInitializedAsync: 24 nodes, 27 edges, 1 jumps, 0 unsupported constructs
- HandleLogout: 6 nodes, 5 edges, 1 jumps, 0 unsupported constructs

## Diagrams

### MainHubLayout Neighborhood

```mermaid
flowchart LR
    class_vf4020_mainhublayout("MainHubLayout")
    file_1ain1yo_mainhublayout_razor("MainHubLayout")
    method_64smty_handlelogout[["HandleLogout()"]]
    method_p4hxqo_oninitializedasync[["OnInitializedAsync()"]]
```

### MainHubLayout Execution Overview

```mermaid
flowchart TD
    class_vf4020_mainhublayout("MainHubLayout")
    method_64smty_handlelogout[["HandleLogout()"]]
    method_p4hxqo_oninitializedasync[["OnInitializedAsync()"]]
    unresolved_unresolved_15jy0tl_call_target{"Unresolved: LogoutAsync"}
    unresolved_unresolved_17ozmdg_call_target{"Unresolved: GetProfileAsync"}
    unresolved_unresolved_1k8045k_interaction_target{"Unresolved: NavigationManager.NavigateTo(\\"/account/logout-form\\", true) (framework navigation)"}
    unresolved_unresolved_1mo1qcu_interaction_target{"Unresolved: await AuthStateProvider.GetAuthenticationStateAsync() (framework call)"}
    unresolved_unresolved_6dhnk4_interaction_target{"Unresolved: await IdentityService.GetProfileAsync(); (project service)"}
    unresolved_unresolved_n5pbzn_interaction_target{"Unresolved: await IdentityService.LogoutAsync(); (project service)"}
    class_vf4020_mainhublayout -->|contains| method_64smty_handlelogout
    class_vf4020_mainhublayout -->|contains| method_p4hxqo_oninitializedasync
    class_vf4020_mainhublayout -->|unresolved interaction| unresolved_unresolved_1k8045k_interaction_target
    class_vf4020_mainhublayout -->|unresolved interaction| unresolved_unresolved_1mo1qcu_interaction_target
    class_vf4020_mainhublayout -->|unresolved interaction| unresolved_unresolved_6dhnk4_interaction_target
    class_vf4020_mainhublayout -->|unresolved interaction| unresolved_unresolved_n5pbzn_interaction_target
    method_64smty_handlelogout -->|unresolved call| unresolved_unresolved_15jy0tl_call_target
    method_p4hxqo_oninitializedasync -->|unresolved call| unresolved_unresolved_17ozmdg_call_target
```

### OnInitializedAsync() Control Flow

_Warnings: diagram method_p4hxqo_oninitializedasync__fragment_diagram exceeds preferred complexity thresholds (24 nodes, 27 edges)._

```mermaid
---
config:
  flowchart:
    defaultRenderer: "elk"
---
flowchart TD
    method_p4hxqo_oninitializedasync__call_103_GetProfileAsync[["GetProfileAsync"]]
    method_p4hxqo_oninitializedasync__action_101_state_change_101__linear("Mark sync in progress")
    method_p4hxqo_oninitializedasync__action_103_oninitializedasync_await_103_3__await[["Waits for async work"]]
    method_p4hxqo_oninitializedasync__action_96_guard_clause_96__condition{"_isSyncing"}
    method_p4hxqo_oninitializedasync__action_96_guard_clause_96__false("continue")
    method_p4hxqo_oninitializedasync__action_96_guard_clause_96__merge("merge")
    method_p4hxqo_oninitializedasync__action_96_guard_clause_96__true("return")
    method_p4hxqo_oninitializedasync__action_96_oninitializedasync_guard_clause_96_0__condition{"_isSyncing"}
    method_p4hxqo_oninitializedasync__action_96_oninitializedasync_guard_clause_96_0__false("continue")
    method_p4hxqo_oninitializedasync__action_96_oninitializedasync_guard_clause_96_0__merge("merge")
    method_p4hxqo_oninitializedasync__action_96_oninitializedasync_guard_clause_96_0__true("exit")
    method_p4hxqo_oninitializedasync__action_98_oninitializedasync_await_98_1__await[["Waits for async work"]]
    method_p4hxqo_oninitializedasync__action_99_branch_99__condition{"!authState.User.Identity?.IsAuthenticated ?? true"}
    method_p4hxqo_oninitializedasync__action_99_branch_99__false("call IdentityService.GetProfileAsync")
    method_p4hxqo_oninitializedasync__action_99_branch_99__merge("merge")
    method_p4hxqo_oninitializedasync__action_99_branch_99__true("set _isSyncing true")
    method_p4hxqo_oninitializedasync__action_99_oninitializedasync_branch_99_2__condition{"!authState.User.Identity?.IsAuthenticated ?? true"}
    method_p4hxqo_oninitializedasync__action_99_oninitializedasync_branch_99_2__false("false")
    method_p4hxqo_oninitializedasync__action_99_oninitializedasync_branch_99_2__merge("merge")
    method_p4hxqo_oninitializedasync__action_99_oninitializedasync_branch_99_2__true("true")
    method_p4hxqo_oninitializedasync__entry(["OnInitializedAsync entry"])
    method_p4hxqo_oninitializedasync__action_103_external_call_103__linear("Attempt to fetch profile from server")
    method_p4hxqo_oninitializedasync__action_98_external_call_98__linear("Read authentication state")
    method_p4hxqo_oninitializedasync__implicit_return(["return"])
    method_p4hxqo_oninitializedasync__action_101_state_change_101__linear -->|next| method_p4hxqo_oninitializedasync__action_103_oninitializedasync_await_103_3__await
    method_p4hxqo_oninitializedasync__action_103_external_call_103__linear -->|none| method_p4hxqo_oninitializedasync__call_103_GetProfileAsync
    method_p4hxqo_oninitializedasync__action_103_oninitializedasync_await_103_3__await -->|next| method_p4hxqo_oninitializedasync__action_103_external_call_103__linear
    method_p4hxqo_oninitializedasync__action_96_guard_clause_96__condition -->|continue| method_p4hxqo_oninitializedasync__action_96_guard_clause_96__false
    method_p4hxqo_oninitializedasync__action_96_guard_clause_96__condition -->|return| method_p4hxqo_oninitializedasync__action_96_guard_clause_96__true
    method_p4hxqo_oninitializedasync__action_96_guard_clause_96__false -->|next| method_p4hxqo_oninitializedasync__action_96_guard_clause_96__merge
    method_p4hxqo_oninitializedasync__action_96_guard_clause_96__merge -->|next| method_p4hxqo_oninitializedasync__action_96_oninitializedasync_guard_clause_96_0__condition
    method_p4hxqo_oninitializedasync__action_96_guard_clause_96__true -->|next| method_p4hxqo_oninitializedasync__action_96_guard_clause_96__merge
    method_p4hxqo_oninitializedasync__action_96_oninitializedasync_guard_clause_96_0__condition -->|continue| method_p4hxqo_oninitializedasync__action_96_oninitializedasync_guard_clause_96_0__false
    method_p4hxqo_oninitializedasync__action_96_oninitializedasync_guard_clause_96_0__condition -->|exit| method_p4hxqo_oninitializedasync__action_96_oninitializedasync_guard_clause_96_0__true
    method_p4hxqo_oninitializedasync__action_96_oninitializedasync_guard_clause_96_0__false -->|next| method_p4hxqo_oninitializedasync__action_96_oninitializedasync_guard_clause_96_0__merge
    method_p4hxqo_oninitializedasync__action_96_oninitializedasync_guard_clause_96_0__merge -->|next| method_p4hxqo_oninitializedasync__action_98_oninitializedasync_await_98_1__await
    method_p4hxqo_oninitializedasync__action_96_oninitializedasync_guard_clause_96_0__true -->|next| method_p4hxqo_oninitializedasync__action_96_oninitializedasync_guard_clause_96_0__merge
    method_p4hxqo_oninitializedasync__action_98_external_call_98__linear -->|next| method_p4hxqo_oninitializedasync__action_99_branch_99__condition
    method_p4hxqo_oninitializedasync__action_98_oninitializedasync_await_98_1__await -->|next| method_p4hxqo_oninitializedasync__action_98_external_call_98__linear
    method_p4hxqo_oninitializedasync__action_99_branch_99__condition -->|call IdentityService.GetProfileAsync| method_p4hxqo_oninitializedasync__action_99_branch_99__false
    method_p4hxqo_oninitializedasync__action_99_branch_99__condition -->|set _isSyncing true| method_p4hxqo_oninitializedasync__action_99_branch_99__true
    method_p4hxqo_oninitializedasync__action_99_branch_99__false -->|next| method_p4hxqo_oninitializedasync__action_99_branch_99__merge
    method_p4hxqo_oninitializedasync__action_99_branch_99__merge -->|next| method_p4hxqo_oninitializedasync__action_99_oninitializedasync_branch_99_2__condition
    method_p4hxqo_oninitializedasync__action_99_branch_99__true -->|next| method_p4hxqo_oninitializedasync__action_99_branch_99__merge
    method_p4hxqo_oninitializedasync__action_99_oninitializedasync_branch_99_2__condition -->|false| method_p4hxqo_oninitializedasync__action_99_oninitializedasync_branch_99_2__false
    method_p4hxqo_oninitializedasync__action_99_oninitializedasync_branch_99_2__condition -->|true| method_p4hxqo_oninitializedasync__action_99_oninitializedasync_branch_99_2__true
    method_p4hxqo_oninitializedasync__action_99_oninitializedasync_branch_99_2__false -->|next| method_p4hxqo_oninitializedasync__action_99_oninitializedasync_branch_99_2__merge
    method_p4hxqo_oninitializedasync__action_99_oninitializedasync_branch_99_2__merge -->|next| method_p4hxqo_oninitializedasync__action_101_state_change_101__linear
    method_p4hxqo_oninitializedasync__action_99_oninitializedasync_branch_99_2__true -->|next| method_p4hxqo_oninitializedasync__action_99_oninitializedasync_branch_99_2__merge
    method_p4hxqo_oninitializedasync__call_103_GetProfileAsync -->|return| method_p4hxqo_oninitializedasync__implicit_return
    method_p4hxqo_oninitializedasync__entry -->|next| method_p4hxqo_oninitializedasync__action_96_guard_clause_96__condition
```

### HandleLogout() Control Flow

```mermaid
flowchart TD
    method_64smty_handlelogout__call_109_LogoutAsync[["LogoutAsync"]]
    method_64smty_handlelogout__action_109_handlelogout_await_109_0__await[["Waits for async work"]]
    method_64smty_handlelogout__entry(["HandleLogout entry"])
    method_64smty_handlelogout__action_109_external_call_109__linear("Invoke logout on identity service")
    method_64smty_handlelogout__action_110_external_call_110__linear("Navigate to logout page")
    method_64smty_handlelogout__implicit_return(["return"])
    method_64smty_handlelogout__action_109_external_call_109__linear -->|none| method_64smty_handlelogout__call_109_LogoutAsync
    method_64smty_handlelogout__action_109_handlelogout_await_109_0__await -->|next| method_64smty_handlelogout__action_109_external_call_109__linear
    method_64smty_handlelogout__action_110_external_call_110__linear -->|return| method_64smty_handlelogout__implicit_return
    method_64smty_handlelogout__call_109_LogoutAsync -->|next| method_64smty_handlelogout__action_110_external_call_110__linear
    method_64smty_handlelogout__entry -->|next| method_64smty_handlelogout__action_109_handlelogout_await_109_0__await
```

## Diagram Validation

- Status: warn
- Warning: Control-flow extraction left 2 unresolved jumps.
- Warning: control-flow: diagram method_p4hxqo_oninitializedasync__fragment_diagram exceeds preferred complexity thresholds (24 nodes, 27 edges).
