Skip to content
Merged
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
2 changes: 1 addition & 1 deletion src/main/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ interface AppSettings {
const schema = {
apiToken: { type: "string" },
apiSecret: { type: "string" }, // For storing the secret, consider encryption
pollingIntervalSeconds: { type: "number", default: 10 },
pollingIntervalSeconds: { type: "number", default: 60 },

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

Changing the default polling interval to 60 seconds is a great improvement for preventing API rate limit issues.

To make this even more robust, I suggest adding a minimum value to the schema, as shown in the suggestion. The SwitchBot API is limited to 10,000 requests/day (~1 every 8.6s), so a very low polling interval can cause problems. By setting a minimum, you can prevent users from choosing a value that is too aggressive. A minimum of 10 seconds would be a safe floor.

Important Note: Adding this validation will cause electron-store to throw an error if an attempt is made to set a value below the minimum. You'll need to ensure that the UI and state management logic can handle this validation gracefully (e.g., by updating the input validation in SettingsScreen.tsx and handling the electron-store set call in a try...catch block or a thunk).

Suggested change
pollingIntervalSeconds: { type: "number", default: 60 },
pollingIntervalSeconds: { type: "number", default: 60, minimum: 10 },

theme: { type: "string", default: "dark" },
logRetentionDays: { type: "number", default: 7 },
};
Expand Down