]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/commitdiff
Fix notification settings
authorChocobozzz <me@florianbigard.com>
Wed, 24 May 2023 15:22:40 +0000 (17:22 +0200)
committerChocobozzz <me@florianbigard.com>
Wed, 24 May 2023 15:22:40 +0000 (17:22 +0200)
client/src/app/+my-account/my-account-settings/my-account-notification-preferences/my-account-notification-preferences.component.html
client/src/app/+my-account/my-account-settings/my-account-notification-preferences/my-account-notification-preferences.component.ts
client/src/app/+videos/+video-watch/shared/recommendations/recommended-videos.component.html
client/src/app/menu/menu.component.html
client/src/app/shared/shared-forms/input-switch.component.ts

index 46f5e5d6b1273f97001930aba2247471ebbd65e1..2af9d576ac28d3ae1766167c306f1be640e91eec 100644 (file)
@@ -12,6 +12,7 @@
 
         <div>
           <my-input-switch
+            [inputName]="'web-notification-' + notificationType"
             [(ngModel)]="webNotifications[notificationType]"
             (ngModelChange)="updateWebSetting(notificationType, webNotifications[notificationType])"
           ></my-input-switch>
@@ -19,6 +20,7 @@
 
         <div *ngIf="emailEnabled">
           <my-input-switch
+            [inputName]="'email-notification-' + notificationType"
             [(ngModel)]="emailNotifications[notificationType]"
             (ngModelChange)="updateEmailSetting(notificationType, emailNotifications[notificationType])"
           ></my-input-switch>
index 8faba676e928f9e95dd4b3fcd008808b6433144f..2adc276a91f3f8219a3c946a6b7d394b219e9b03 100644 (file)
@@ -3,6 +3,7 @@ import { Subject } from 'rxjs'
 import { Component, Input, OnInit } from '@angular/core'
 import { Notifier, ServerService, User } from '@app/core'
 import { UserNotificationService } from '@app/shared/shared-main'
+import { objectKeysTyped } from '@shared/core-utils'
 import { UserNotificationSetting, UserNotificationSettingValue, UserRight } from '@shared/models'
 
 @Component({
@@ -141,7 +142,7 @@ export class MyAccountNotificationPreferencesComponent implements OnInit {
   }
 
   private loadNotificationSettings () {
-    for (const key of Object.keys(this.user.notificationSettings) as (keyof UserNotificationSetting)[]) {
+    for (const key of objectKeysTyped(this.user.notificationSettings)) {
       const value = this.user.notificationSettings[key]
       this.emailNotifications[key] = !!(value & UserNotificationSettingValue.EMAIL)
 
index 2bbe26c96db0e6cc2eb93f570396226c55ac5c53..59ee57b16df2c6e0412d8999b61800ca34ebe754 100644 (file)
@@ -7,7 +7,7 @@
         [ngbTooltip]="autoPlayNextVideoTooltip" placement="bottom-right auto"
       >
         <span i18n>AUTOPLAY</span>
-        <my-input-switch  class="small" [(ngModel)]="autoPlayNextVideo" (ngModelChange)="switchAutoPlayNextVideo()"></my-input-switch>
+        <my-input-switch class="small" inputName="autoplay-next-video" [(ngModel)]="autoPlayNextVideo" (ngModelChange)="switchAutoPlayNextVideo()"></my-input-switch>
       </div>
     </div>
 
index 10b3f15d906aa0382817c3df554af15f3dc45028..c23bb4f5bc4c24d1bb280958301f073a9ae94e66 100644 (file)
@@ -61,7 +61,7 @@
                 <my-global-icon iconName="p2p" aria-hidden="true"></my-global-icon>
                 <ng-container i18n>Help share videos</ng-container>
 
-                <my-input-switch class="ms-auto" [checked]="user.p2pEnabled"></my-input-switch>
+                <my-input-switch inputName="p2p-enabled" class="ms-auto" [checked]="user.p2pEnabled"></my-input-switch>
               </button>
 
               <div class="dropdown-divider"></div>
index abb96de6244cf3bfa64c02023610b4cb97e10882..f340ce81e85e6e3aeb606bc15436edf78498662b 100644 (file)
@@ -20,6 +20,7 @@ export class InputSwitchComponent implements ControlValueAccessor {
   propagateChange = (_: any) => { /* empty */ }
 
   writeValue (checked: boolean) {
+    console.log(checked)
     this.checked = checked
   }
 
@@ -32,6 +33,7 @@ export class InputSwitchComponent implements ControlValueAccessor {
   }
 
   update () {
+    console.log(this.checked)
     this.checked = !this.checked
     this.propagateChange(this.checked)
   }