Skip to content

Commit

Permalink
virtual-merge all return fix (#641)
Browse files Browse the repository at this point in the history
* fix

* fix: filter virtualMerge keys only if its a store

---------

Co-authored-by: Federico <[email protected]>
  • Loading branch information
yofukashino and FedeIlLeone authored Nov 13, 2024
1 parent 1df7737 commit 5afc587
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/renderer/util.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { React, channels, fluxDispatcher, guilds } from "@common";
import { React, channels, flux, fluxDispatcher, guilds } from "@common";
import type { Fiber } from "react-reconciler";
import type { Jsonifiable } from "type-fest";
import type { ObjectExports } from "../types";
Expand Down Expand Up @@ -287,7 +287,17 @@ export function virtualMerge<O extends ObjectType[]>(...objects: O): ExtractObje
if (method === "get" && args[0] === "all") {
// Return function that returns all objects combined
// For use in devtools to see everything available
return () => objects.reduce((acc, obj) => ({ ...acc, ...obj }), {});
return () =>
objects.reduce((acc: Record<string, unknown>, obj: Record<string, unknown>) => {
// Manually iterate over the property names of the object because the spread operator does not work with prototype objects, which are common for stores.
Object.getOwnPropertyNames(obj).forEach((key) => {
// Filter out keys that are common on all stores
if (!(obj instanceof flux.Store) || (key !== "initialize" && key !== "constructor")) {
acc[key] = obj[key];
}
});
return acc;
}, {});
}
return Reflect[method](
findObjectByProp(args[0] as PropertyKey),
Expand Down

0 comments on commit 5afc587

Please sign in to comment.