fix(web): change component keys to use id tied to controller lifecycle instead of item id (#1681)

* fix(web): change component keys to use id tied to controller lifecycle instead of item id

* chore: lint
This commit is contained in:
Mo
2022-09-29 10:58:10 -05:00
committed by GitHub
parent 88f35b39fb
commit 492c9bacbf
4 changed files with 11 additions and 4 deletions

View File

@@ -122,10 +122,10 @@ class NoteGroupView extends PureComponent<Props, State> {
<>
{this.state.controllers.map((controller) => {
return controller instanceof NoteViewController ? (
<NoteView key={controller.item.uuid} application={this.application} controller={controller} />
<NoteView key={controller.runtimeId} application={this.application} controller={controller} />
) : (
<FileView
key={controller.item.uuid}
key={controller.runtimeId}
application={this.application}
viewControllerManager={this.viewControllerManager}
file={controller.item}

View File

@@ -149,6 +149,9 @@ class NoteView extends PureComponent<NoteViewProps, State> {
}
override deinit() {
super.deinit()
;(this.controller as unknown) = undefined
window.removeEventListener('scroll', this.handleWindowScroll)
this.removeComponentStreamObserver?.()
@@ -165,7 +168,6 @@ class NoteView extends PureComponent<NoteViewProps, State> {
this.clearNoteProtectionInactivityTimer()
;(this.ensureNoteIsInsertedBeforeUIAction as unknown) = undefined
;(this.controller as unknown) = undefined
this.removeTabObserver?.()
this.removeTabObserver = undefined
@@ -173,7 +175,6 @@ class NoteView extends PureComponent<NoteViewProps, State> {
this.statusTimeout = undefined
;(this.onPanelResizeFinish as unknown) = undefined
super.deinit()
;(this.dismissProtectedWarning as unknown) = undefined
;(this.editorComponentViewerRequestsReload as unknown) = undefined
;(this.onTextAreaChange as unknown) = undefined
@@ -313,6 +314,10 @@ class NoteView extends PureComponent<NoteViewProps, State> {
}
override async onAppEvent(eventName: ApplicationEvent) {
if (this.controller?.dealloced) {
return
}
switch (eventName) {
case ApplicationEvent.PreferencesChanged:
this.reloadPreferences().catch(console.error)