|
24 | 24 |
|
25 | 25 | use OCA\Theming\AppInfo\Application; |
26 | 26 | use OCA\Theming\Themes\DefaultTheme; |
| 27 | +use OCA\Theming\Util; |
27 | 28 | use OCP\IConfig; |
28 | 29 | use OCP\IURLGenerator; |
29 | 30 | use OCP\IUserSession; |
30 | | -use OCP\Util; |
31 | 31 |
|
32 | 32 | class ThemeInjectionService { |
33 | 33 |
|
34 | 34 | private IURLGenerator $urlGenerator; |
35 | 35 | private ThemesService $themesService; |
36 | 36 | private DefaultTheme $defaultTheme; |
| 37 | + private Util $util; |
37 | 38 | private IConfig $config; |
38 | 39 | private ?string $userId; |
39 | 40 |
|
40 | 41 | public function __construct(IURLGenerator $urlGenerator, |
41 | 42 | ThemesService $themesService, |
42 | 43 | DefaultTheme $defaultTheme, |
| 44 | + Util $util, |
43 | 45 | IConfig $config, |
44 | 46 | IUserSession $userSession) { |
45 | 47 | $this->urlGenerator = $urlGenerator; |
46 | 48 | $this->themesService = $themesService; |
47 | 49 | $this->defaultTheme = $defaultTheme; |
| 50 | + $this->util = $util; |
48 | 51 | $this->config = $config; |
49 | 52 | if ($userSession->getUser() !== null) { |
50 | 53 | $this->userId = $userSession->getUser()->getUID(); |
@@ -87,20 +90,12 @@ public function injectHeaders() { |
87 | 90 | * @param string $media media query to use in the <link> element |
88 | 91 | */ |
89 | 92 | private function addThemeHeader(string $themeId, bool $plain = true, string $media = null) { |
90 | | - $cacheBuster = $this->config->getAppValue('theming', 'cachebuster', '0'); |
91 | | - if ($this->userId !== null) { |
92 | | - // need to bust the cache for the CSS file when the user background changed as its |
93 | | - // URL is served in those files |
94 | | - $userCacheBuster = $this->config->getUserValue($this->userId, Application::APP_ID, 'userCacheBuster', '0'); |
95 | | - $cacheBuster .= $this->userId . '_' . $userCacheBuster; |
96 | | - } |
97 | | - |
98 | 93 | $linkToCSS = $this->urlGenerator->linkToRoute('theming.Theming.getThemeStylesheet', [ |
99 | 94 | 'themeId' => $themeId, |
100 | 95 | 'plain' => $plain, |
101 | | - 'v' => substr(sha1($cacheBuster), 0, 8), |
| 96 | + 'v' => $this->util->getCacheBuster(), |
102 | 97 | ]); |
103 | | - Util::addHeader('link', [ |
| 98 | + \OCP\Util::addHeader('link', [ |
104 | 99 | 'rel' => 'stylesheet', |
105 | 100 | 'media' => $media, |
106 | 101 | 'href' => $linkToCSS, |
|
0 commit comments