commit
5602e6eeb4
|
@ -141,8 +141,8 @@ export class AddonMessagesGroupConversationsPage implements OnInit, OnDestroy {
|
||||||
conversation.unreadcount = 0;
|
conversation.unreadcount = 0;
|
||||||
|
|
||||||
// Conversations changed, invalidate them and refresh unread counts.
|
// Conversations changed, invalidate them and refresh unread counts.
|
||||||
this.messagesProvider.invalidateConversations();
|
this.messagesProvider.invalidateConversations(this.siteId);
|
||||||
this.messagesProvider.refreshUnreadConversationCounts();
|
this.messagesProvider.refreshUnreadConversationCounts(this.siteId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, this.siteId);
|
}, this.siteId);
|
||||||
|
@ -251,7 +251,7 @@ export class AddonMessagesGroupConversationsPage implements OnInit, OnDestroy {
|
||||||
const promises = [];
|
const promises = [];
|
||||||
|
|
||||||
promises.push(this.fetchConversationCounts());
|
promises.push(this.fetchConversationCounts());
|
||||||
promises.push(this.messagesProvider.getContactRequestsCount()); // View updated by the event observer.
|
promises.push(this.messagesProvider.getContactRequestsCount(this.siteId)); // View updated by the event observer.
|
||||||
|
|
||||||
return Promise.all(promises).then(() => {
|
return Promise.all(promises).then(() => {
|
||||||
if (typeof this.favourites.expanded == 'undefined') {
|
if (typeof this.favourites.expanded == 'undefined') {
|
||||||
|
@ -323,7 +323,8 @@ export class AddonMessagesGroupConversationsPage implements OnInit, OnDestroy {
|
||||||
|
|
||||||
promises.push(this.fetchConversationCounts());
|
promises.push(this.fetchConversationCounts());
|
||||||
if (refreshUnreadCounts) {
|
if (refreshUnreadCounts) {
|
||||||
promises.push(this.messagesProvider.refreshUnreadConversationCounts()); // View updated by the event observer.
|
// View updated by event observer.
|
||||||
|
promises.push(this.messagesProvider.refreshUnreadConversationCounts(this.siteId));
|
||||||
}
|
}
|
||||||
|
|
||||||
return Promise.all(promises);
|
return Promise.all(promises);
|
||||||
|
@ -347,10 +348,10 @@ export class AddonMessagesGroupConversationsPage implements OnInit, OnDestroy {
|
||||||
offlineMessages;
|
offlineMessages;
|
||||||
|
|
||||||
// Get the conversations and, if needed, the offline messages. Always try to get the latest data.
|
// Get the conversations and, if needed, the offline messages. Always try to get the latest data.
|
||||||
promises.push(this.messagesProvider.invalidateConversations().catch(() => {
|
promises.push(this.messagesProvider.invalidateConversations(this.siteId).catch(() => {
|
||||||
// Shouldn't happen.
|
// Shouldn't happen.
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
return this.messagesProvider.getConversations(option.type, option.favourites, limitFrom);
|
return this.messagesProvider.getConversations(option.type, option.favourites, limitFrom, this.siteId);
|
||||||
}).then((result) => {
|
}).then((result) => {
|
||||||
data = result;
|
data = result;
|
||||||
}));
|
}));
|
||||||
|
@ -362,7 +363,8 @@ export class AddonMessagesGroupConversationsPage implements OnInit, OnDestroy {
|
||||||
|
|
||||||
promises.push(this.fetchConversationCounts());
|
promises.push(this.fetchConversationCounts());
|
||||||
if (refreshUnreadCounts) {
|
if (refreshUnreadCounts) {
|
||||||
promises.push(this.messagesProvider.refreshUnreadConversationCounts()); // View updated by the event observer.
|
// View updated by the event observer.
|
||||||
|
promises.push(this.messagesProvider.refreshUnreadConversationCounts(this.siteId));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -392,10 +394,10 @@ export class AddonMessagesGroupConversationsPage implements OnInit, OnDestroy {
|
||||||
*/
|
*/
|
||||||
protected fetchConversationCounts(): Promise<void> {
|
protected fetchConversationCounts(): Promise<void> {
|
||||||
// Always try to get the latest data.
|
// Always try to get the latest data.
|
||||||
return this.messagesProvider.invalidateConversationCounts().catch(() => {
|
return this.messagesProvider.invalidateConversationCounts(this.siteId).catch(() => {
|
||||||
// Shouldn't happen.
|
// Shouldn't happen.
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
return this.messagesProvider.getConversationCounts();
|
return this.messagesProvider.getConversationCounts(this.siteId);
|
||||||
}).then((counts) => {
|
}).then((counts) => {
|
||||||
this.favourites.count = counts.favourites;
|
this.favourites.count = counts.favourites;
|
||||||
this.individual.count = counts.individual;
|
this.individual.count = counts.individual;
|
||||||
|
@ -610,7 +612,7 @@ export class AddonMessagesGroupConversationsPage implements OnInit, OnDestroy {
|
||||||
refreshData(refresher?: any, refreshUnreadCounts: boolean = true): Promise<any> {
|
refreshData(refresher?: any, refreshUnreadCounts: boolean = true): Promise<any> {
|
||||||
// Don't invalidate conversations and so, they always try to get latest data.
|
// Don't invalidate conversations and so, they always try to get latest data.
|
||||||
const promises = [
|
const promises = [
|
||||||
this.messagesProvider.invalidateContactRequestsCountCache()
|
this.messagesProvider.invalidateContactRequestsCountCache(this.siteId)
|
||||||
];
|
];
|
||||||
|
|
||||||
return this.utils.allPromises(promises).finally(() => {
|
return this.utils.allPromises(promises).finally(() => {
|
||||||
|
|
|
@ -245,7 +245,7 @@ export class AddonModLessonPlayerPage implements OnInit, OnDestroy {
|
||||||
|
|
||||||
if (info.preventaccessreasons && info.preventaccessreasons.length) {
|
if (info.preventaccessreasons && info.preventaccessreasons.length) {
|
||||||
// If it's a password protected lesson and we have the password, allow playing it.
|
// If it's a password protected lesson and we have the password, allow playing it.
|
||||||
const preventReason = this.lessonProvider.getPreventAccessReason(info, !!this.password);
|
const preventReason = this.lessonProvider.getPreventAccessReason(info, !!this.password, this.review);
|
||||||
if (preventReason) {
|
if (preventReason) {
|
||||||
// Lesson cannot be played, show message and go back.
|
// Lesson cannot be played, show message and go back.
|
||||||
return Promise.reject(preventReason.message);
|
return Promise.reject(preventReason.message);
|
||||||
|
|
|
@ -2367,9 +2367,10 @@ export class AddonModLessonProvider {
|
||||||
*
|
*
|
||||||
* @param {any} info Lesson access info.
|
* @param {any} info Lesson access info.
|
||||||
* @param {boolean} [ignorePassword] Whether password protected reason should be ignored (user already entered the password).
|
* @param {boolean} [ignorePassword] Whether password protected reason should be ignored (user already entered the password).
|
||||||
|
* @param {boolean} [isReview] Whether user is reviewing a retake.
|
||||||
* @return {any} Prevent access reason.
|
* @return {any} Prevent access reason.
|
||||||
*/
|
*/
|
||||||
getPreventAccessReason(info: any, ignorePassword?: boolean): any {
|
getPreventAccessReason(info: any, ignorePassword?: boolean, isReview?: boolean): any {
|
||||||
let result;
|
let result;
|
||||||
|
|
||||||
if (info && info.preventaccessreasons) {
|
if (info && info.preventaccessreasons) {
|
||||||
|
@ -2384,6 +2385,8 @@ export class AddonModLessonProvider {
|
||||||
// Treat password before all other reasons.
|
// Treat password before all other reasons.
|
||||||
result = entry;
|
result = entry;
|
||||||
}
|
}
|
||||||
|
} else if (entry.reason == 'noretake' && isReview) {
|
||||||
|
// Ignore noretake error when reviewing.
|
||||||
} else if (!result) {
|
} else if (!result) {
|
||||||
// Rest of cases, just return any of them.
|
// Rest of cases, just return any of them.
|
||||||
result = entry;
|
result = entry;
|
||||||
|
|
|
@ -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 { Injectable } from '@angular/core';
|
import { Injectable, NgZone } from '@angular/core';
|
||||||
import { NavController } from 'ionic-angular';
|
import { NavController } from 'ionic-angular';
|
||||||
import { TranslateService } from '@ngx-translate/core';
|
import { TranslateService } from '@ngx-translate/core';
|
||||||
import { CoreAppProvider } from '@providers/app';
|
import { CoreAppProvider } from '@providers/app';
|
||||||
|
@ -40,7 +40,7 @@ export class CoreContentLinksHelperProvider {
|
||||||
private contentLinksDelegate: CoreContentLinksDelegate, private appProvider: CoreAppProvider,
|
private contentLinksDelegate: CoreContentLinksDelegate, private appProvider: CoreAppProvider,
|
||||||
private domUtils: CoreDomUtilsProvider, private urlUtils: CoreUrlUtilsProvider, private translate: TranslateService,
|
private domUtils: CoreDomUtilsProvider, private urlUtils: CoreUrlUtilsProvider, private translate: TranslateService,
|
||||||
private initDelegate: CoreInitDelegate, eventsProvider: CoreEventsProvider, private textUtils: CoreTextUtilsProvider,
|
private initDelegate: CoreInitDelegate, eventsProvider: CoreEventsProvider, private textUtils: CoreTextUtilsProvider,
|
||||||
private sitePluginsProvider: CoreSitePluginsProvider) {
|
private sitePluginsProvider: CoreSitePluginsProvider, private zone: NgZone) {
|
||||||
this.logger = logger.getInstance('CoreContentLinksHelperProvider');
|
this.logger = logger.getInstance('CoreContentLinksHelperProvider');
|
||||||
|
|
||||||
// Listen for app launched URLs. If we receive one, check if it's a content link.
|
// Listen for app launched URLs. If we receive one, check if it's a content link.
|
||||||
|
@ -91,11 +91,15 @@ export class CoreContentLinksHelperProvider {
|
||||||
*/
|
*/
|
||||||
goInSite(navCtrl: NavController, pageName: string, pageParams: any, siteId?: string): void {
|
goInSite(navCtrl: NavController, pageName: string, pageParams: any, siteId?: string): void {
|
||||||
siteId = siteId || this.sitesProvider.getCurrentSiteId();
|
siteId = siteId || this.sitesProvider.getCurrentSiteId();
|
||||||
|
|
||||||
|
// Execute the code in the Angular zone, so change detection doesn't stop working.
|
||||||
|
this.zone.run(() => {
|
||||||
if (navCtrl && siteId == this.sitesProvider.getCurrentSiteId()) {
|
if (navCtrl && siteId == this.sitesProvider.getCurrentSiteId()) {
|
||||||
navCtrl.push(pageName, pageParams);
|
navCtrl.push(pageName, pageParams);
|
||||||
} else {
|
} else {
|
||||||
this.loginHelper.redirect(pageName, pageParams, siteId);
|
this.loginHelper.redirect(pageName, pageParams, siteId);
|
||||||
}
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -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 { Injectable } from '@angular/core';
|
import { Injectable, NgZone } from '@angular/core';
|
||||||
import { Platform, Alert, AlertController } from 'ionic-angular';
|
import { Platform, Alert, AlertController } from 'ionic-angular';
|
||||||
import { LocalNotifications, ILocalNotification } from '@ionic-native/local-notifications';
|
import { LocalNotifications, ILocalNotification } from '@ionic-native/local-notifications';
|
||||||
import { Push } from '@ionic-native/push';
|
import { Push } from '@ionic-native/push';
|
||||||
|
@ -105,7 +105,7 @@ export class CoreLocalNotificationsProvider {
|
||||||
constructor(logger: CoreLoggerProvider, private localNotifications: LocalNotifications, private platform: Platform,
|
constructor(logger: CoreLoggerProvider, private localNotifications: LocalNotifications, private platform: Platform,
|
||||||
private appProvider: CoreAppProvider, private utils: CoreUtilsProvider, private configProvider: CoreConfigProvider,
|
private appProvider: CoreAppProvider, private utils: CoreUtilsProvider, private configProvider: CoreConfigProvider,
|
||||||
private textUtils: CoreTextUtilsProvider, private translate: TranslateService, private alertCtrl: AlertController,
|
private textUtils: CoreTextUtilsProvider, private translate: TranslateService, private alertCtrl: AlertController,
|
||||||
eventsProvider: CoreEventsProvider, private push: Push) {
|
eventsProvider: CoreEventsProvider, private push: Push, private zone: NgZone) {
|
||||||
|
|
||||||
this.logger = logger.getInstance('CoreLocalNotificationsProvider');
|
this.logger = logger.getInstance('CoreLocalNotificationsProvider');
|
||||||
this.appDB = appProvider.getDB();
|
this.appDB = appProvider.getDB();
|
||||||
|
@ -327,12 +327,15 @@ export class CoreLocalNotificationsProvider {
|
||||||
* @param {any} data Data received by the notification.
|
* @param {any} data Data received by the notification.
|
||||||
*/
|
*/
|
||||||
notifyClick(data: any): void {
|
notifyClick(data: any): void {
|
||||||
|
// Execute the code in the Angular zone, so change detection doesn't stop working.
|
||||||
|
this.zone.run(() => {
|
||||||
const component = data.component;
|
const component = data.component;
|
||||||
if (component) {
|
if (component) {
|
||||||
if (this.observables[component]) {
|
if (this.observables[component]) {
|
||||||
this.observables[component].next(data);
|
this.observables[component].next(data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue