Skip to content
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

Studio V6 Add WebSocket listener to track unsaved changes and update dirty state for ZAP configuration #1495

Merged
merged 1 commit into from
Dec 12, 2024

Conversation

paulr34
Copy link
Collaborator

@paulr34 paulr34 commented Dec 12, 2024

This pull request introduces functionality to track and manage the "dirty" state of ZAP configuration by listening for WebSocket events indicating unsaved changes. Specifically, the code listens for the dirtyFlag WebSocket event, and upon receiving this event, it triggers an action to update the application's dirty state.

Changes:

WebSocket listener: Added a WebSocket listener for the dirtyFlag event, which dispatches the setDirtyState action to update the application state when unsaved changes are detected.
Action: The setDirtyState action is responsible for fetching the current dirty state from the backend using the isDirty API endpoint and committing the result to the store.
Mutation: The setDirtyState mutation updates the state with the new dirty flag (isDirty) and sends a postMessage to the parent window to notify about the state change.

Detailed Changes:

WebSocket Listener:
Listens for the dirtyFlag event (dbEnum.wsCategory.dirtyFlag).
Dispatches the zap/setDirtyState action when the event is received.
setDirtyState Action:
Calls the backend API (restApi.ide.isDirty) to check if there are unsaved changes.
Commits the result (DIRTY status) to the store using the mutation.
setDirtyState Mutation:
Updates the Vuex state with the new isDirty value.
Sends a message to the parent window indicating the new dirty state, enabling external applications or processes to be aware of unsaved changes.

Purpose:

Ensure the application's dirty state is accurately tracked when there are unsaved changes in the ZAP configuration.
Improve integration with external systems by notifying them of dirty state changes through postMessage.

Copy link
Collaborator

@tecimovic tecimovic left a comment

Choose a reason for hiding this comment

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

This is propagating a wrong thing, but we can merge it in. I will work on cleaning this up further.

src/App.vue Show resolved Hide resolved
@paulr34 paulr34 merged commit 5d60f45 into project-chip:master Dec 12, 2024
13 checks passed
paulr34 added a commit to paulr34/zap that referenced this pull request Dec 13, 2024
paulr34 added a commit that referenced this pull request Dec 13, 2024
* set session_uuid in one place

* Revert "retrieve dirty status and send it via postMessage (#1495)"

This reverts commit 5d60f45.
gmarcosb pushed a commit to gmarcosb/zap that referenced this pull request Jan 15, 2025
gmarcosb pushed a commit to gmarcosb/zap that referenced this pull request Jan 15, 2025
* set session_uuid in one place

* Revert "retrieve dirty status and send it via postMessage (project-chip#1495)"

This reverts commit 5d60f45.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants