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

Do not stack several automatic dialogs #1549

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

ArturoManzoli
Copy link
Contributor

@ArturoManzoli ArturoManzoli commented Jan 7, 2025

  • Implemented a dialog queue to handle potential modal stack-ups.

Closes #1494

src/App.vue Show resolved Hide resolved
Comment on lines 2 to 4
<v-dialog v-model="internalShowDialog" :persistent="persistent" :width="maxWidth || 'auto'">
<v-dialog
v-model="internalShowDialog"
:persistent="persistent"
Copy link
Member

Choose a reason for hiding this comment

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

In this case are we coupling the interaction dialog to the queue system? It seems strange, since we use it for a lot of popups that are open explicitly by the user (and not automatically), like the about page, menus, error dialogs, etc.

It seems to me they should be completely uncoupled, and the queue system should live outside it and only for automatically-issued dialogs.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The other dialogs will be unchanged and uncoupled from the queue. The ones that will be queued are only those that can potentially stack up, like the ones on the Cockpit startup.

It's also done like this on snackbar queue systems. Whenever a message can stackup, you queue it.

Copy link
Member

Choose a reason for hiding this comment

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

I mean that the queue system should be external to the InteractionDialog.vue component, otherwise we are putting queue logic on dialogs that should not be queue-aware.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In reality the InteractionDialog is uncoupled from the queue system.

The queue uses a logic based on dependency injection. If you check on App.vue, the components are loaded on startup and queued independently and the enqueueDialog function takes the component, its props and an id as parameter.

interfaceStore.enqueueDialog({ id: 'VehicleDiscoveryDialog', component: VehicleDiscoveryDialog, props: {}, })

For example, the system update dialog will only be queued if the function that checks for new versions triggers the dialog and will inject the component on the function to do so.
Actually it doesn't have to be a dialog. Could be virtually any other component we have.

Copy link
Member

@rafaellehmkuhl rafaellehmkuhl Jan 17, 2025

Choose a reason for hiding this comment

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

What I'm saying is that the interaction dialog should not be the one deciding on what happens with the log queue (interfaceStore.openNextDialogOnQueue()), but instead there should be an observer outside the interaction dialog checking if there's any interaction dialog open, and if not, open the next dialog in the queue.

The interaction dialog should be what is is, a dialog. It does not need to be aware of the queue. It's an unnecessary architecture coupling.

It's the same problem we had before, that you're fixing in this PR, about the interaction dialog being aware of the Tutorial functionality (it shouldn't).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

But the InteractionDialog isn't aware of the queue. The only modification I made to it was the closing logic so it can handle the queue

Copy link
Member

Choose a reason for hiding this comment

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

Discussed the details in a call. Main topic was to uncouple to facilitate maintenance, shrink the codebase and allow easy future changes (for new auto-instantiated dialogs).

src/types/interface.ts Outdated Show resolved Hide resolved
src/App.vue Show resolved Hide resolved
src/App.vue Outdated Show resolved Hide resolved
Comment on lines 2 to 4
<v-dialog v-model="internalShowDialog" :persistent="persistent" :width="maxWidth || 'auto'">
<v-dialog
v-model="internalShowDialog"
:persistent="persistent"
Copy link
Member

@rafaellehmkuhl rafaellehmkuhl Jan 17, 2025

Choose a reason for hiding this comment

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

What I'm saying is that the interaction dialog should not be the one deciding on what happens with the log queue (interfaceStore.openNextDialogOnQueue()), but instead there should be an observer outside the interaction dialog checking if there's any interaction dialog open, and if not, open the next dialog in the queue.

The interaction dialog should be what is is, a dialog. It does not need to be aware of the queue. It's an unnecessary architecture coupling.

It's the same problem we had before, that you're fixing in this PR, about the interaction dialog being aware of the Tutorial functionality (it shouldn't).

@ArturoManzoli ArturoManzoli force-pushed the do-not-stack-auto-dialogs branch 2 times, most recently from d6147e2 to f6e9ea4 Compare January 17, 2025 15:49
@ArturoManzoli ArturoManzoli force-pushed the do-not-stack-auto-dialogs branch from f6e9ea4 to 38901db Compare January 27, 2025 15:15
@ArturoManzoli
Copy link
Contributor Author

On last patch:

  • Dialog queue now monitors the dom for its open elements by id, and once they cease to exist, they open the next one on the line, decoupling the enqueued elements from the queue logic.
  • Reverted changes made on components like UpdateNotification, VehicleDiscoveryDialog and InteractiveDialog;

Signed-off-by: Arturo Manzoli <[email protected]>

App: Implement startup dialogs queue

Signed-off-by: Arturo Manzoli <[email protected]>
@ArturoManzoli ArturoManzoli force-pushed the do-not-stack-auto-dialogs branch 2 times, most recently from 1495c59 to c5cb8ce Compare January 27, 2025 15:59
Comment on lines -316 to +324
<Tutorial :show-tutorial="interfaceStore.isTutorialVisible" />
<VideoLibraryModal :open-modal="interfaceStore.isVideoLibraryVisible" />
<VehicleDiscoveryDialog v-model="showDiscoveryDialog" show-auto-search-option />
<UpdateNotification v-if="isElectron()" />
<Teleport to="body">
<Tutorial />
</Teleport>

<!-- Startup dialogs queue -->
<div v-if="activeDialog">
<component :is="activeDialog.component" v-bind="activeDialog.props" :id="activeDialog.id" />
</div>
Copy link
Member

Choose a reason for hiding this comment

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

Why is the tutorial treated differently? Aren't it a automatic dialog like all others?

@@ -403,6 +392,7 @@ const handleKeydown = (event: KeyboardEvent): void => {
watch(
() => interfaceStore.isTutorialVisible,
(val) => {
console.log('🚀 ~ val:', val)
Copy link
Member

Choose a reason for hiding this comment

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

This was in an old PR, was asked to be removed, and is being added here again.

Comment on lines +82 to +85
if (interfaceStore.activeDialog?.id === 'UpdateNotification' || interfaceStore.activeDialog === undefined) {
showUpdateDialog.value = true
return
}
Copy link
Member

Choose a reason for hiding this comment

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

This is still putting the instantiation logic inside the components, just with another name/approach, and there's no need for that.

This is solvable with a much easier approach where the one controlling the issue of automatic notifications (the App.vue file) is the one who instantiates the component, based on the queue logic (show tutorial, when it closes show the discovery dialog, when it closes show the user selection, etc). There's no need for any logic around the automation of the component mounting to be inside the component itself.

Every new dialog component still has to implement logic around an automatic issuing, which it should't need to be aware off. The dialog components should only care about their own content.

@ArturoManzoli ArturoManzoli force-pushed the do-not-stack-auto-dialogs branch from c5cb8ce to 2b70ec8 Compare January 27, 2025 17:19
@ArturoManzoli ArturoManzoli marked this pull request as draft January 27, 2025 17:19
@ArturoManzoli ArturoManzoli force-pushed the do-not-stack-auto-dialogs branch from 2b70ec8 to d0ea490 Compare January 27, 2025 18:32
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.

There's a stack of dialogs being created on top of each other without coordination
2 participants