Skip to content
This repository has been archived by the owner on Jun 15, 2022. It is now read-only.

Commit

Permalink
fix: crash when using a 3rd-party theme with native features (#615)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
johnny243 and johnny243 committed May 17, 2022
1 parent 3a14a82 commit 08b7b28
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/Lib/ComponentManager.ts
Expand Up @@ -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)
}
Expand Down Expand Up @@ -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) {
Expand Down
1 change: 1 addition & 0 deletions src/Style/ThemeService.ts
Expand Up @@ -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()
}
Expand Down

0 comments on commit 08b7b28

Please sign in to comment.