Sync-in · Sovereign platform for file storage, sharing, synchronization, and collaboration.
TypeScript cloud-alternativecollaborationcollaborative-editingdropboxfile-serverfile-sharingfile-storagefile-syncfull-text-searchhomelabnextcloudon-premiseopen-sourceprivacy-firstprivate-cloudrealtimesecureself-hostedstorage-serverwebdav
feat(users): persist desktop notification display preference
johavene07d339919f0
diff --git a/backend/src/applications/users/dto/user-properties.dto.ts b/backend/src/applications/users/dto/user-properties.dto.tsindex 7baaa1bb..1de07888 100644--- a/backend/src/applications/users/dto/user-properties.dto.ts+++ b/backend/src/applications/users/dto/user-properties.dto.ts@@ -33,6 +33,10 @@ export class UserPreferencesDto implements Partial<UserPreferences> {@ValidateIf((_, value) => value !== undefined)@IsIn([COLLABORA_EDITOR, ONLY_OFFICE_EDITOR, EURO_OFFICE_EDITOR, null])editor?: UserPreferences['editor']++ @ValidateIf((_, value) => value !== undefined)+ @IsBoolean()+ useSystemNotifications?: UserPreferences['useSystemNotifications']}export class UserUpdatePasswordDto {diff --git a/backend/src/applications/users/interfaces/user-preferences.interface.ts b/backend/src/applications/users/interfaces/user-preferences.interface.tsindex e44496fc..337c0ad1 100644--- a/backend/src/applications/users/interfaces/user-preferences.interface.ts+++ b/backend/src/applications/users/interfaces/user-preferences.interface.ts@@ -6,4 +6,5 @@ export type UserTheme = Exclude<USER_THEME, USER_THEME.AUTO>export interface UserPreferences {theme: USER_THEMEeditor: Exclude<keyof FileEditorProviders, 'drawio'> | null+ useSystemNotifications: boolean}diff --git a/backend/src/applications/users/services/users-manager.service.ts b/backend/src/applications/users/services/users-manager.service.tsindex fff5f446..a1e4fd95 100755--- a/backend/src/applications/users/services/users-manager.service.ts+++ b/backend/src/applications/users/services/users-manager.service.ts@@ -238,6 +238,7 @@ export class UsersManager {const patch: Partial<UserPreferences> = {}if (dto.theme !== undefined) patch.theme = dto.themeif (dto.editor !== undefined) patch.editor = dto.editor+ if (dto.useSystemNotifications !== undefined) patch.useSystemNotifications = dto.useSystemNotificationstry {return await this.usersQueries.updateUserPreferences(user.id, patch)} catch (e) {diff --git a/backend/src/applications/users/services/users-queries.service.ts b/backend/src/applications/users/services/users-queries.service.tsindex 05974b60..9a656d09 100644--- a/backend/src/applications/users/services/users-queries.service.ts+++ b/backend/src/applications/users/services/users-queries.service.ts@@ -193,7 +193,11 @@ export class UsersQueries {}const currentPreferences = normalizeUserPreferences(user.preferences)const preferences = { ...currentPreferences, ...patch }- if (preferences.theme === currentPreferences.theme && preferences.editor === currentPreferences.editor) {+ if (+ preferences.theme === currentPreferences.theme &&+ preferences.editor === currentPreferences.editor &&+ preferences.useSystemNotifications === currentPreferences.useSystemNotifications+ ) {return currentPreferences}dbCheckAffectedRows(await tx.update(users).set({ preferences }).where(eq(users.id, userId)), 1)diff --git a/backend/src/applications/users/utils/user.ts b/backend/src/applications/users/utils/user.tsindex 6d1bd601..4b42f76d 100644--- a/backend/src/applications/users/utils/user.ts+++ b/backend/src/applications/users/utils/user.ts@@ -4,6 +4,7 @@ import type { UserPreferences } from '../interfaces/user-preferences.interface'export function normalizeUserPreferences(preferences?: Partial<UserPreferences> | null): UserPreferences {return {theme: preferences?.theme ?? USER_THEME.AUTO,- editor: preferences?.editor ?? null+ editor: preferences?.editor ?? null,+ useSystemNotifications: preferences?.useSystemNotifications ?? true}}diff --git a/frontend/src/app/applications/users/components/user-account.component.html b/frontend/src/app/applications/users/components/user-account.component.htmlindex 183beff0..60e1bac0 100755--- a/frontend/src/app/applications/users/components/user-account.component.html+++ b/frontend/src/app/applications/users/components/user-account.component.html@@ -34,6 +34,19 @@<div><div class="px-1 mt-4">+ @if (user.isUser) {+ <div class="row g-2 align-items-center py-2 border-bottom border-secondary-subtle">+ <div class="col-5 col-sm-4" l10nTranslate>Avatar</div>+ <div class="col-7 col-sm-8 d-flex flex-wrap justify-content-end gap-2">+ <button (click)="genAvatar()" class="btn btn-success" type="button" l10nTranslate>Generate</button>+ <button class="btn-file-upload btn btn-default" type="button">+ <span l10nTranslate>Import</span>+ <input (change)="uploadAvatar($event)" accept="image/*" name="file" role="button" type="file" />+ </button>+ </div>+ </div>+ }+<div class="row g-2 align-items-center py-2 border-bottom border-secondary-subtle"><div class="col-5 col-sm-4" l10nTranslate>Login</div><span class="col-7 col-sm-8 text-end">{{ user.login }}</span>@@ -101,6 +114,17 @@<div class="card-body"><div class="text-muted text-uppercase fs-sm text-bold mb-2" l10nTranslate>Preferences</div>+ <div class="row g-2 align-items-center mb-2">+ <label class="col-12 col-sm-6" for="userLanguage" l10nTranslate>Language</label>+ <div class="col-12 col-sm-6">+ <select id="userLanguage" [(ngModel)]="language" class="form-select">+ @for (l of languages; track $index) {+ <option [ngValue]="l">{{ i18nLanguageText[l] }}</option>+ }+ </select>+ </div>+ </div>+<div class="row g-2 align-items-center mb-2"><label class="col-12 col-sm-6" for="userTheme" l10nTranslate>Theme</label><div class="col-12 col-sm-6">@@ -172,36 +196,10 @@<div class="col-12 col-lg-6 d-flex flex-column gap-3"><div class="card dialog-tab-card"><div class="card-body">- <div class="text-muted text-uppercase fs-sm text-bold mb-2" l10nTranslate>Configuration</div>+ <div class="text-muted text-uppercase fs-sm text-bold mb-2" l10nTranslate>Notifications</div><div class="d-flex flex-column gap-2">- @if (user.isUser) {- <div class="row g-2 align-items-center">- <div class="form-label col-12 col-md-6 mb-0" l10nTranslate>Avatar</div>- <div class="col-12 col-md-6">- <div class="d-flex flex-wrap gap-2">- <button (click)="genAvatar()" class="btn btn-success" type="button" l10nTranslate>Generate</button>- <button class="btn-file-upload btn btn-default" type="button">- <span l10nTranslate>Import</span>- <input (change)="uploadAvatar($event)" accept="image/*" name="file" role="button" type="file" />- </button>- </div>- </div>- </div>- }-<div class="row g-2 align-items-center">- <label class="form-label col-12 col-md-6 mb-0" for="userLanguage" l10nTranslate>Language</label>- <div class="col-12 col-md-6">- <select id="userLanguage" [(ngModel)]="language" class="form-select">- @for (l of languages; track $index) {- <option [ngValue]="l">{{ i18nLanguageText[l] }}</option>- }- </select>- </div>- </div>-- <div class="row g-2 align-items-center">- <label class="form-label col-12 col-md-6 mb-0" for="userNotification" l10nTranslate>Notification</label>+ <label class="form-label col-12 col-md-6 mb-0" for="userNotification" l10nTranslate>Channels</label><div class="col-12 col-md-6"><select id="userNotification"[ngModel]="user.notification"@@ -213,6 +211,36 @@</select></div></div>++ @if (store.isElectronApp()) {+ <div class="row g-0">+ <div class="col-12">+ <div class="card dialog-check-card dialog-check-card--interactive"+ [class.dialog-check-card--active]="user.preferences.useSystemNotifications"+ (click)="updateSystemNotificationsPreference(!user.preferences.useSystemNotifications)">+ <div class="card-body p-2">+ <div class="d-flex align-items-center cursor-pointer">+ <label for="useSystemNotifications" class="form-label me-auto text-nowrap" l10nTranslate>System display</label>+ <div class="d-flex align-items-center form-check form-switch ps-0 mb-0">+ <label class="form-check-label" for="useSystemNotifications" (click)="$event.stopPropagation()"></label>+ <input+ [ngModel]="user.preferences.useSystemNotifications"+ (ngModelChange)="updateSystemNotificationsPreference($event)"+ (click)="$event.stopPropagation()"+ class="form-check-input ms-2"+ id="useSystemNotifications"+ type="checkbox"+ role="button">+ </div>+ </div>+ <div class="text-muted fs-sm mt-2 px-1" l10nTranslate>+ Show notifications through the operating system instead of in the application.+ </div>+ </div>+ </div>+ </div>+ </div>+ }</div></div></div>@@ -268,7 +296,7 @@</div></div>- <div class="card dialog-tab-card flex-grow-1">+ <div class="card dialog-tab-card"><div class="card-body"><div class="text-muted text-uppercase fs-sm text-bold mb-2" l10nTranslate>Security</div><div class="d-flex flex-column gap-3">diff --git a/frontend/src/app/applications/users/components/user-account.component.ts b/frontend/src/app/applications/users/components/user-account.component.tsindex 46507792..179996a4 100644--- a/frontend/src/app/applications/users/components/user-account.component.ts+++ b/frontend/src/app/applications/users/components/user-account.component.ts@@ -216,6 +216,10 @@ export class UserAccountComponent implements OnInit, OnDestroy {this.userService.changePreferences({ editor }).subscribe()}+ updateSystemNotificationsPreference(useSystemNotifications: UserPreferences['useSystemNotifications']) {+ this.userService.changePreferences({ useSystemNotifications }).subscribe()+ }+async enable2Fa() {this.userService.init2Fa().subscribe({next: (init: TwoFaSetup) => {diff --git a/frontend/src/app/applications/users/user.service.ts b/frontend/src/app/applications/users/user.service.tsindex e67484b0..ac92a216 100644--- a/frontend/src/app/applications/users/user.service.ts+++ b/frontend/src/app/applications/users/user.service.ts@@ -249,7 +249,12 @@ export class UserService {const userId = this.user.idreturn this.http.patch<UserPreferences>(API_USERS_MY_PREFERENCES, patch).pipe(catchError((e: HttpErrorResponse) => {- const message = patch.theme !== undefined ? 'Unable to update theme preference' : 'Unable to update editor preference'+ const message =+ patch.theme !== undefined+ ? 'Unable to update theme preference'+ : patch.editor !== undefined+ ? 'Unable to update editor preference'+ : 'Unable to update notification preference'this.layout.sendNotification('error', 'Configuration', message, e)return EMPTY}),diff --git a/frontend/src/app/electron/constants/events.ts b/frontend/src/app/electron/constants/events.tsindex d22bc7f0..754adc06 100644--- a/frontend/src/app/electron/constants/events.ts+++ b/frontend/src/app/electron/constants/events.ts@@ -29,7 +29,8 @@ export const EVENT = {// tasks & notifications & chatsAPPLICATIONS: {MSG: 'applications-msg',- COUNTER: 'applications-counter'+ COUNTER: 'applications-counter',+ SYSTEM_NOTIFICATIONS: 'applications-system-notifications'},MISC: {DIALOG_OPEN: 'dialog-open',diff --git a/frontend/src/app/electron/electron.service.ts b/frontend/src/app/electron/electron.service.tsindex 72e67662..668a884f 100644--- a/frontend/src/app/electron/electron.service.ts+++ b/frontend/src/app/electron/electron.service.ts@@ -43,6 +43,10 @@ export class Electron {constructor() {this.store.isElectronApp.set(this.enabled)if (this.enabled) {+ this.store.user.subscribe((user) => {+ if (!user) return+ this.send(EVENT.APPLICATIONS.SYSTEM_NOTIFICATIONS, user.preferences?.useSystemNotifications ?? true)+ })effect(() => {const count = this.store.notifications().filter((n: NotificationModel) => !n.wasRead).lengththis.send(EVENT.APPLICATIONS.COUNTER, CLIENT_APP_COUNTER.NOTIFICATIONS, count)diff --git a/frontend/src/app/layout/layout.service.ts b/frontend/src/app/layout/layout.service.tsindex 136a9fa0..b5799238 100644--- a/frontend/src/app/layout/layout.service.ts+++ b/frontend/src/app/layout/layout.service.ts@@ -17,6 +17,7 @@ import { USER_LANGUAGE_AUTO } from '../applications/users/user.constants'import { getTheme } from '../common/utils/functions'import { EVENT } from '../electron/constants/events'import { Electron } from '../electron/electron.service'+import { StoreService } from '../store/store.service'import { BreadCrumbUrl } from './breadcrumb/breadcrumb.interfaces'import { AppWindow, TAB_GROUP, TAB_MENU, TabMenu, themeDark, themeLight } from './layout.interfaces'@@ -64,6 +65,7 @@ export class LayoutService {private readonly toastr = inject(ToastrService)private readonly contextMenu = inject<ContextMenuService<any>>(ContextMenuService)private readonly electron = inject(Electron)+ private readonly store = inject(StoreService)// Statesprivate readonly screenMediumSize = 767 // pxprivate readonly screenSmallSize = 576 // px@@ -229,13 +231,14 @@ export class LayoutService {e?: HttpErrorResponse,override: any = {}): ActiveToast<any> | void {+ const useSystemNotifications = this.electron.enabled && (this.store.user.getValue()?.preferences?.useSystemNotifications ?? true)if (type === 'error' && e) {const errorMessage = e.error? Array.isArray(e.error.message)? e.error.message.map((e: string) => this.translateString(e)).join(' & '): this.translateString(e.error.message): this.translateString(e.message || 'Unknown error !')- if (this.electron.enabled) {+ if (useSystemNotifications) {this.electron.sendMessage(this.translateString(title), `${this.translateString(message)} - ${errorMessage}`)} else {return this.toastr[type](@@ -248,7 +251,7 @@ export class LayoutService {)}}- if (this.electron.enabled) {+ if (useSystemNotifications) {this.electron.sendMessage(this.translateString(title), this.translateString(message))} else {return this.toastr[type](this.translateString(message), this.translateString(title), override)diff --git a/frontend/src/i18n/de.json b/frontend/src/i18n/de.jsonindex 20a83f8f..62cfae03 100644--- a/frontend/src/i18n/de.json+++ b/frontend/src/i18n/de.json@@ -740,6 +740,9 @@"stopping": "wird gestoppt","idle": "leerlauf","Preferences": "Einstellungen",+ "Channels": "Kanäle",+ "System display": "Systemanzeige",+ "Show notifications through the operating system instead of in the application.": "Benachrichtigungen über das Betriebssystem statt in der Anwendung anzeigen.","Theme": "Design","Auto": "Automatisch","Light": "Hell",diff --git a/frontend/src/i18n/es.json b/frontend/src/i18n/es.jsonindex 448b67fb..fa26dcd7 100644--- a/frontend/src/i18n/es.json+++ b/frontend/src/i18n/es.json@@ -740,6 +740,9 @@"stopping": "deteniendo","idle": "inactivo","Preferences": "Preferencias",+ "Channels": "Canales",+ "System display": "Visualización del sistema",+ "Show notifications through the operating system instead of in the application.": "Mostrar las notificaciones a través del sistema operativo en lugar de la aplicación.","Theme": "Tema","Auto": "Automático","Light": "Claro",diff --git a/frontend/src/i18n/fr.json b/frontend/src/i18n/fr.jsonindex 0d68b3fa..a8ebc751 100644--- a/frontend/src/i18n/fr.json+++ b/frontend/src/i18n/fr.json@@ -740,6 +740,9 @@"stopping": "arrêt en cours","idle": "inactif","Preferences": "Préférences",+ "Channels": "Canaux",+ "System display": "Affichage système",+ "Show notifications through the operating system instead of in the application.": "Afficher les notifications via le système d’exploitation plutôt que dans l’application.","Theme": "Thème","Auto": "Automatique","Light": "Clair",diff --git a/frontend/src/i18n/hi.json b/frontend/src/i18n/hi.jsonindex 80fa0c9e..df1aa71f 100644--- a/frontend/src/i18n/hi.json+++ b/frontend/src/i18n/hi.json@@ -740,6 +740,9 @@"stopping": "रोका जा रहा है","idle": "निष्क्रिय","Preferences": "वरीयताएँ",+ "Channels": "चैनल",+ "System display": "सिस्टम में प्रदर्शन",+ "Show notifications through the operating system instead of in the application.": "सूचनाएँ ऐप के बजाय ऑपरेटिंग सिस्टम के माध्यम से दिखाएँ।","Theme": "थीम","Auto": "स्वचालित","Light": "लाइट",diff --git a/frontend/src/i18n/it.json b/frontend/src/i18n/it.jsonindex d1157e98..b4acdabb 100644--- a/frontend/src/i18n/it.json+++ b/frontend/src/i18n/it.json@@ -740,6 +740,9 @@"stopping": "in arresto","idle": "inattivo","Preferences": "Preferenze",+ "Channels": "Canali",+ "System display": "Visualizzazione di sistema",+ "Show notifications through the operating system instead of in the application.": "Mostra le notifiche tramite il sistema operativo anziché nell'applicazione.","Theme": "Tema","Auto": "Automatico","Light": "Chiaro",diff --git a/frontend/src/i18n/ja.json b/frontend/src/i18n/ja.jsonindex 05416d5e..83508363 100644--- a/frontend/src/i18n/ja.json+++ b/frontend/src/i18n/ja.json@@ -740,6 +740,9 @@"stopping": "停止中","idle": "待機中","Preferences": "環境設定",+ "Channels": "チャネル",+ "System display": "システム表示",+ "Show notifications through the operating system instead of in the application.": "アプリ内ではなく、オペレーティングシステム経由で通知を表示します。","Theme": "テーマ","Auto": "自動","Light": "ライト",diff --git a/frontend/src/i18n/ko.json b/frontend/src/i18n/ko.jsonindex f2ada728..a126bbd0 100644--- a/frontend/src/i18n/ko.json+++ b/frontend/src/i18n/ko.json@@ -740,6 +740,9 @@"stopping": "중지 중","idle": "유휴","Preferences": "환경 설정",+ "Channels": "채널",+ "System display": "시스템 표시",+ "Show notifications through the operating system instead of in the application.": "애플리케이션 내부 대신 운영 체제를 통해 알림을 표시합니다.","Theme": "테마","Auto": "자동","Light": "라이트",diff --git a/frontend/src/i18n/nl.json b/frontend/src/i18n/nl.jsonindex a2473ec3..5d90ac59 100644--- a/frontend/src/i18n/nl.json+++ b/frontend/src/i18n/nl.json@@ -740,6 +740,9 @@"stopping": "bezig met stoppen","idle": "inactief","Preferences": "Voorkeuren",+ "Channels": "Kanalen",+ "System display": "Systeemweergave",+ "Show notifications through the operating system instead of in the application.": "Meldingen via het besturingssysteem weergeven in plaats van in de toepassing.","Theme": "Thema","Auto": "Automatisch","Light": "Licht",diff --git a/frontend/src/i18n/pl.json b/frontend/src/i18n/pl.jsonindex 3b184dc0..0a92a8e7 100644--- a/frontend/src/i18n/pl.json+++ b/frontend/src/i18n/pl.json@@ -740,6 +740,9 @@"stopping": "zatrzymywanie","idle": "bezczynny","Preferences": "Preferencje",+ "Channels": "Kanały",+ "System display": "Wyświetlanie systemowe",+ "Show notifications through the operating system instead of in the application.": "Wyświetlaj powiadomienia przez system operacyjny zamiast w aplikacji.","Theme": "Motyw","Auto": "Automatyczny","Light": "Jasny",diff --git a/frontend/src/i18n/pt-BR.json b/frontend/src/i18n/pt-BR.jsonindex c3d75b57..e52e4e21 100644--- a/frontend/src/i18n/pt-BR.json+++ b/frontend/src/i18n/pt-BR.json@@ -740,6 +740,9 @@"stopping": "parando","idle": "inativo","Preferences": "Preferências",+ "Channels": "Canais",+ "System display": "Exibição do sistema",+ "Show notifications through the operating system instead of in the application.": "Exibir notificações pelo sistema operacional em vez de no aplicativo.","Theme": "Tema","Auto": "Automático","Light": "Claro",diff --git a/frontend/src/i18n/pt.json b/frontend/src/i18n/pt.jsonindex c2c54c05..26ffa2a2 100644--- a/frontend/src/i18n/pt.json+++ b/frontend/src/i18n/pt.json@@ -740,6 +740,9 @@"stopping": "a parar","idle": "inativo","Preferences": "Preferências",+ "Channels": "Canais",+ "System display": "Apresentação do sistema",+ "Show notifications through the operating system instead of in the application.": "Mostrar notificações através do sistema operativo em vez de na aplicação.","Theme": "Tema","Auto": "Automático","Light": "Claro",diff --git a/frontend/src/i18n/ru.json b/frontend/src/i18n/ru.jsonindex 2f7f9e7d..ac36c569 100644--- a/frontend/src/i18n/ru.json+++ b/frontend/src/i18n/ru.json@@ -740,6 +740,9 @@"stopping": "останавливается","idle": "ожидание","Preferences": "Настройки",+ "Channels": "Каналы",+ "System display": "Отображение в системе",+ "Show notifications through the operating system instead of in the application.": "Показывать уведомления средствами операционной системы, а не в приложении.","Theme": "Тема","Auto": "Автоматически","Light": "Светлая",diff --git a/frontend/src/i18n/tr.json b/frontend/src/i18n/tr.jsonindex 4f77438c..5999b877 100644--- a/frontend/src/i18n/tr.json+++ b/frontend/src/i18n/tr.json@@ -740,6 +740,9 @@"stopping": "durduruluyor","idle": "boşta","Preferences": "Tercihler",+ "Channels": "Kanallar",+ "System display": "Sistem görünümü",+ "Show notifications through the operating system instead of in the application.": "Bildirimleri uygulama yerine işletim sistemi üzerinden göster.","Theme": "Tema","Auto": "Otomatik","Light": "Açık",diff --git a/frontend/src/i18n/zh.json b/frontend/src/i18n/zh.jsonindex 04b616e1..7b45bc0a 100644--- a/frontend/src/i18n/zh.json+++ b/frontend/src/i18n/zh.json@@ -740,6 +740,9 @@"stopping": "停止中","idle": "空闲","Preferences": "偏好设置",+ "Channels": "渠道",+ "System display": "系统显示",+ "Show notifications through the operating system instead of in the application.": "通过操作系统而非应用内显示通知。","Theme": "主题","Auto": "自动","Light": "浅色",