本文整理汇总了TypeScript中@providers/sites.CoreSitesProvider.getSite方法的典型用法代码示例。如果您正苦于以下问题:TypeScript CoreSitesProvider.getSite方法的具体用法?TypeScript CoreSitesProvider.getSite怎么用?TypeScript CoreSitesProvider.getSite使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类@providers/sites.CoreSitesProvider
的用法示例。
在下文中一共展示了CoreSitesProvider.getSite方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: ionViewDidLoad
/**
* View loaded.
*/
ionViewDidLoad(): void {
if (this.siteConfig) {
this.identityProviders = this.loginHelper.getValidIdentityProviders(this.siteConfig);
}
this.sitesProvider.getSite(this.siteId).then((site) => {
this.site = {
id: site.id,
fullname: site.infos.fullname,
avatar: site.infos.userpictureurl
};
this.username = site.infos.username;
this.siteUrl = site.infos.siteurl;
this.siteName = site.infos.sitename;
// Check logoURL if user avatar is not set.
if (this.site.avatar.startsWith(site.infos.siteurl + '/theme/image.php')) {
this.site.avatar = false;
return site.getPublicConfig().then((config) => {
this.logoUrl = config.logourl || config.compactlogourl;
}).catch(() => {
// Ignore errors.
});
}
}).catch(() => {
// Shouldn't happen. Just leave the view.
this.cancel();
});
}
示例2: getEntry
/**
* Get an online or offline entry.
*
* @param {any} data Database.
* @param {number} entryId Entry ID.
* @param {any} [offlineActions] Offline data with the actions done. Required for offline entries.
* @param {string} [siteId] Site ID. If not defined, current site.
* @return {Promise<any>} Promise resolved with the entry.
*/
getEntry(data: any, entryId: number, offlineActions?: any, siteId?: string): Promise<any> {
if (entryId > 0) {
// It's an online entry, get it from WS.
return this.dataProvider.getEntry(data.id, entryId, siteId);
}
// It's an offline entry, search it in the offline actions.
return this.sitesProvider.getSite(siteId).then((site) => {
const offlineEntry = offlineActions.find((offlineAction) => offlineAction.action == 'add');
if (offlineEntry) {
const siteInfo = site.getInfo();
return {entry: {
id: offlineEntry.entryid,
canmanageentry: true,
approved: !data.approval || data.manageapproved,
dataid: offlineEntry.dataid,
groupid: offlineEntry.groupid,
timecreated: -offlineEntry.entryid,
timemodified: -offlineEntry.entryid,
userid: siteInfo.userid,
fullname: siteInfo.fullname,
contents: {}
}
};
}
});
}