Merge pull request #4137 from dpalou/MOBILE-4633
MOBILE-4633 message: Improve handle no permission errormain
commit
21f785e4c1
|
@ -29,6 +29,14 @@
|
||||||
</ion-list>
|
</ion-list>
|
||||||
</ion-card>
|
</ion-card>
|
||||||
|
|
||||||
|
@if (warningMessage()) {
|
||||||
|
<ion-card class="core-warning-card ion-margin-top">
|
||||||
|
<ion-item>
|
||||||
|
<ion-icon name="fas-triangle-exclamation" slot="start" aria-hidden="true" />
|
||||||
|
<ion-label>{{ warningMessage() }}</ion-label>
|
||||||
|
</ion-item>
|
||||||
|
</ion-card>
|
||||||
|
} @else {
|
||||||
<!-- Contactable privacy. -->
|
<!-- Contactable privacy. -->
|
||||||
<ion-card>
|
<ion-card>
|
||||||
<ion-item *ngIf="!advancedContactable" class="ion-text-wrap">
|
<ion-item *ngIf="!advancedContactable" class="ion-text-wrap">
|
||||||
|
@ -72,6 +80,7 @@
|
||||||
<ng-container *ngTemplateOutlet="settings; context: {preferences: preferences}" />
|
<ng-container *ngTemplateOutlet="settings; context: {preferences: preferences}" />
|
||||||
</ng-container>
|
</ng-container>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
|
}
|
||||||
</core-loading>
|
</core-loading>
|
||||||
</ion-content>
|
</ion-content>
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
import { Component, OnDestroy, OnInit } from '@angular/core';
|
import { Component, OnDestroy, OnInit, signal } from '@angular/core';
|
||||||
import {
|
import {
|
||||||
AddonMessagesProvider, AddonMessagesMessagePreferences,
|
AddonMessagesProvider, AddonMessagesMessagePreferences,
|
||||||
AddonMessagesMessagePreferencesNotification,
|
AddonMessagesMessagePreferencesNotification,
|
||||||
|
@ -27,6 +27,7 @@ import { CoreDomUtils } from '@services/utils/dom';
|
||||||
import { CoreConstants } from '@/core/constants';
|
import { CoreConstants } from '@/core/constants';
|
||||||
import { AddonNotificationsPreferencesNotificationProcessorState } from '@addons/notifications/services/notifications';
|
import { AddonNotificationsPreferencesNotificationProcessorState } from '@addons/notifications/services/notifications';
|
||||||
import { CorePlatform } from '@services/platform';
|
import { CorePlatform } from '@services/platform';
|
||||||
|
import { CoreTextUtils } from '@services/utils/text';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Page that displays the messages settings page.
|
* Page that displays the messages settings page.
|
||||||
|
@ -49,6 +50,7 @@ export class AddonMessagesSettingsPage implements OnInit, OnDestroy {
|
||||||
siteValue = AddonMessagesProvider.MESSAGE_PRIVACY_SITE;
|
siteValue = AddonMessagesProvider.MESSAGE_PRIVACY_SITE;
|
||||||
groupMessagingEnabled = false;
|
groupMessagingEnabled = false;
|
||||||
sendOnEnter = false;
|
sendOnEnter = false;
|
||||||
|
warningMessage = signal<string | undefined>(undefined);
|
||||||
|
|
||||||
protected loggedInOffLegacyMode = false;
|
protected loggedInOffLegacyMode = false;
|
||||||
protected previousContactableValue?: number | boolean;
|
protected previousContactableValue?: number | boolean;
|
||||||
|
@ -106,7 +108,14 @@ export class AddonMessagesSettingsPage implements OnInit, OnDestroy {
|
||||||
this.preferences = preferences;
|
this.preferences = preferences;
|
||||||
this.contactablePrivacy = preferences.blocknoncontacts;
|
this.contactablePrivacy = preferences.blocknoncontacts;
|
||||||
this.previousContactableValue = this.contactablePrivacy;
|
this.previousContactableValue = this.contactablePrivacy;
|
||||||
|
this.warningMessage.set(undefined);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
if (error.errorcode === 'nopermissions') {
|
||||||
|
this.warningMessage.set(CoreTextUtils.getErrorMessageFromError(error));
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
CoreDomUtils.showErrorModal(error);
|
CoreDomUtils.showErrorModal(error);
|
||||||
} finally {
|
} finally {
|
||||||
this.preferencesLoaded = true;
|
this.preferencesLoaded = true;
|
||||||
|
|
|
@ -20,6 +20,14 @@
|
||||||
<ion-refresher-content pullingText="{{ 'core.pulltorefresh' | translate }}" />
|
<ion-refresher-content pullingText="{{ 'core.pulltorefresh' | translate }}" />
|
||||||
</ion-refresher>
|
</ion-refresher>
|
||||||
<core-loading [hideUntil]="preferencesLoaded">
|
<core-loading [hideUntil]="preferencesLoaded">
|
||||||
|
@if (warningMessage()) {
|
||||||
|
<ion-card class="core-warning-card ion-margin-top">
|
||||||
|
<ion-item>
|
||||||
|
<ion-icon name="fas-triangle-exclamation" slot="start" aria-hidden="true" />
|
||||||
|
<ion-label>{{ warningMessage() }}</ion-label>
|
||||||
|
</ion-item>
|
||||||
|
</ion-card>
|
||||||
|
} @else {
|
||||||
<ion-card>
|
<ion-card>
|
||||||
<ion-item class="ion-text-wrap" *ngIf="preferences">
|
<ion-item class="ion-text-wrap" *ngIf="preferences">
|
||||||
<ion-toggle [(ngModel)]="preferences.enableall" (ngModelChange)="enableAll(preferences.enableall)">
|
<ion-toggle [(ngModel)]="preferences.enableall" (ngModelChange)="enableAll(preferences.enableall)">
|
||||||
|
@ -52,6 +60,7 @@
|
||||||
<ng-container *ngTemplateOutlet="settings; context: {preferences: preferences}" />
|
<ng-container *ngTemplateOutlet="settings; context: {preferences: preferences}" />
|
||||||
</ng-container>
|
</ng-container>
|
||||||
</ion-card>
|
</ion-card>
|
||||||
|
}
|
||||||
</core-loading>
|
</core-loading>
|
||||||
|
|
||||||
</ion-content>
|
</ion-content>
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
import { Component, OnInit, OnDestroy } from '@angular/core';
|
import { Component, OnInit, OnDestroy, signal } from '@angular/core';
|
||||||
|
|
||||||
import { CoreConfig } from '@services/config';
|
import { CoreConfig } from '@services/config';
|
||||||
import { CoreLocalNotifications } from '@services/local-notifications';
|
import { CoreLocalNotifications } from '@services/local-notifications';
|
||||||
|
@ -39,6 +39,7 @@ import { CoreNavigator } from '@services/navigator';
|
||||||
import { CoreTime } from '@singletons/time';
|
import { CoreTime } from '@singletons/time';
|
||||||
import { CoreAnalytics, CoreAnalyticsEventType } from '@services/analytics';
|
import { CoreAnalytics, CoreAnalyticsEventType } from '@services/analytics';
|
||||||
import { Translate } from '@singletons';
|
import { Translate } from '@singletons';
|
||||||
|
import { CoreTextUtils } from '@services/utils/text';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Page that displays notifications settings.
|
* Page that displays notifications settings.
|
||||||
|
@ -58,6 +59,7 @@ export class AddonNotificationsSettingsPage implements OnInit, OnDestroy {
|
||||||
canChangeSound: boolean;
|
canChangeSound: boolean;
|
||||||
processorHandlers: AddonMessageOutputHandlerData[] = [];
|
processorHandlers: AddonMessageOutputHandlerData[] = [];
|
||||||
loggedInOffLegacyMode = false;
|
loggedInOffLegacyMode = false;
|
||||||
|
warningMessage = signal<string | undefined>(undefined);
|
||||||
|
|
||||||
protected updateTimeout?: number;
|
protected updateTimeout?: number;
|
||||||
protected logView: () => void;
|
protected logView: () => void;
|
||||||
|
@ -99,6 +101,8 @@ export class AddonNotificationsSettingsPage implements OnInit, OnDestroy {
|
||||||
try {
|
try {
|
||||||
const preferences = await AddonNotifications.getNotificationPreferences();
|
const preferences = await AddonNotifications.getNotificationPreferences();
|
||||||
|
|
||||||
|
this.warningMessage.set(undefined);
|
||||||
|
|
||||||
// Initialize current processor. Load "Mobile" (airnotifier) if available.
|
// Initialize current processor. Load "Mobile" (airnotifier) if available.
|
||||||
let currentProcessor = preferences.processors.find((processor) => processor.name == this.currentProcessorName);
|
let currentProcessor = preferences.processors.find((processor) => processor.name == this.currentProcessorName);
|
||||||
if (!currentProcessor) {
|
if (!currentProcessor) {
|
||||||
|
@ -116,6 +120,12 @@ export class AddonNotificationsSettingsPage implements OnInit, OnDestroy {
|
||||||
|
|
||||||
this.logView();
|
this.logView();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
if (error.errorcode === 'nopermissions') {
|
||||||
|
this.warningMessage.set(CoreTextUtils.getErrorMessageFromError(error));
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
CoreDomUtils.showErrorModal(error);
|
CoreDomUtils.showErrorModal(error);
|
||||||
} finally {
|
} finally {
|
||||||
this.preferencesLoaded = true;
|
this.preferencesLoaded = true;
|
||||||
|
|
Loading…
Reference in New Issue