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

fix: Use get() instead of this in Zustand stores #2250

Merged
merged 1 commit into from
Oct 1, 2023
Merged
Show file tree
Hide file tree
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
5 changes: 2 additions & 3 deletions editor.planx.uk/src/pages/FlowEditor/lib/store/team.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export const teamStore: StateCreator<TeamStore, [], [], TeamStore> = (
boundaryBBox: get().boundaryBBox,
}),

async initTeamStore(teamSlugFromURLParams) {
initTeamStore: async (teamSlugFromURLParams) => {
const slug = teamSlugFromURLParams || await getTeamFromDomain(window.location.hostname)
const { data } = await client.query({
query: gql`
Expand Down Expand Up @@ -86,7 +86,6 @@ export const teamStore: StateCreator<TeamStore, [], [], TeamStore> = (
const team = data.teams[0];

if (!team) throw new Error("Team not found");

this.setTeam(team);
get().setTeam(team);
},
});
4 changes: 2 additions & 2 deletions editor.planx.uk/src/pages/FlowEditor/lib/store/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export const userStore: StateCreator<UserStore, [], [], UserStore> = (
);
},

async initUserStore(jwt: string) {
initUserStore: async (jwt: string) => {
const email = (jwtDecode(jwt) as any)["email"];
const users = await client.query({
query: gql`
Expand Down Expand Up @@ -87,6 +87,6 @@ export const userStore: StateCreator<UserStore, [], [], UserStore> = (
const user: User = users.data.users[0];
if (!user) throw new Error(`Failed to get user ${email}`);

this.setUser(user);
get().setUser(user);
},
});
2 changes: 1 addition & 1 deletion editor.planx.uk/src/routes/views/team.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export const teamView = async (req: NaviRequest) => {
try {
await initTeamStore(req.params.team);
} catch (error) {
throw new NotFoundError("Team not found");
throw new NotFoundError(`Team not found: ${error}`);
}
}

Expand Down
Loading