Misskey Playのノート投稿画面で「内容を隠す」を設定できるようにする (#12576)

* Add the content warning option in AiScript UI postFormButton

* Fix initial CW in postFormButton

---------

Co-authored-by: syuilo <Syuilotan@yahoo.co.jp>
This commit is contained in:
Yuriha 2023-12-09 13:14:51 +09:00 committed by GitHub
parent b7bdd45dba
commit dd332b3515
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 14 additions and 2 deletions

View File

@ -43,6 +43,7 @@ SPDX-License-Identifier: AGPL-3.0-only
fixed fixed
:instant="true" :instant="true"
:initialText="c.form.text" :initialText="c.form.text"
:initialCw="c.form.cw"
/> />
</div> </div>
<MkFolder v-else-if="c.type === 'folder'" :defaultOpen="c.opened"> <MkFolder v-else-if="c.type === 'folder'" :defaultOpen="c.opened">
@ -97,6 +98,7 @@ function onSwitchUpdate(v) {
function openPostForm() { function openPostForm() {
os.post({ os.post({
initialText: c.form.text, initialText: c.form.text,
initialCw: c.form.cw,
instant: true, instant: true,
}); });
} }

View File

@ -135,6 +135,7 @@ const props = withDefaults(defineProps<{
mention?: Misskey.entities.User; mention?: Misskey.entities.User;
specified?: Misskey.entities.User; specified?: Misskey.entities.User;
initialText?: string; initialText?: string;
initialCw?: string;
initialVisibility?: (typeof Misskey.noteVisibilities)[number]; initialVisibility?: (typeof Misskey.noteVisibilities)[number];
initialFiles?: Misskey.entities.DriveFile[]; initialFiles?: Misskey.entities.DriveFile[];
initialLocalOnly?: boolean; initialLocalOnly?: boolean;
@ -177,10 +178,10 @@ const poll = ref<{
expiresAt: string | null; expiresAt: string | null;
expiredAfter: string | null; expiredAfter: string | null;
} | null>(null); } | null>(null);
const useCw = ref(false); const useCw = ref<boolean>(!!props.initialCw);
const showPreview = ref(defaultStore.state.showPreview); const showPreview = ref(defaultStore.state.showPreview);
watch(showPreview, () => defaultStore.set('showPreview', showPreview.value)); watch(showPreview, () => defaultStore.set('showPreview', showPreview.value));
const cw = ref<string | null>(null); const cw = ref<string | null>(props.initialCw ?? null);
const localOnly = ref<boolean>(props.initialLocalOnly ?? defaultStore.state.rememberNoteVisibility ? defaultStore.state.localOnly : defaultStore.state.defaultNoteLocalOnly); const localOnly = ref<boolean>(props.initialLocalOnly ?? defaultStore.state.rememberNoteVisibility ? defaultStore.state.localOnly : defaultStore.state.defaultNoteLocalOnly);
const visibility = ref(props.initialVisibility ?? (defaultStore.state.rememberNoteVisibility ? defaultStore.state.visibility : defaultStore.state.defaultNoteVisibility) as typeof Misskey.noteVisibilities[number]); const visibility = ref(props.initialVisibility ?? (defaultStore.state.rememberNoteVisibility ? defaultStore.state.visibility : defaultStore.state.defaultNoteVisibility) as typeof Misskey.noteVisibilities[number]);
const visibleUsers = ref([]); const visibleUsers = ref([]);

View File

@ -22,6 +22,7 @@ const props = defineProps<{
mention?: Misskey.entities.User; mention?: Misskey.entities.User;
specified?: Misskey.entities.User; specified?: Misskey.entities.User;
initialText?: string; initialText?: string;
initialCw?: string;
initialVisibility?: typeof Misskey.noteVisibilities; initialVisibility?: typeof Misskey.noteVisibilities;
initialFiles?: Misskey.entities.DriveFile[]; initialFiles?: Misskey.entities.DriveFile[];
initialLocalOnly?: boolean; initialLocalOnly?: boolean;

View File

@ -121,6 +121,7 @@ export type AsUiPostFormButton = AsUiComponentBase & {
rounded?: boolean; rounded?: boolean;
form?: { form?: {
text: string; text: string;
cw?: string;
}; };
}; };
@ -128,6 +129,7 @@ export type AsUiPostForm = AsUiComponentBase & {
type: 'postForm'; type: 'postForm';
form?: { form?: {
text: string; text: string;
cw?: string;
}; };
}; };
@ -454,8 +456,11 @@ function getPostFormButtonOptions(def: values.Value | undefined, call: (fn: valu
const getForm = () => { const getForm = () => {
const text = form!.value.get('text'); const text = form!.value.get('text');
utils.assertString(text); utils.assertString(text);
const cw = form!.value.get('cw');
if (cw) utils.assertString(cw);
return { return {
text: text.value, text: text.value,
cw: cw?.value,
}; };
}; };
@ -478,8 +483,11 @@ function getPostFormOptions(def: values.Value | undefined, call: (fn: values.VFn
const getForm = () => { const getForm = () => {
const text = form!.value.get('text'); const text = form!.value.get('text');
utils.assertString(text); utils.assertString(text);
const cw = form!.value.get('cw');
if (cw) utils.assertString(cw);
return { return {
text: text.value, text: text.value,
cw: cw?.value,
}; };
}; };