Skip to content

Commit ebfec71

Browse files
committed
MOBILE-3325 settings: Modern syntax changes
1 parent 496a0a4 commit ebfec71

File tree

11 files changed

+97
-117
lines changed

11 files changed

+97
-117
lines changed

scripts/langindex.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1953,9 +1953,9 @@
19531953
"core.settings.sites": "moodle",
19541954
"core.settings.spaceusage": "local_moodlemobileapp",
19551955
"core.settings.spaceusagehelp": "local_moodlemobileapp",
1956-
"core.settings.synchelp": "local_moodlemobileapp",
19571956
"core.settings.synchronization": "local_moodlemobileapp",
19581957
"core.settings.synchronizenow": "local_moodlemobileapp",
1958+
"core.settings.synchronizenowhelp": "local_moodlemobileapp",
19591959
"core.settings.syncsettings": "local_moodlemobileapp",
19601960
"core.settings.total": "moodle",
19611961
"core.settings.wificonnection": "local_moodlemobileapp",

src/addon/messages/providers/settings-handler.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export class AddonMessagesSettingsHandler implements CoreSettingsHandler {
4646
icon: 'chatbubbles',
4747
title: 'addon.messages.messages',
4848
page: 'AddonMessagesSettingsPage',
49-
class: 'addon-messages-settings-handler'
49+
class: 'addon-messages-settings-handler',
5050
};
5151
}
5252

src/addon/notifications/providers/settings-handler.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ export class AddonNotificationsSettingsHandler implements CoreSettingsHandler {
5151
icon: 'notifications',
5252
title: 'addon.notifications.notifications',
5353
page: 'AddonNotificationsSettingsPage',
54-
class: 'addon-notifications-settings-handler'
54+
class: 'addon-notifications-settings-handler',
5555
};
5656
}
5757
}

src/assets/lang/en.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1953,9 +1953,9 @@
19531953
"core.settings.sites": "Sites",
19541954
"core.settings.spaceusage": "Space usage",
19551955
"core.settings.spaceusagehelp": "Deleting the stored information of the site will remove all the site offline data. This information allows you to use the app when offline. ",
1956-
"core.settings.synchelp": "Synchronising a site will send pending changes and all offline activity stored in the device and will synchronise some data like messages and notifications.",
19571956
"core.settings.synchronization": "Synchronisation",
19581957
"core.settings.synchronizenow": "Synchronise now",
1958+
"core.settings.synchronizenowhelp": "Synchronising a site will send pending changes and all offline activity stored in the device and will synchronise some data like messages and notifications.",
19591959
"core.settings.syncsettings": "Synchronisation settings",
19601960
"core.settings.total": "Total",
19611961
"core.settings.wificonnection": "Wi-Fi connection",

src/core/mainmenu/pages/more/more.html

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,7 @@ <h2>{{ 'core.settings.preferences' | translate }}</h2>
4747
<ion-icon name="log-out" item-start aria-hidden="true"></ion-icon>
4848
<h2>{{ logoutLabel | translate }}</h2>
4949
</a>
50-
<ion-item-divider></ion-item-divider>
51-
50+
<ion-item-divider></ion-item-divider>
5251
<a ion-item (click)="openAppSettings()" title="{{ 'core.settings.appsettings' | translate }}">
5352
<core-icon name="fa-cogs" item-start></core-icon>
5453
<h2>{{ 'core.settings.appsettings' | translate }}</h2>

src/core/settings/lang/en.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,9 @@
6363
"sites": "Sites",
6464
"spaceusage": "Space usage",
6565
"spaceusagehelp": "Deleting the stored information of the site will remove all the site offline data. This information allows you to use the app when offline. ",
66-
"synchelp": "Synchronising a site will send pending changes and all offline activity stored in the device and will synchronise some data like messages and notifications.",
6766
"synchronization": "Synchronisation",
6867
"synchronizenow": "Synchronise now",
68+
"synchronizenowhelp": "Synchronising a site will send pending changes and all offline activity stored in the device and will synchronise some data like messages and notifications.",
6969
"syncsettings": "Synchronisation settings",
7070
"total": "Total",
7171
"wificonnection": "Wi-Fi connection"

src/core/settings/pages/site/site.module.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,14 @@ import { CorePipesModule } from '@pipes/pipes.module';
2222

2323
@NgModule({
2424
declarations: [
25-
CoreSitePreferencesPage
25+
CoreSitePreferencesPage,
2626
],
2727
imports: [
2828
CoreComponentsModule,
2929
CoreDirectivesModule,
3030
CorePipesModule,
3131
IonicPageModule.forChild(CoreSitePreferencesPage),
32-
TranslateModule.forChild()
32+
TranslateModule.forChild(),
3333
],
3434
})
3535
export class CoreSitePreferencesPageModule {}

