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

Stop note map simulation if not visible #4183

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
4 changes: 4 additions & 0 deletions src/public/app/widgets/containers/ribbon_container.js
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,10 @@ export default class RibbonContainer extends NoteContextAwareWidget {
}
}
} else {
const activeChild = this.getActiveRibbonWidget();
if (activeChild) {
activeChild.handleEvent('deactivated', {});
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am using a new event here since I did not find any existing mechanism to shut down a widget.

Copy link
Owner

Choose a reason for hiding this comment

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

Have you tried cleanup() method in TypeWidget (inherited in NoteMapTypeWidget)? Seems to me it could be used for this. Although it would not work for Ribbon specifically ...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It doesn't matter as much for the Ribbon widget, but could still be relevant for cases like #2608

}
this.lastActiveComponentId = null;
}
}
Expand Down
3 changes: 3 additions & 0 deletions src/public/app/widgets/note_detail.js
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,9 @@ export default class NoteDetailWidget extends NoteContextAwareWidget {

async beforeNoteSwitchEvent({noteContext}) {
if (this.isNoteContext(noteContext.ntxId)) {
for (const x of this.children) {
FliegendeWurst marked this conversation as resolved.
Show resolved Hide resolved
x.handleEvent("deactivated", {});
}
await this.spacedUpdate.updateNowIfNecessary();
}
}
Expand Down
5 changes: 5 additions & 0 deletions src/public/app/widgets/note_map.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,11 @@ export default class NoteMapWidget extends NoteContextAwareWidget {
this.renderData(data);
}

deactivatedEvent() {
this.graph.stopAnimation();
this.graph = null;
}

getMapRootNoteId() {
if (this.widgetMode === 'ribbon') {
return this.noteId;
Expand Down
4 changes: 4 additions & 0 deletions src/public/app/widgets/type_widgets/note_map.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,8 @@ export default class NoteMapTypeWidget extends TypeWidget {
async doRefresh(note) {
await this.noteMapWidget.refresh();
}

deactivatedEvent() {
this.noteMapWidget.deactivatedEvent();
}
}
Loading