Improve build times

* Fix bulma/buefy being imported many (many !!!) times

* Remove javascript-time-ago because date-fns pretty much does the same
thing

* Make sure languages are loaded asynchronously

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel
2020-10-13 20:39:59 +02:00
parent f627cab292
commit 93cecbe49c
66 changed files with 167 additions and 283 deletions

View File

@@ -323,8 +323,6 @@ export default class AccountSettings extends Vue {
}
</script>
<style lang="scss">
@import "@/variables.scss";
.setting-title {
margin-top: 2rem;
margin-bottom: 1rem;

View File

@@ -155,8 +155,6 @@ export default class Notifications extends Vue {
</script>
<style lang="scss" scoped>
@import "../../variables.scss";
.field {
&:not(:last-child) {
margin-bottom: 1.5rem;

View File

@@ -17,7 +17,7 @@
v-model="$i18n.locale"
:placeholder="$t('Select a language')"
>
<option v-for="(language, lang) in languages" :value="lang" :key="lang">
<option v-for="(language, lang) in langs" :value="lang" :key="lang">
{{ language }}
</option>
</b-select>
@@ -73,8 +73,10 @@ export default class Preferences extends Vue {
RouteName = RouteName;
langs: Record<string, string> = langs;
@Watch("loggedUser")
setSavedTimezone(loggedUser: IUser) {
setSavedTimezone(loggedUser: IUser): void {
if (loggedUser && loggedUser.settings.timezone) {
this.selectedTimezone = loggedUser.settings.timezone;
} else {
@@ -87,22 +89,24 @@ export default class Preferences extends Vue {
}
}
// eslint-disable-next-line class-methods-use-this
sanitize(timezone: string): string {
return timezone.split("_").join(" ").replace("St ", "St. ").split("/").join(" - ");
}
get timezones() {
get timezones(): Record<string, string[]> {
if (!this.config || !this.config.timezones) return {};
return this.config.timezones.reduce((acc: { [key: string]: Array<string> }, val: string) => {
const components = val.split("/");
const [prefix, suffix] = [components.shift() as string, components.join("/")];
const pushOrCreate = (
acc: { [key: string]: Array<string> },
prefix: string,
suffix: string
acc2: { [key: string]: Array<string> },
prefix2: string,
suffix2: string
) => {
(acc[prefix] = acc[prefix] || []).push(suffix);
return acc;
// eslint-disable-next-line no-param-reassign
(acc2[prefix2] = acc2[prefix2] || []).push(suffix2);
return acc2;
};
if (suffix) {
return pushOrCreate(acc, prefix, suffix);
@@ -111,22 +115,8 @@ export default class Preferences extends Vue {
}, {});
}
get languages(): object {
return this.$i18n.availableLocales.reduce((acc: object, lang: string) => {
// @ts-ignore
if (langs[lang]) {
return {
...acc,
// @ts-ignore
[lang]: langs[lang],
};
}
return acc;
}, {} as object);
}
@Watch("selectedTimezone")
async updateTimezone() {
async updateTimezone(): Promise<void> {
if (this.selectedTimezone !== this.loggedUser.settings.timezone) {
await this.$apollo.mutate<{ setUserSetting: string }>({
mutation: SET_USER_SETTINGS,
@@ -138,7 +128,7 @@ export default class Preferences extends Vue {
}
@Watch("$i18n.locale")
async updateLocale() {
async updateLocale(): Promise<void> {
await this.$apollo.mutate({
mutation: UPDATE_USER_LOCALE,
variables: {