MOBILE-2308 events: Adapt events to new functions
parent
6f671fe39f
commit
3ef367db76
|
@ -504,27 +504,27 @@ export class CoreSite {
|
|||
}
|
||||
|
||||
// Session expired, trigger event.
|
||||
this.eventsProvider.trigger(CoreEventsProvider.SESSION_EXPIRED, {siteId: this.id});
|
||||
this.eventsProvider.trigger(CoreEventsProvider.SESSION_EXPIRED, {}, this.id);
|
||||
// Change error message. We'll try to get data from cache.
|
||||
error.message = this.translate.instant('core.lostconnection');
|
||||
} else if (error.errorcode === 'userdeleted') {
|
||||
// User deleted, trigger event.
|
||||
this.eventsProvider.trigger(CoreEventsProvider.USER_DELETED, {siteId: this.id, params: data});
|
||||
this.eventsProvider.trigger(CoreEventsProvider.USER_DELETED, {params: data}, this.id);
|
||||
error.message = this.translate.instant('core.userdeleted');
|
||||
return Promise.reject(error);
|
||||
} else if (error.errorcode === 'forcepasswordchangenotice') {
|
||||
// Password Change Forced, trigger event.
|
||||
this.eventsProvider.trigger(CoreEventsProvider.PASSWORD_CHANGE_FORCED, {siteId: this.id});
|
||||
this.eventsProvider.trigger(CoreEventsProvider.PASSWORD_CHANGE_FORCED, {}, this.id);
|
||||
error.message = this.translate.instant('core.forcepasswordchangenotice');
|
||||
return Promise.reject(error);
|
||||
} else if (error.errorcode === 'usernotfullysetup') {
|
||||
// User not fully setup, trigger event.
|
||||
this.eventsProvider.trigger(CoreEventsProvider.USER_NOT_FULLY_SETUP, {siteId: this.id});
|
||||
this.eventsProvider.trigger(CoreEventsProvider.USER_NOT_FULLY_SETUP, {}, this.id);
|
||||
error.message = this.translate.instant('core.usernotfullysetup');
|
||||
return Promise.reject(error);
|
||||
} else if (error.errorcode === 'sitepolicynotagreed') {
|
||||
// Site policy not agreed, trigger event.
|
||||
this.eventsProvider.trigger(CoreEventsProvider.SITE_POLICY_NOT_AGREED, {siteId: this.id});
|
||||
this.eventsProvider.trigger(CoreEventsProvider.SITE_POLICY_NOT_AGREED, {}, this.id);
|
||||
error.message = this.translate.instant('core.sitepolicynotagreederror');
|
||||
return Promise.reject(error);
|
||||
} else if (error.errorcode === 'dmlwriteexception' && this.textUtils.hasUnicodeData(data)) {
|
||||
|
|
|
@ -307,7 +307,7 @@ export class CoreCoursesCoursePreviewPage implements OnDestroy {
|
|||
this.refreshData().finally(() => {
|
||||
// My courses have been updated, trigger event.
|
||||
this.eventsProvider.trigger(
|
||||
CoreCoursesProvider.EVENT_MY_COURSES_UPDATED, {siteId: this.sitesProvider.getCurrentSiteId()});
|
||||
CoreCoursesProvider.EVENT_MY_COURSES_UPDATED, {}, this.sitesProvider.getCurrentSiteId());
|
||||
});
|
||||
});
|
||||
}).catch((error) => {
|
||||
|
|
|
@ -53,17 +53,13 @@ export class CoreCoursesMyCoursesPage implements OnDestroy {
|
|||
this.coursesLoaded = true;
|
||||
});
|
||||
|
||||
this.myCoursesObserver = this.eventsProvider.on(CoreCoursesProvider.EVENT_MY_COURSES_UPDATED, (data) => {
|
||||
if (data.siteId == this.sitesProvider.getCurrentSiteId()) {
|
||||
this.fetchCourses();
|
||||
}
|
||||
});
|
||||
this.myCoursesObserver = this.eventsProvider.on(CoreCoursesProvider.EVENT_MY_COURSES_UPDATED, () => {
|
||||
this.fetchCourses();
|
||||
}, this.sitesProvider.getCurrentSiteId());
|
||||
|
||||
this.siteUpdatedObserver = this.eventsProvider.on(CoreEventsProvider.SITE_UPDATED, (data) => {
|
||||
if (data.siteId == this.sitesProvider.getCurrentSiteId()) {
|
||||
this.searchEnabled = !this.coursesProvider.isSearchCoursesDisabledInSite();
|
||||
}
|
||||
});
|
||||
this.siteUpdatedObserver = this.eventsProvider.on(CoreEventsProvider.SITE_UPDATED, () => {
|
||||
this.searchEnabled = !this.coursesProvider.isSearchCoursesDisabledInSite();
|
||||
}, this.sitesProvider.getCurrentSiteId());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -84,10 +84,7 @@ export class CoreLoginCredentialsPage {
|
|||
*/
|
||||
ionViewDidLeave() {
|
||||
this.viewLeft = true;
|
||||
this.eventsProvider.trigger(CoreEventsProvider.LOGIN_SITE_UNCHECKED, {
|
||||
siteId: this.siteId,
|
||||
config: this.siteConfig
|
||||
});
|
||||
this.eventsProvider.trigger(CoreEventsProvider.LOGIN_SITE_UNCHECKED, {config: this.siteConfig}, this.siteId);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -146,9 +143,7 @@ export class CoreLoginCredentialsPage {
|
|||
|
||||
if (!this.eventThrown && !this.viewLeft) {
|
||||
this.eventThrown = true;
|
||||
this.eventsProvider.trigger(CoreEventsProvider.LOGIN_SITE_CHECKED, {
|
||||
config: this.siteConfig
|
||||
});
|
||||
this.eventsProvider.trigger(CoreEventsProvider.LOGIN_SITE_CHECKED, {config: this.siteConfig});
|
||||
}
|
||||
} else {
|
||||
this.siteName = null;
|
||||
|
|
|
@ -574,10 +574,9 @@ export class CoreLoginHelperProvider {
|
|||
|
||||
if (site.isLoggedOut()) {
|
||||
this.eventsProvider.trigger(CoreEventsProvider.SESSION_EXPIRED, {
|
||||
siteId: site.getId(),
|
||||
pageName: pageName,
|
||||
params: params
|
||||
});
|
||||
}, site.getId());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
|
@ -45,12 +45,8 @@ export class CoreMainMenuMorePage implements OnDestroy {
|
|||
private navCtrl: NavController, private mainMenuProvider: CoreMainMenuProvider, eventsProvider: CoreEventsProvider) {
|
||||
|
||||
this.langObserver = eventsProvider.on(CoreEventsProvider.LANGUAGE_CHANGED, this.loadSiteInfo.bind(this));
|
||||
this.updateSiteObserver = eventsProvider.on(CoreEventsProvider.SITE_UPDATED, (data) => {
|
||||
if (sitesProvider.getCurrentSiteId() == data.siteId) {
|
||||
this.loadSiteInfo();
|
||||
}
|
||||
});
|
||||
|
||||
this.updateSiteObserver = eventsProvider.on(CoreEventsProvider.SITE_UPDATED, this.loadSiteInfo.bind(this),
|
||||
sitesProvider.getCurrentSiteId());
|
||||
this.loadSiteInfo();
|
||||
}
|
||||
|
||||
|
|
|
@ -2692,12 +2692,11 @@ export class CoreFilepoolProvider {
|
|||
*/
|
||||
protected triggerPackageStatusChanged(siteId: string, status: string, component: string, componentId?: string|number) : void {
|
||||
const data = {
|
||||
siteid: siteId,
|
||||
component: component,
|
||||
componentId: this.fixComponentId(componentId),
|
||||
status: status
|
||||
}
|
||||
this.eventsProvider.trigger(CoreEventsProvider.PACKAGE_STATUS_CHANGED, data);
|
||||
this.eventsProvider.trigger(CoreEventsProvider.PACKAGE_STATUS_CHANGED, data, siteId);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -398,7 +398,7 @@ export class CoreSitesProvider {
|
|||
this.sites[siteId] = candidateSite;
|
||||
// Store session.
|
||||
this.login(siteId);
|
||||
this.eventsProvider.trigger(CoreEventsProvider.SITE_ADDED, siteId);
|
||||
this.eventsProvider.trigger(CoreEventsProvider.SITE_ADDED, {}, siteId);
|
||||
|
||||
if (this.siteTablesSchemas.length) {
|
||||
// Create tables in the site's database.
|
||||
|
@ -558,7 +558,7 @@ export class CoreSitesProvider {
|
|||
// Check if local_mobile was installed to Moodle.
|
||||
return site.checkIfLocalMobileInstalledAndNotUsed().then(() => {
|
||||
// Local mobile was added. Throw invalid session to force reconnect and create a new token.
|
||||
this.eventsProvider.trigger(CoreEventsProvider.SESSION_EXPIRED, {siteId: siteId});
|
||||
this.eventsProvider.trigger(CoreEventsProvider.SESSION_EXPIRED, {}, siteId);
|
||||
}, () => {
|
||||
// Update site info. We don't block the UI.
|
||||
this.updateSiteInfo(siteId);
|
||||
|
@ -622,7 +622,7 @@ export class CoreSitesProvider {
|
|||
// DB remove shouldn't fail, but we'll go ahead even if it does.
|
||||
return site.deleteFolder();
|
||||
}).then(() => {
|
||||
this.eventsProvider.trigger(CoreEventsProvider.SITE_DELETED, site);
|
||||
this.eventsProvider.trigger(CoreEventsProvider.SITE_DELETED, site, siteId);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -801,7 +801,7 @@ export class CoreSitesProvider {
|
|||
siteId: siteId
|
||||
};
|
||||
return this.appDB.insertOrUpdateRecord(this.CURRENT_SITE_TABLE, entry, {id: 1}).then(() => {
|
||||
this.eventsProvider.trigger(CoreEventsProvider.LOGIN, {siteId: siteId});
|
||||
this.eventsProvider.trigger(CoreEventsProvider.LOGIN, {}, siteId);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -829,7 +829,7 @@ export class CoreSitesProvider {
|
|||
promises.push(this.appDB.deleteRecords(this.CURRENT_SITE_TABLE, {id: 1}));
|
||||
|
||||
return Promise.all(promises).finally(() => {
|
||||
this.eventsProvider.trigger(CoreEventsProvider.LOGOUT, {siteId: siteId});
|
||||
this.eventsProvider.trigger(CoreEventsProvider.LOGOUT, {}, siteId);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -936,7 +936,7 @@ export class CoreSitesProvider {
|
|||
}
|
||||
|
||||
return this.appDB.updateRecords(this.SITES_TABLE, newValues, {id: siteId}).finally(() => {
|
||||
this.eventsProvider.trigger(CoreEventsProvider.SITE_UPDATED, {siteId: siteId});
|
||||
this.eventsProvider.trigger(CoreEventsProvider.SITE_UPDATED, {}, siteId);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue