forked from CIT/Vmeda.Online
		
	MOBILE-2497 notifications: Toggle all notifications in affirmative way
This commit is contained in:
		
							parent
							
								
									bcb41032f5
								
							
						
					
					
						commit
						5b6ea2d25b
					
				| @ -24,8 +24,8 @@ | |||||||
|         <ng-container *ngIf="notifPrefsEnabled"> |         <ng-container *ngIf="notifPrefsEnabled"> | ||||||
|             <ion-card> |             <ion-card> | ||||||
|                 <ion-item text-wrap *ngIf="preferences"> |                 <ion-item text-wrap *ngIf="preferences"> | ||||||
|                     <ion-label>{{ 'core.settings.disableall' | translate }}</ion-label> |                     <ion-label>{{ 'addon.notifications.notifications' | translate }}</ion-label> | ||||||
|                     <ion-toggle [(ngModel)]="preferences.disableall" (ionChange)="disableAll(preferences.disableall)"></ion-toggle> |                     <ion-toggle [(ngModel)]="preferences.enableall" (ionChange)="enableAll(preferences.enableall)"></ion-toggle> | ||||||
|                 </ion-item> |                 </ion-item> | ||||||
|                 <ion-item text-wrap *ngIf="canChangeSound"> |                 <ion-item text-wrap *ngIf="canChangeSound"> | ||||||
|                     <ion-label>{{ 'addon.notifications.playsound' | translate }}</ion-label> |                     <ion-label>{{ 'addon.notifications.playsound' | translate }}</ion-label> | ||||||
| @ -53,25 +53,25 @@ | |||||||
|                     <ion-row text-wrap class="hidden-phone" align-items-center> |                     <ion-row text-wrap class="hidden-phone" align-items-center> | ||||||
|                         <ion-col margin-horizontal>{{ notification.displayname }}</ion-col> |                         <ion-col margin-horizontal>{{ notification.displayname }}</ion-col> | ||||||
|                         <ion-col col-2 text-center *ngFor="let state of ['loggedin', 'loggedoff']"> |                         <ion-col col-2 text-center *ngFor="let state of ['loggedin', 'loggedoff']"> | ||||||
|                             <!-- If notifications not disabled, show toggle. --> |                             <!-- If notifications enabled, show toggle. --> | ||||||
|                             <ion-spinner [hidden]="preferences.disableall || !(notification.currentProcessor[state] && notification.currentProcessor[state].updating)"></ion-spinner> |                             <ion-spinner [hidden]="!preferences.enableall || !(notification.currentProcessor[state] && notification.currentProcessor[state].updating)"></ion-spinner> | ||||||
|                             <ion-toggle *ngIf="!preferences.disableall && !notification.currentProcessor.locked" [(ngModel)]="notification.currentProcessor[state].checked" (ionChange)="changePreference(notification, state)" [disabled]="notification.currentProcessor[state].updating"> |                             <ion-toggle *ngIf="preferences.enableall && !notification.currentProcessor.locked" [(ngModel)]="notification.currentProcessor[state].checked" (ionChange)="changePreference(notification, state)" [disabled]="notification.currentProcessor[state].updating"> | ||||||
|                             </ion-toggle> |                             </ion-toggle> | ||||||
|                             <div padding class="text-gray" *ngIf="!preferences.disableall && notification.currentProcessor.locked">{{'core.settings.locked' | translate }}</div> |                             <div padding class="text-gray" *ngIf="preferences.enableall && notification.currentProcessor.locked">{{'core.settings.locked' | translate }}</div> | ||||||
|                             <!-- If notifications are disabled, show "Disabled" instead of toggle. --> |                             <!-- If notifications are disabled, show "Disabled" instead of toggle. --> | ||||||
|                             <span *ngIf="preferences.disableall">{{ 'core.settings.disabled' | translate }}</span> |                             <span *ngIf="!preferences.enableall">{{ 'core.settings.disabled' | translate }}</span> | ||||||
|                         </ion-col> |                         </ion-col> | ||||||
|                     </ion-row> |                     </ion-row> | ||||||
|                     <!-- Phone view --> |                     <!-- Phone view --> | ||||||
|                     <ion-list-header text-wrap no-margin class="hidden-tablet">{{ notification.displayname }}</ion-list-header> |                     <ion-list-header text-wrap no-margin class="hidden-tablet">{{ notification.displayname }}</ion-list-header> | ||||||
|                     <!-- If notifications not disabled, show toggles. If notifications are disabled, show "Disabled" instead of toggle. --> |                     <!-- If notifications enabled, show toggles. If notifications are disabled, show "Disabled" instead of toggle. --> | ||||||
|                     <ion-item *ngFor="let state of ['loggedin', 'loggedoff']" text-wrap class="hidden-tablet"> |                     <ion-item *ngFor="let state of ['loggedin', 'loggedoff']" text-wrap class="hidden-tablet"> | ||||||
|                         <ion-label>{{ 'core.settings.' + state | translate }}</ion-label> |                         <ion-label>{{ 'core.settings.' + state | translate }}</ion-label> | ||||||
|                         <ion-spinner item-end *ngIf="!preferences.disableall && (notification.currentProcessor[state] && notification.currentProcessor[state].updating)"></ion-spinner> |                         <ion-spinner item-end *ngIf="preferences.enableall && (notification.currentProcessor[state] && notification.currentProcessor[state].updating)"></ion-spinner> | ||||||
|                         <ion-toggle item-end *ngIf="!preferences.disableall && !notification.currentProcessor.locked" [(ngModel)]="notification.currentProcessor[state].checked" (ionChange)="changePreference(notification, state)" [disabled]="notification.currentProcessor[state].updating"> |                         <ion-toggle item-end *ngIf="preferences.enableall && !notification.currentProcessor.locked" [(ngModel)]="notification.currentProcessor[state].checked" (ionChange)="changePreference(notification, state)" [disabled]="notification.currentProcessor[state].updating"> | ||||||
|                         </ion-toggle> |                         </ion-toggle> | ||||||
|                         <ion-note item-end *ngIf="!preferences.disableall && notification.currentProcessor.locked">{{'core.settings.locked' | translate }}</ion-note> |                         <ion-note item-end *ngIf="preferences.enableall && notification.currentProcessor.locked">{{'core.settings.locked' | translate }}</ion-note> | ||||||
|                         <ion-note item-end *ngIf="preferences.disableall">{{ 'core.settings.disabled' | translate }}</ion-note> |                         <ion-note item-end *ngIf="!preferences.enableall">{{ 'core.settings.disabled' | translate }}</ion-note> | ||||||
|                     </ion-item> |                     </ion-item> | ||||||
|                 </ng-container> |                 </ng-container> | ||||||
|             </ion-card> |             </ion-card> | ||||||
|  | |||||||
| @ -96,7 +96,7 @@ export class AddonNotificationsSettingsPage implements OnDestroy { | |||||||
|                 return Promise.reject('No processor found'); |                 return Promise.reject('No processor found'); | ||||||
|             } |             } | ||||||
| 
 | 
 | ||||||
