Skip to content

[6942] Pinia Task 13 - account-team #6952

Open
n-lark wants to merge 8 commits intomainfrom
6942-pinia-task-13-account-team
Open

[6942] Pinia Task 13 - account-team #6952
n-lark wants to merge 8 commits intomainfrom
6942-pinia-task-13-account-team

Conversation

@n-lark
Copy link
Copy Markdown
Contributor

@n-lark n-lark commented Mar 24, 2026

Description

See details & test plan.

Related Issue(s)

Resolves #6942

Checklist

  • I have read the contribution guidelines
  • Suitable unit/system level tests have been added and they pass
  • Documentation has been updated
    • Upgrade instructions
    • Configuration details
    • Concepts
  • Changes flowforge.yml?
    • Issue/PR raised on FlowFuse/helm to update ConfigMap Template
    • Issue/PR raised on FlowFuse/CloudProject to update values for Staging/Production
  • Link to Changelog Entry PR, or note why one is not needed.

Labels

  • Includes a DB migration? -> add the area:migration label

@n-lark n-lark self-assigned this Mar 24, 2026
@n-lark n-lark linked an issue Mar 24, 2026 that may be closed by this pull request
@codecov
Copy link
Copy Markdown

codecov bot commented Mar 24, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 76.29%. Comparing base (849757a) to head (65df555).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #6952   +/-   ##
=======================================
  Coverage   76.29%   76.29%           
=======================================
  Files         403      403           
  Lines       20296    20296           
  Branches     4881     4881           
=======================================
  Hits        15485    15485           
  Misses       4811     4811           
Flag Coverage Δ
backend 76.29% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

// Same team — skip full reload but always refresh membership
if (team?.id) {
this.teamMembership = await teamApi.getTeamUserMembership(team.id)
}
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With pinia-plugin-persistedstate, the store hydrates from sessionStorage synchronously on first access. So this.team is already set when checkState calls setTeam. This meant currentTeam?.id === team?.id was always true on second+ page loads, the early return fired, and getTeamUserMembership was never called.

Fix: when IDs match, still call getTeamUserMembership before returning.

const teamMembership = await teamApi.getTeamUserMembership(team.id)
commit('setTeam', team)
commit('setTeamMembership', teamMembership)
await useAccountTeamStore().setTeam(team)
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

setTeam in the Pinia store now handles fetching teamMembership internally. It calls teamApi.getTeamUserMembership(team.id) as part of its own logic. So the old pattern of fetching membership separately and then committing both setTeam and setTeamMembership is replaced by a single useAccountTeamStore().setTeam(team) call that does both.

@n-lark n-lark marked this pull request as ready for review March 26, 2026 14:48
@n-lark n-lark requested a review from cstns March 26, 2026 14:49
Base automatically changed from 6829-pinia-task-12-account-auth to main March 31, 2026 13:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Pinia Task 13 - account-team

1 participant