Refactor settings/other to use Composition API (#8589)

* refactor(client): refactor settings/other to use Composition API

* fix(client): fix 'show featured notes' checkbox
This commit is contained in:
Andreas Nedbal 2022-05-04 03:12:08 +02:00 committed by GitHub
parent e555686294
commit 471bb7f3b7

View file

@ -1,66 +1,44 @@
<template> <template>
<div class="_formRoot"> <div class="_formRoot">
<FormSwitch :value="$i.injectFeaturedNote" class="_formBlock" @update:modelValue="onChangeInjectFeaturedNote"> <FormSwitch v-model="$i.injectFeaturedNote" class="_formBlock" @update:modelValue="onChangeInjectFeaturedNote">
{{ $ts.showFeaturedNotesInTimeline }} {{ i18n.ts.showFeaturedNotesInTimeline }}
</FormSwitch> </FormSwitch>
<!-- <!--
<FormSwitch v-model="reportError" class="_formBlock">{{ $ts.sendErrorReports }}<template #caption>{{ $ts.sendErrorReportsDescription }}</template></FormSwitch> <FormSwitch v-model="reportError" class="_formBlock">{{ i18n.ts.sendErrorReports }}<template #caption>{{ i18n.ts.sendErrorReportsDescription }}</template></FormSwitch>
--> -->
<FormLink to="/settings/account-info" class="_formBlock">{{ $ts.accountInfo }}</FormLink> <FormLink to="/settings/account-info" class="_formBlock">{{ i18n.ts.accountInfo }}</FormLink>
<FormLink to="/settings/delete-account" class="_formBlock"><template #icon><i class="fas fa-exclamation-triangle"></i></template>{{ $ts.closeAccount }}</FormLink> <FormLink to="/settings/delete-account" class="_formBlock"><template #icon><i class="fas fa-exclamation-triangle"></i></template>{{ i18n.ts.closeAccount }}</FormLink>
</div> </div>
</template> </template>
<script lang="ts"> <script lang="ts" setup>
import { defineAsyncComponent, defineComponent } from 'vue'; import { computed, defineExpose } from 'vue';
import FormSwitch from '@/components/form/switch.vue'; import FormSwitch from '@/components/form/switch.vue';
import FormSection from '@/components/form/section.vue';
import FormLink from '@/components/form/link.vue'; import FormLink from '@/components/form/link.vue';
import * as os from '@/os'; import * as os from '@/os';
import { debug } from '@/config';
import { defaultStore } from '@/store'; import { defaultStore } from '@/store';
import { unisonReload } from '@/scripts/unison-reload';
import * as symbols from '@/symbols'; import * as symbols from '@/symbols';
import { $i } from '@/account';
import { i18n } from '@/i18n';
export default defineComponent({ const reportError = computed(defaultStore.makeGetterSetter('reportError'));
components: {
FormSection,
FormSwitch,
FormLink,
},
emits: ['info'], function onChangeInjectFeaturedNote(v) {
os.api('i/update', {
data() { injectFeaturedNote: v
return { }).then((i) => {
[symbols.PAGE_INFO]: { $i!.injectFeaturedNote = i.injectFeaturedNote;
title: this.$ts.other, });
icon: 'fas fa-ellipsis-h', }
bg: 'var(--bg)',
},
debug,
}
},
computed: { defineExpose({
reportError: defaultStore.makeGetterSetter('reportError'), [symbols.PAGE_INFO]: {
}, title: i18n.ts.other,
icon: 'fas fa-ellipsis-h',
methods: { bg: 'var(--bg)',
changeDebug(v) {
console.log(v);
localStorage.setItem('debug', v.toString());
unisonReload();
},
onChangeInjectFeaturedNote(v) {
os.api('i/update', {
injectFeaturedNote: v
});
},
} }
}); });
</script> </script>