blob: ba198be0a0049b9b0f95961cfac8c2047a50fee8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
/**
* SPDX-FileCopyrightText: 2022 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
/**
* Refresh server-side generated theming CSS
* This resolves when all themes are reloaded
*/
export async function refreshStyles() {
const themes = [...document.head.querySelectorAll('link.theme')]
const promises = themes.map((theme) => new Promise((resolve) => {
const url = new URL(theme.href)
url.searchParams.set('v', Date.now())
const newTheme = theme.cloneNode()
newTheme.href = url.toString()
newTheme.onload = () => {
theme.remove()
resolve()
}
document.head.append(newTheme)
}))
// Wait until all themes are loaded
await Promise.allSettled(promises)
}
|