Skip to content

Commit

Permalink
Merge pull request #14 from author-more/fix/icon-set-status-persistance
Browse files Browse the repository at this point in the history
fix: icon set's state to persist across restarts
  • Loading branch information
Belar authored Sep 6, 2024
2 parents 56768cd + d55ebca commit 50a5db0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
19 changes: 10 additions & 9 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,6 @@ function App() {
}, []);

useEffect(() => {
sendMessage("set-plugin-data", {
scope: DATA_KEY_ICON_SETS_SETTINGS,
data: iconSetsSettings,
});

const [result, controller] = getIconSetsByVariant(
iconLibraries,
iconSetsSettings,
Expand Down Expand Up @@ -226,13 +221,19 @@ function App() {
(typeof defaultIconSetSettings)[keyof typeof defaultIconSetSettings]
>,
) {
setIconSetsSettings((currentSettings) => ({
...currentSettings,
const settingsUpdated = {
...iconSetsSettings,
[id]: {
...currentSettings[id],
...iconSetsSettings[id],
...settings,
},
}));
};

setIconSetsSettings(settingsUpdated);
sendMessage("set-plugin-data", {
scope: DATA_KEY_ICON_SETS_SETTINGS,
data: settingsUpdated,
});
}

return (
Expand Down
4 changes: 2 additions & 2 deletions tests/settings.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ test.describe("settings", () => {
await iconSetToggleButton.click();

const event = eventLog.filter(({ type }) => type === "set-plugin-data");
expect(event[1]).toMatchObject({
expect(event[0]).toMatchObject({
type: "set-plugin-data",
content: {
scope: "iconSetsSettings",
Expand Down Expand Up @@ -41,7 +41,7 @@ test.describe("settings", () => {
await changeStyleSelect.selectOption({ label: "solid" });

const event = eventLog.filter(({ type }) => type === "set-plugin-data");
expect(event[2]).toMatchObject({
expect(event[1]).toMatchObject({
type: "set-plugin-data",
content: {
scope: "iconSetsSettings",
Expand Down

0 comments on commit 50a5db0

Please sign in to comment.