|             preferences.disableall = !!preferences.disableall; // Convert to boolean.
 |             preferences.enableall = !preferences.disableall; | ||||||
|             this.preferences = preferences; |             this.preferences = preferences; | ||||||
|             this.loadProcessor(this.currentProcessor); |             this.loadProcessor(this.currentProcessor); | ||||||
| 
 | 
 | ||||||
| @ -230,17 +230,17 @@ export class AddonNotificationsSettingsPage implements OnDestroy { | |||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     /** |     /** | ||||||
|      * Disable all notifications changed. |      * Enable all notifications changed. | ||||||
|      */ |      */ | ||||||
|     disableAll(disable: boolean): void { |     enableAll(enable: boolean): void { | ||||||
|         const modal = this.domUtils.showModalLoading('core.sending', true); |         const modal = this.domUtils.showModalLoading('core.sending', true); | ||||||
|         this.userProvider.updateUserPreferences([], disable).then(() => { |         this.userProvider.updateUserPreferences([], !enable).then(() => { | ||||||
|             // Update the preferences since they were modified.
 |             // Update the preferences since they were modified.
 | ||||||
|             this.updatePreferencesAfterDelay(); |             this.updatePreferencesAfterDelay(); | ||||||
|         }).catch((message) => { |         }).catch((message) => { | ||||||
|             // Show error and revert change.
 |             // Show error and revert change.
 | ||||||
|             this.domUtils.showErrorModal(message); |             this.domUtils.showErrorModal(message); | ||||||
|             this.preferences.disableall = !this.preferences.disableall; |             this.preferences.enableall = !this.preferences.enableall; | ||||||
|         }).finally(() => { |         }).finally(() => { | ||||||
|             modal.dismiss(); |             modal.dismiss(); | ||||||
|         }); |         }); | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user