Skip to content

Commit

Permalink
Prevent ThemeDetection from throwing if it is not available
Browse files Browse the repository at this point in the history
I believe this is related to #67.
  • Loading branch information
MarmadileManteater committed Jan 23, 2023
1 parent ff8a84f commit 294be7e
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions src/renderer/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ export default defineComponent({
this.grabAllProfiles(this.$t('Profile.All Channels')).then(async () => {
this.grabHistory()
this.grabAllPlaylists()

this.watchSystemTheme()
document.addEventListener('visibilitychange', () => {
if (!document.hidden) { // if the window was unfocused, the system theme might have changed
Expand Down Expand Up @@ -486,13 +487,17 @@ export default defineComponent({
document.body.dataset.systemTheme = shouldUseDarkColors ? 'dark' : 'light'
})
} else if (process.env.IS_CORDOVA) {
cordova.plugins.ThemeDetection.isAvailable((isThemeDetectionAvailable) => {
if (isThemeDetectionAvailable) {
cordova.plugins.ThemeDetection.isDarkModeEnabled((message) => {
document.body.dataset.systemTheme = message.value ? 'dark' : 'light'
})
}
}, console.error)
if ('ThemeDetection' in cordova.plugins) {
cordova.plugins.ThemeDetection.isAvailable((isThemeDetectionAvailable) => {
if (isThemeDetectionAvailable) {
cordova.plugins.ThemeDetection.isDarkModeEnabled((message) => {
document.body.dataset.systemTheme = message.value ? 'dark' : 'light'
})
}
}, console.error)
} else {
console.warn('ThemeDetection plugin failed to load.')
}
}
},

Expand Down

0 comments on commit 294be7e

Please sign in to comment.