src/core/settings/pages/site/site.ts

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ export class CoreSitePreferencesPage {
5858
protected sharedFilesProvider: CoreSharedFilesProvider,
5959
protected translate: TranslateService,
6060
platorm: Platform,
61-
navParams: NavParams) {
61+
navParams: NavParams,
62+
) {
6263

6364
this.isIOS = platorm.is('ios');
6465

@@ -93,27 +94,25 @@ export class CoreSitePreferencesPage {
9394
/**
9495
* Fetch Data.
9596
*/
96-
protected async fetchData(): Promise<void[]> {
97-
const promises = [];
98-
97+
protected async fetchData(): Promise<void> {
9998
this.handlers = this.settingsDelegate.getHandlers();
10099
const currentSite = this.sitesProvider.getCurrentSite();
101100
this.siteId = currentSite.id;
102101
this.siteInfo = currentSite.getInfo();
103102
this.siteName = currentSite.getSiteName();
104103
this.siteUrl = currentSite.getURL();
105104

106-
promises.push(this.settingsHelper.getSiteSpaceUsage(this.siteId).then((spaceUsage) => {
107-
this.spaceUsage = spaceUsage;
108-
}));
105+
const promises = [];
106+
107+
promises.push(this.settingsHelper.getSiteSpaceUsage(this.siteId).then((spaceUsage) => this.spaceUsage = spaceUsage));
109108

110109
if (this.isIOS) {
111-
promises.push(this.sharedFilesProvider.getSiteSharedFiles(this.siteId).then((files) => {
112-
this.iosSharedFiles = files.length;
113-
}));
110+
promises.push(this.sharedFilesProvider.getSiteSharedFiles(this.siteId).then((files) =>
111+
this.iosSharedFiles = files.length
112+
));
114113
}
115114

116-
return Promise.all(promises);
115+
await Promise.all(promises);
117116
}
118117

119118
/**
@@ -186,7 +185,7 @@ export class CoreSitePreferencesPage {
186185
*/
187186
showSyncInfo(): void {
188187
this.domUtils.showAlert(this.translate.instant('core.help'),
189-
this.translate.instant('core.settings.synchelp'));
188+
this.translate.instant('core.settings.synchronizenowhelp'));
190189
}
191190

192191
/**

src/core/settings/pages/space-usage/space-usage.ts

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -40,46 +40,45 @@ export class CoreSettingsSpaceUsagePage {
4040
constructor(protected sitesProvider: CoreSitesProvider,
4141
protected settingsHelper: CoreSettingsHelper,
4242
protected domUtils: CoreDomUtilsProvider,
43-
protected translate: TranslateService) {
43+
protected translate: TranslateService,
44+
) {
4445
this.currentSiteId = this.sitesProvider.getCurrentSiteId();
4546
}
4647

4748
/**
4849
* View loaded.
4950
*/
5051
ionViewDidLoad(): void {
51-
this.calculateSizeUsage().finally(() => {
52+
this.loadSiteData().finally(() => {
5253
this.loaded = true;
5354
});
5455
}
5556

5657
/**
57-
* Convenience function to calculate each site's usage, and the total usage.
58+
* Convenience function to load site data/usage and calculate the totals.
5859
*
5960
* @return Resolved when done.
6061
*/
61-
protected async calculateSizeUsage(): Promise<void> {
62+
protected async loadSiteData(): Promise<void> {
6263
// Calculate total usage.
63-
let totalSize = 0,
64-
totalEntries = 0;
64+
let totalSize = 0;
65+
let totalEntries = 0;
6566

66-
return this.sitesProvider.getSortedSites().then((sites) => {
67-
this.sites = sites;
67+
this.sites = await this.sitesProvider.getSortedSites();
6868

69-
// Get space usage.
70-
return Promise.all(this.sites.map((site) => {
71-
return this.settingsHelper.getSiteSpaceUsage(site.id).then((siteInfo) => {
72-
site.cacheEntries = siteInfo.cacheEntries;
73-
site.spaceUsage = siteInfo.spaceUsage;
69+
// Get space usage.
70+
await Promise.all(this.sites.map(async (site) => {
71+
const siteInfo = await this.settingsHelper.getSiteSpaceUsage(site.id);
7472

75-
totalSize += (site.spaceUsage ? parseInt(site.spaceUsage, 10) : 0);
76-
totalEntries += (site.cacheEntries ? parseInt(site.cacheEntries, 10) : 0);
77-
});
78-
}));
79-
}).then(() => {
80-
this.totals.spaceUsage = totalSize;
81-
this.totals.cacheEntries = totalEntries;
82-
});
73+
site.cacheEntries = siteInfo.cacheEntries;
74+
site.spaceUsage = siteInfo.spaceUsage;
75+
76+
totalSize += (site.spaceUsage ? parseInt(site.spaceUsage, 10) : 0);
77+
totalEntries += (site.cacheEntries ? parseInt(site.cacheEntries, 10) : 0);
78+
}));
79+
80+
this.totals.spaceUsage = totalSize;
81+
this.totals.cacheEntries = totalEntries;
8382
}
8483

8584
/**
@@ -88,7 +87,7 @@ export class CoreSettingsSpaceUsagePage {
8887
* @param refresher Refresher.
8988
*/
9089
refreshData(refresher: any): void {
91-
this.calculateSizeUsage().finally(() => {
90+
this.loadSiteData().finally(() => {
9291
refresher.complete();
9392
});
9493
}

src/core/settings/pages/synchronization/synchronization.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ export class CoreSettingsSynchronizationPage implements OnDestroy {
4444
protected sitesProvider: CoreSitesProvider,
4545
protected domUtils: CoreDomUtilsProvider,
4646
protected settingsHelper: CoreSettingsHelper,
47-
protected translate: TranslateService) {
47+
protected translate: TranslateService,
48+
) {
4849

4950
this.currentSiteId = this.sitesProvider.getCurrentSiteId();
5051

@@ -113,7 +114,7 @@ export class CoreSettingsSynchronizationPage implements OnDestroy {
113114
*/
114115
showInfo(): void {
115116
this.domUtils.showAlert(this.translate.instant('core.help'),
116-
this.translate.instant('core.settings.synchelp'));
117+
this.translate.instant('core.settings.synchronizenowhelp'));
117118
}
118119

119120
/**

0 commit comments

Comments
 (0)