Skip to content

fix: take into account all changed keys #210

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
10 changes: 5 additions & 5 deletions resources/js/electron-plugin/dist/server/state.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@ import Store from "electron-store";
import { notifyLaravel } from "./utils.js";
const settingsStore = new Store();
settingsStore.onDidAnyChange((newValue, oldValue) => {
const changedKey = Object.keys(newValue).find((key) => newValue[key] !== oldValue[key]);
if (changedKey) {
const changedKeys = Object.keys(newValue).filter((key) => newValue[key] !== oldValue[key]);
changedKeys.forEach((key) => {
notifyLaravel("events", {
event: "Native\\Laravel\\Events\\Settings\\SettingChanged",
payload: {
key: changedKey,
value: newValue[changedKey] || null,
key,
value: newValue[key] || null,
},
});
}
});
});
function generateRandomString(length) {
let result = "";
Expand Down
12 changes: 5 additions & 7 deletions resources/js/electron-plugin/src/server/state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,17 @@ import { notifyLaravel } from "./utils.js";
const settingsStore = new Store();
settingsStore.onDidAnyChange((newValue, oldValue) => {
// Only notify of the changed key/value pair
const changedKey = Object.keys(newValue).find(
(key) => newValue[key] !== oldValue[key]
);
const changedKeys = Object.keys(newValue).filter((key) => newValue[key] !== oldValue[key]);

if (changedKey) {
changedKeys.forEach((key) => {
notifyLaravel("events", {
event: "Native\\Laravel\\Events\\Settings\\SettingChanged",
payload: {
key: changedKey,
value: newValue[changedKey] || null,
key,
value: newValue[key] || null,
},
});
}
});
});

interface State {
Expand Down
Loading