View MR for information: https://activitypub.software/TransFem-org/Sharkey/-/merge_requests/881 Closes #901 Approved-by: dakkar <dakkar@thenautilus.net> Approved-by: Marie <github@yuugi.dev>
This commit is contained in:
commit
d629b882b0
12 changed files with 178 additions and 7 deletions
|
|
@ -364,6 +364,29 @@ if (defaultStore.state.keepCw && props.reply && props.reply.cw) {
|
|||
cw.value = props.reply.cw;
|
||||
}
|
||||
|
||||
// apply default CW
|
||||
if ($i.defaultCW) {
|
||||
useCw.value = true;
|
||||
|
||||
if (!cw.value || $i.defaultCWPriority === 'default') {
|
||||
cw.value = $i.defaultCW;
|
||||
} else if ($i.defaultCWPriority !== 'parent') {
|
||||
// This is a fancy way of simulating /\bsearch\b/ without a regular expression.
|
||||
// We're checking to see whether the default CW appears inside the existing CW, but *only* if there's word boundaries.
|
||||
const parts = cw.value.split($i.defaultCW);
|
||||
const hasExistingDefaultCW = parts.length === 2 && !/\w$/.test(parts[0]) && !/^\w/.test(parts[1]);
|
||||
if (!hasExistingDefaultCW) {
|
||||
// We need to merge the CWs
|
||||
if ($i.defaultCWPriority === 'defaultParent') {
|
||||
cw.value = `${$i.defaultCW}, ${cw.value}`;
|
||||
} else if ($i.defaultCWPriority === 'parentDefault') {
|
||||
cw.value = `${cw.value}, ${$i.defaultCW}`;
|
||||
}
|
||||
}
|
||||
}
|
||||
// else { do nothing, because existing CW takes priority. }
|
||||
}
|
||||
|
||||
function watchForDraft() {
|
||||
watch(text, () => saveDraft());
|
||||
watch(useCw, () => saveDraft());
|
||||
|
|
|
|||
|
|
@ -155,10 +155,24 @@ SPDX-License-Identifier: AGPL-3.0-only
|
|||
<MkSwitch v-model="defaultNoteLocalOnly">{{ i18n.ts._visibility.disableFederation }}</MkSwitch>
|
||||
</div>
|
||||
</MkFolder>
|
||||
|
||||
<MkSwitch v-model="keepCw" @update:modelValue="save()">{{ i18n.ts.keepCw }}</MkSwitch>
|
||||
|
||||
<MkInput v-model="defaultCW" type="text" manualSave @update:modelValue="save()">
|
||||
<template #label>{{ i18n.ts.defaultCW }}</template>
|
||||
<template #caption>{{ i18n.ts.defaultCWDescription }}</template>
|
||||
</MkInput>
|
||||
|
||||
<MkSelect v-model="defaultCWPriority" :disabled="!defaultCW || !keepCw" @update:modelValue="save()">
|
||||
<template #label>{{ i18n.ts.defaultCWPriority }}</template>
|
||||
<template #caption>{{ i18n.ts.defaultCWPriorityDescription }}</template>
|
||||
<option value="default">{{ i18n.ts._defaultCWPriority.default }}</option>
|
||||
<option value="parent">{{ i18n.ts._defaultCWPriority.parent }}</option>
|
||||
<option value="parentDefault">{{ i18n.ts._defaultCWPriority.parentDefault }}</option>
|
||||
<option value="defaultParent">{{ i18n.ts._defaultCWPriority.defaultParent }}</option>
|
||||
</MkSelect>
|
||||
</div>
|
||||
</FormSection>
|
||||
|
||||
<MkSwitch v-model="keepCw" @update:modelValue="save()">{{ i18n.ts.keepCw }}</MkSwitch>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
|
|
@ -193,6 +207,8 @@ const hideOnlineStatus = ref($i.hideOnlineStatus);
|
|||
const publicReactions = ref($i.publicReactions);
|
||||
const followingVisibility = ref($i.followingVisibility);
|
||||
const followersVisibility = ref($i.followersVisibility);
|
||||
const defaultCW = ref($i.defaultCW);
|
||||
const defaultCWPriority = ref($i.defaultCWPriority);
|
||||
|
||||
const defaultNoteVisibility = computed(defaultStore.makeGetterSetter('defaultNoteVisibility'));
|
||||
const defaultNoteLocalOnly = computed(defaultStore.makeGetterSetter('defaultNoteLocalOnly'));
|
||||
|
|
@ -251,6 +267,8 @@ function save() {
|
|||
publicReactions: !!publicReactions.value,
|
||||
followingVisibility: followingVisibility.value,
|
||||
followersVisibility: followersVisibility.value,
|
||||
defaultCWPriority: defaultCWPriority.value,
|
||||
defaultCW: defaultCW.value,
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue