Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduce amount of queries for Teams feature #708

Merged
merged 1 commit into from
Mar 17, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/Http/Middleware/ShareInertiaData.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ public function handle($request, $next)
}

if (Jetstream::hasTeamFeatures() && $request->user()) {
$request->user()->currentTeam;
$request->user()->setRelation('currentTeam', $request->user()->allTeams()->filter(function ($team) use ($request) {
return $team->id === $request->user()->current_team_id;
})->first());
Comment on lines +45 to +47
Copy link
Contributor

@matthieumota matthieumota Mar 24, 2021

Choose a reason for hiding this comment

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

Hi,

I think that PR cause a bug due to current_team_id field who can be null. Just try to install a fresh Laravel with Jetstream and you're unable to login (white page due to JS error and team).

It's because field is refresh with switchTeam method. Before PR, currentTeam() was called and check that.

Maybe you can try that 👍

if (is_null($request->user()->current_team_id)) {
    $request->user()->switchTeam($request->user()->personalTeam());
}

Copy link
Member

Choose a reason for hiding this comment

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

Thanks, reverted.

}

return array_merge($request->user()->toArray(), array_filter([
Expand Down