fix: preserve rapid extended options saves - #754
Conversation
AllTerrainDeveloper
left a comment
There was a problem hiding this comment.
Great! Thank you!
@Pranjal1423 would you like to create a guest-post in our blog as the top contributor? :)
You can write about yourself, who are you, why you like OpenStation, why you contribute, the tools you use, etc.
|
Thank you! 😄 I’d love to!
|
I've sent you the invitation ;) Feel free to start the blog post when you wish! =) |
Closes #552
This PR resolves the issue where making quick successive changes in Extended Options could send a stale payload to WordPress, causing previous in-flight changes to be silently overwritten and lost after reload.
Changes:
apps/os-settings/parts/features.ts: Added optimistic in-memory updates viaObject.assign( ctx.data.extendedOptions, options )insidesaveExtended. This ensures any subsequent rapid click reads the newest user selections rather than waiting for the previous server response. Also added aninFlightExtendedSavescounter so theui.extendedSaving("Saving…") indicator accurately tracks overlapping background requests without flickering or premature reset.tests/vitest/extended-options-save.test.ts: Added automated test coverage for rapid successive toggles while a save is in flight to verify that all changes are preserved and dispatches carry the newest combined values.Testing:
Or
Run command:
npx vitest run tests/vitest/extended-options-save.test.tsBefore Fix (Test Fails — Bug Present)
After Fix (All Tests Pass — Bug Fixed)