mirror of
https://codeberg.org/yeentown/barkey.git
synced 2025-07-07 20:44:34 +00:00
improve attributionDomain settings.
This commit is contained in:
parent
eb88920f41
commit
a5e7a6b68b
2 changed files with 30 additions and 31 deletions
|
@ -4,23 +4,19 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||||
-->
|
-->
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div class="_gaps_m">
|
<MkTextarea v-model="attributionDomains">
|
||||||
<SearchMarker :keywords="['attribution', 'domains', 'preview', 'url']">
|
<template #label><SearchLabel>{{ i18n.ts.attributionDomains }}</SearchLabel></template>
|
||||||
<MkTextarea v-model="attributionDomains">
|
<template #caption>
|
||||||
<template #label>{{ i18n.ts.attributionDomains }}</template>
|
{{ i18n.ts.attributionDomainsDescription }}
|
||||||
<template #caption>
|
<br/>
|
||||||
{{ i18n.ts.attributionDomainsDescription }}
|
<Mfm :text="tutorialTag"/>
|
||||||
<br/>
|
</template>
|
||||||
<Mfm :text="tutorialTag"/>
|
</MkTextarea>
|
||||||
</template>
|
<MkButton primary :disabled="!changed" @click="save()"><i class="ti ti-device-floppy"></i> {{ i18n.ts.save }}</MkButton>
|
||||||
</MkTextarea>
|
|
||||||
</SearchMarker>
|
|
||||||
<MkButton primary :disabled="!changed" @click="save()"><i class="ti ti-device-floppy"></i> {{ i18n.ts.save }}</MkButton>
|
|
||||||
</div>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { ref, watch } from 'vue';
|
import { ref, watch, computed } from 'vue';
|
||||||
import { host as hostRaw } from '@@/js/config.js';
|
import { host as hostRaw } from '@@/js/config.js';
|
||||||
import { toUnicode } from 'punycode.js';
|
import { toUnicode } from 'punycode.js';
|
||||||
import MkTextarea from '@/components/MkTextarea.vue';
|
import MkTextarea from '@/components/MkTextarea.vue';
|
||||||
|
@ -33,31 +29,29 @@ import { i18n } from '@/i18n.js';
|
||||||
const $i = ensureSignin();
|
const $i = ensureSignin();
|
||||||
|
|
||||||
const attributionDomains = ref($i.attributionDomains.join('\n'));
|
const attributionDomains = ref($i.attributionDomains.join('\n'));
|
||||||
const changed = ref(false);
|
const domainArray = computed(() => {
|
||||||
const autochange = ref(false);
|
return attributionDomains.value
|
||||||
const tutorialTag = '`<meta name="fediverse:creator" content="' + $i.username + '@' + toUnicode(hostRaw) + '" />`';
|
|
||||||
|
|
||||||
async function save() {
|
|
||||||
const domains = attributionDomains.value
|
|
||||||
.trim().split('\n')
|
.trim().split('\n')
|
||||||
.map(el => el.trim().toLowerCase())
|
.map(el => el.trim().toLowerCase())
|
||||||
.filter(el => el);
|
.filter(el => el);
|
||||||
|
});
|
||||||
|
const changed = ref(false);
|
||||||
|
const tutorialTag = '`<meta name="fediverse:creator" content="' + $i.username + '@' + toUnicode(hostRaw) + '" />`';
|
||||||
|
|
||||||
|
async function save() {
|
||||||
await misskeyApi('i/update', {
|
await misskeyApi('i/update', {
|
||||||
attributionDomains: domains,
|
attributionDomains: domainArray.value,
|
||||||
});
|
});
|
||||||
|
|
||||||
changed.value = false;
|
|
||||||
|
|
||||||
// Refresh filtered list to signal to the user how they've been saved
|
// Refresh filtered list to signal to the user how they've been saved
|
||||||
if (attributionDomains.value !== domains.join('\n')) {
|
attributionDomains.value = domainArray.value.join('\n');
|
||||||
attributionDomains.value = domains.join('\n');
|
|
||||||
autochange.value = true;
|
changed.value = false;
|
||||||
} else { autochange.value = false; }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
watch(attributionDomains, () => {
|
watch(domainArray, (newArray, oldArray) => {
|
||||||
if (!autochange.value) {
|
// compare arrays
|
||||||
|
if (newArray.length !== oldArray.length || !newArray.every((a, i) => a === oldArray[i])) {
|
||||||
changed.value = true;
|
changed.value = true;
|
||||||
}
|
}
|
||||||
});
|
});
|
|
@ -162,7 +162,12 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||||
</MkSwitch>
|
</MkSwitch>
|
||||||
</SearchMarker>
|
</SearchMarker>
|
||||||
|
|
||||||
<AttributionDomainsSettings/>
|
<SearchMarker
|
||||||
|
:label="i18n.ts.attributionDomains"
|
||||||
|
:keywords="['attribution', 'domains', 'preview', 'url']"
|
||||||
|
>
|
||||||
|
<AttributionDomainsSettings/>
|
||||||
|
</SearchMarker>
|
||||||
</div>
|
</div>
|
||||||
</MkFolder>
|
</MkFolder>
|
||||||
</SearchMarker>
|
</SearchMarker>
|
||||||
|
@ -172,7 +177,7 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { computed, reactive, ref, watch, defineAsyncComponent } from 'vue';
|
import { computed, reactive, ref, watch, defineAsyncComponent } from 'vue';
|
||||||
import AttributionDomainsSettings from './attribution-domains-setting.vue';
|
import AttributionDomainsSettings from './profile.attribution-domains-setting.vue';
|
||||||
import MkButton from '@/components/MkButton.vue';
|
import MkButton from '@/components/MkButton.vue';
|
||||||
import MkInput from '@/components/MkInput.vue';
|
import MkInput from '@/components/MkInput.vue';
|
||||||
import MkSwitch from '@/components/MkSwitch.vue';
|
import MkSwitch from '@/components/MkSwitch.vue';
|
||||||
|
|
Loading…
Add table
Reference in a new issue