mirror of
https://github.com/cheeaun/phanpy.git
synced 2025-02-16 15:21:48 +03:00
Attempt to fix theme-color bug
This commit is contained in:
parent
af503ac865
commit
34e2fe320d
1 changed files with 26 additions and 0 deletions
26
src/app.jsx
26
src/app.jsx
|
@ -187,6 +187,32 @@ setTimeout(() => {
|
|||
// );
|
||||
})();
|
||||
|
||||
// Possible fix for iOS PWA theme-color bug
|
||||
// It changes when loading web pages in "webview"
|
||||
const isIOS = /iPad|iPhone|iPod/.test(navigator.userAgent);
|
||||
if (isIOS) {
|
||||
document.addEventListener('visibilitychange', () => {
|
||||
if (document.visibilityState === 'visible') {
|
||||
// Get current color scheme
|
||||
const colorScheme = window.matchMedia('(prefers-color-scheme: dark)')
|
||||
.matches
|
||||
? 'dark'
|
||||
: 'light';
|
||||
// Get current theme-color
|
||||
const $meta = document.querySelector(
|
||||
`meta[name="theme-color"][media*="${colorScheme}"]`,
|
||||
);
|
||||
const color = $meta?.getAttribute('content');
|
||||
if (color) {
|
||||
$meta.content = '';
|
||||
setTimeout(() => {
|
||||
$meta.content = color;
|
||||
}, 10);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
subscribe(states, (changes) => {
|
||||
for (const [action, path, value, prevValue] of changes) {
|
||||
// Change #app dataset based on settings.shortcutsViewMode
|
||||
|
|
Loading…
Add table
Reference in a new issue