Skip to content

Commit

Permalink
fix: redux can't serialize a Set<string> (#173)
Browse files Browse the repository at this point in the history
Use a plain object with unique keys Go style
  • Loading branch information
evan-buss authored Jul 1, 2024
1 parent e6bc149 commit fc95f6d
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion server/app/src/components/tables/BookTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export default function BookTable({ books }: BookTableProps) {
<DataTableColumnHeader column={props.column} title="Server" />
),
cell: (props) => {
const online = servers && servers.has(props.getValue());
const online = servers && servers[props.getValue()];
return (
<Tooltip position="top-start" label={online ? "Online" : "Offline"}>
<Indicator
Expand Down
2 changes: 1 addition & 1 deletion server/app/src/components/tables/Facets.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export function ServerFacetEntry({
style
}: FacetEntryProps) {
const { data: servers } = useGetServersQuery();
const serverOnline = servers && servers.has(entry);
const serverOnline = servers && servers[entry];

return (
<Button
Expand Down
6 changes: 4 additions & 2 deletions server/app/src/state/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,12 @@ export const api = createApi({
}),
tagTypes: ["books", "servers"],
endpoints: (builder) => ({
getServers: builder.query<Set<string>, void>({
getServers: builder.query<Record<string, boolean>, void>({
query: () => `servers`,
transformResponse: (ircServers: IrcServer) => {
return new Set(ircServers.elevatedUsers ?? []);
return Object.fromEntries(
ircServers.elevatedUsers?.map((x) => [x, true]) ?? []
);
}
}),
getBooks: builder.query<Book[], void>({
Expand Down

0 comments on commit fc95f6d

Please sign in to comment.