fix: crash when using a 3rd-party theme with native features (#615)

* fix: crash when using a 3rd-party theme with native features

* fix: preload 3rd-party theme from ThemeService

* fix: take preloadThirdPartyThemeIndexPath outside of setActiveTheme

* fix: move preloadThirdPartyThemeIndexPath to component manager

Co-authored-by: Johnny Almonte <johnny243@users.noreply.github.com>
This commit is contained in:
Johnny A
2022-05-17 10:51:45 -04:00
committed by GitHub
parent 3a14a82eb9
commit 08b7b28149
2 changed files with 15 additions and 2 deletions

View File

@@ -64,8 +64,8 @@ export class ComponentManager extends SNComponentManager {
} catch (e) {
void this.alertService.alert(
'Unable to start component server. ' +
'Editors other than the Plain Editor will fail to load. ' +
'Please restart the app and try again.'
'Editors other than the Plain Editor will fail to load. ' +
'Please restart the app and try again.'
)
SNLog.error(e as any)
}
@@ -317,6 +317,18 @@ export class ComponentManager extends SNComponentManager {
return []
}
}
public async preloadThirdPartyThemeIndexPath() {
const theme = this.mobileActiveTheme
if (!theme) {
return
}
const { identifier } = theme
if (this.isComponentThirdParty(identifier)) {
await this.preloadThirdPartyIndexPathFromDisk(identifier)
}
}
}
export async function associateComponentWithNote(application: SNApplication, component: SNComponent, note: SNNote) {

View File

@@ -262,6 +262,7 @@ export class ThemeService {
const matchingThemeId = Object.keys(this.themes).find(themeId => themeId === savedThemeId)
if (matchingThemeId) {
this.setActiveTheme(matchingThemeId)
void this.application?.mobileComponentManager.preloadThirdPartyThemeIndexPath()
} else {
this.setDefaultTheme()
}