Skip to content

Commit 861d5ef

Browse files
fix: take into account all changed keys (#231)
1 parent d9953c9 commit 861d5ef

File tree

2 files changed

+10
-12
lines changed

2 files changed

+10
-12
lines changed

resources/js/electron-plugin/dist/server/state.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@ import Store from "electron-store";
22
import { notifyLaravel } from "./utils.js";
33
const settingsStore = new Store();
44
settingsStore.onDidAnyChange((newValue, oldValue) => {
5-
const changedKey = Object.keys(newValue).find((key) => newValue[key] !== oldValue[key]);
6-
if (changedKey) {
5+
const changedKeys = Object.keys(newValue).filter((key) => newValue[key] !== oldValue[key]);
6+
changedKeys.forEach((key) => {
77
notifyLaravel("events", {
88
event: "Native\\Laravel\\Events\\Settings\\SettingChanged",
99
payload: {
10-
key: changedKey,
11-
value: newValue[changedKey] || null,
10+
key,
11+
value: newValue[key] || null,
1212
},
1313
});
14-
}
14+
});
1515
});
1616
function generateRandomString(length) {
1717
let result = "";

resources/js/electron-plugin/src/server/state.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,17 @@ import { notifyLaravel } from "./utils.js";
55
const settingsStore = new Store();
66
settingsStore.onDidAnyChange((newValue, oldValue) => {
77
// Only notify of the changed key/value pair
8-
const changedKey = Object.keys(newValue).find(
9-
(key) => newValue[key] !== oldValue[key]
10-
);
8+
const changedKeys = Object.keys(newValue).filter((key) => newValue[key] !== oldValue[key]);
119

12-
if (changedKey) {
10+
changedKeys.forEach((key) => {
1311
notifyLaravel("events", {
1412
event: "Native\\Laravel\\Events\\Settings\\SettingChanged",
1513
payload: {
16-
key: changedKey,
17-
value: newValue[changedKey] || null,
14+
key,
15+
value: newValue[key] || null,
1816
},
1917
});
20-
}
18+
});
2119
});
2220

2321
interface State {

0 commit comments

Comments
 (0)