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:
@@ -6,6 +6,7 @@ import { ItemViewControllerInterface } from './ItemViewControllerInterface'
|
||||
export class FileViewController implements ItemViewControllerInterface {
|
||||
public dealloced = false
|
||||
private removeStreamObserver?: () => void
|
||||
public runtimeId = `${Math.random()}`
|
||||
|
||||
constructor(private application: SNApplication, public item: FileItem) {}
|
||||
|
||||
|
||||
@@ -35,6 +35,7 @@ export class NoteViewController implements ItemViewControllerInterface {
|
||||
private saveTimeout?: ReturnType<typeof setTimeout>
|
||||
private defaultTitle: string | undefined
|
||||
private defaultTag: UuidString | undefined
|
||||
public runtimeId = `${Math.random()}`
|
||||
|
||||
constructor(
|
||||
private application: SNApplication,
|
||||
|
||||
@@ -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}
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user