aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files_sharing/src
diff options
context:
space:
mode:
authorskjnldsv <skjnldsv@protonmail.com>2024-06-06 19:36:19 +0200
committerskjnldsv <skjnldsv@protonmail.com>2024-06-12 10:27:29 +0200
commit8bed23288b781db22c0825df7fac9f5312fbf6c4 (patch)
treebb4ace2d7cbca2c59402e7d04e30246ec1c9000f /apps/files_sharing/src
parent4a77fe3530d3213a2700b8ecdc1ccf3b4195b41a (diff)
downloadnextcloud-server-8bed23288b781db22c0825df7fac9f5312fbf6c4.tar.gz
nextcloud-server-8bed23288b781db22c0825df7fac9f5312fbf6c4.zip
fix(files_sharing): dark avatar support
Signed-off-by: skjnldsv <skjnldsv@protonmail.com>
Diffstat (limited to 'apps/files_sharing/src')
-rw-r--r--apps/files_sharing/src/actions/sharingStatusAction.ts6
1 files changed, 5 insertions, 1 deletions
diff --git a/apps/files_sharing/src/actions/sharingStatusAction.ts b/apps/files_sharing/src/actions/sharingStatusAction.ts
index f048de1c4fe..55e2bf21e8f 100644
--- a/apps/files_sharing/src/actions/sharingStatusAction.ts
+++ b/apps/files_sharing/src/actions/sharingStatusAction.ts
@@ -17,8 +17,12 @@ import { getCurrentUser } from '@nextcloud/auth'
import './sharingStatusAction.scss'
+const isDarkMode = window?.matchMedia?.('(prefers-color-scheme: dark)')?.matches === true
+ || document.querySelector('[data-themes*=dark]') !== null
+
const generateAvatarSvg = (userId: string, isGuest = false) => {
- const avatarUrl = generateUrl(isGuest ? '/avatar/guest/{userId}/32' : '/avatar/{userId}/32?guestFallback=true', { userId })
+ const url = isDarkMode ? '/avatar/{userId}/32/dark' : '/avatar/{userId}/32'
+ const avatarUrl = generateUrl(isGuest ? url : url + '?guestFallback=true', { userId })
return `<svg width="32" height="32" viewBox="0 0 32 32"
xmlns="http://www.w3.org/2000/svg" class="sharing-status__avatar">
<image href="${avatarUrl}" height="32" width="32" />