From a552778ba5c40ff2c7c5367a6fd93dd90e853958 Mon Sep 17 00:00:00 2001 From: kakkokari-gtyih <67428053+kakkokari-gtyih@users.noreply.github.com> Date: Fri, 3 May 2024 15:21:57 +0900 Subject: [PATCH 1/2] =?UTF-8?q?enhance(frontend=5Fais):=20PostForm?= =?UTF-8?q?=E7=B3=BB=E3=81=AE=E8=A8=AD=E5=AE=9A=E9=A0=85=E7=9B=AE=E3=82=92?= =?UTF-8?q?=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/frontend/src/components/MkAsUi.vue | 4 ++ packages/frontend/src/scripts/aiscript/ui.ts | 62 ++++++++++---------- 2 files changed, 34 insertions(+), 32 deletions(-) diff --git a/packages/frontend/src/components/MkAsUi.vue b/packages/frontend/src/components/MkAsUi.vue index 5eb77740be15..18e8e7542e3f 100644 --- a/packages/frontend/src/components/MkAsUi.vue +++ b/packages/frontend/src/components/MkAsUi.vue @@ -44,6 +44,8 @@ SPDX-License-Identifier: AGPL-3.0-only :instant="true" :initialText="c.form?.text" :initialCw="c.form?.cw" + :initialVisibility="c.form?.visibility" + :initialLocalOnly="c.form?.localOnly" /> @@ -111,6 +113,8 @@ function openPostForm() { os.post({ initialText: form.text, initialCw: form.cw, + initialVisibility: form.visibility, + initialLocalOnly: form.localOnly, instant: true, }); } diff --git a/packages/frontend/src/scripts/aiscript/ui.ts b/packages/frontend/src/scripts/aiscript/ui.ts index f2493264d37a..fa3fcac2e79a 100644 --- a/packages/frontend/src/scripts/aiscript/ui.ts +++ b/packages/frontend/src/scripts/aiscript/ui.ts @@ -6,6 +6,7 @@ import { utils, values } from '@syuilo/aiscript'; import { v4 as uuid } from 'uuid'; import { ref, Ref } from 'vue'; +import * as Misskey from 'misskey-js'; export type AsUiComponentBase = { id: string; @@ -115,23 +116,24 @@ export type AsUiFolder = AsUiComponentBase & { opened?: boolean; }; +type PostFormPropsForAsUi = { + text: string; + cw?: string; + visibility?: (typeof Misskey.noteVisibilities)[number]; + localOnly?: boolean; +}; + export type AsUiPostFormButton = AsUiComponentBase & { type: 'postFormButton'; text?: string; primary?: boolean; rounded?: boolean; - form?: { - text: string; - cw?: string; - }; + form?: PostFormPropsForAsUi; }; export type AsUiPostForm = AsUiComponentBase & { type: 'postForm'; - form?: { - text: string; - cw?: string; - }; + form?: PostFormPropsForAsUi; }; export type AsUiComponent = AsUiRoot | AsUiContainer | AsUiText | AsUiMfm | AsUiButton | AsUiButtons | AsUiSwitch | AsUiTextarea | AsUiTextInput | AsUiNumberInput | AsUiSelect | AsUiFolder | AsUiPostFormButton | AsUiPostForm; @@ -447,6 +449,24 @@ function getFolderOptions(def: values.Value | undefined): Omit Promise): Omit { utils.assertObject(def); @@ -459,22 +479,11 @@ function getPostFormButtonOptions(def: values.Value | undefined, call: (fn: valu const form = def.value.get('form'); if (form) utils.assertObject(form); - const getForm = () => { - const text = form!.value.get('text'); - utils.assertString(text); - const cw = form!.value.get('cw'); - if (cw) utils.assertString(cw); - return { - text: text.value, - cw: cw?.value, - }; - }; - return { text: text?.value, primary: primary?.value, rounded: rounded?.value, - form: form ? getForm() : { + form: form ? getPostFormProps(form) : { text: '', }, }; @@ -486,19 +495,8 @@ function getPostFormOptions(def: values.Value | undefined, call: (fn: values.VFn const form = def.value.get('form'); if (form) utils.assertObject(form); - const getForm = () => { - const text = form!.value.get('text'); - utils.assertString(text); - const cw = form!.value.get('cw'); - if (cw) utils.assertString(cw); - return { - text: text.value, - cw: cw?.value, - }; - }; - return { - form: form ? getForm() : { + form: form ? getPostFormProps(form) : { text: '', }, }; From aa6ecb4c2bace308a5b3c83d8af5cc73ab5ca9da Mon Sep 17 00:00:00 2001 From: kakkokari-gtyih <67428053+kakkokari-gtyih@users.noreply.github.com> Date: Fri, 3 May 2024 15:26:56 +0900 Subject: [PATCH 2/2] Update Changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1f3ae412effb..c54fa6ed78c2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -38,6 +38,7 @@ - Enhance: フォローするかどうかの確認ダイアログを出せるように - Enhance: Playを手動でリロードできるように - Enhance: 通報のコメント内のリンクをクリックした際、ウィンドウで開くように +- Enhance: `Ui:C:postForm` および `Ui:C:postFormButton` に `localOnly` と `visibility` を設定できるように - Chore: AiScriptを0.18.0にバージョンアップ - Fix: 一部のページ内リンクが正しく動作しない問題を修正 - Fix: 周年の実績が閏年を考慮しない問題を修正