enhance(client): 投稿フォームをちょっといい感じに (#10442)

* .formラッパーを削除

* fix type of MkPostFormAttaches

* 🚀

* 🎨

* 🎨

* 🎨

* 🎨

* specifiedの時は連合なしをdisabledに

* ✌️

* set select default

* gap: 2px (max-width: 500px) / 4px

* wip

* ✌️

* 🎨

* fix maxTextLength

* 今後表示しない

* 🎨

* cache channel

* 🎨

* 連合なしにする

* use i18n.ts.neverShow

* ✌️

* refactor

* fix indent

* tweak

---------

Co-authored-by: syuilo <Syuilotan@yahoo.co.jp>
This commit is contained in:
tamaina 2023-04-05 14:30:03 +09:00 committed by GitHub
parent d739aeee32
commit 6798effbab
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 338 additions and 211 deletions

View file

@ -961,7 +961,9 @@ copyErrorInfo: "エラー情報をコピー"
joinThisServer: "このサーバーに登録する" joinThisServer: "このサーバーに登録する"
exploreOtherServers: "他のサーバーを探す" exploreOtherServers: "他のサーバーを探す"
letsLookAtTimeline: "タイムラインを見てみる" letsLookAtTimeline: "タイムラインを見てみる"
disableFederationWarn: "連合が無効になっています。無効にしても投稿が非公開にはなりません。ほとんどの場合、このオプションを有効にする必要はありません。" disableFederationConfirm: "連合なしにしますか?"
disableFederationConfirmWarn: "連合なしにしても投稿は非公開になりません。ほとんどの場合、連合なしにする必要はありません。"
disableFederationOk: "連合なしにする"
invitationRequiredToRegister: "現在このサーバーは招待制です。招待コードをお持ちの方のみ登録できます。" invitationRequiredToRegister: "現在このサーバーは招待制です。招待コードをお持ちの方のみ登録できます。"
emailNotSupported: "このサーバーではメール配信はサポートされていません" emailNotSupported: "このサーバーではメール配信はサポートされていません"
postToTheChannel: "チャンネルに投稿" postToTheChannel: "チャンネルに投稿"

View file

@ -36,7 +36,7 @@
<MkButton v-if="showCancelButton || input || select" inline @click="cancel">{{ cancelText ?? i18n.ts.cancel }}</MkButton> <MkButton v-if="showCancelButton || input || select" inline @click="cancel">{{ cancelText ?? i18n.ts.cancel }}</MkButton>
</div> </div>
<div v-if="actions" :class="$style.buttons"> <div v-if="actions" :class="$style.buttons">
<MkButton v-for="action in actions" :key="action.text" inline :primary="action.primary" @click="() => { action.callback(); modal?.close(); }">{{ action.text }}</MkButton> <MkButton v-for="action in actions" :key="action.text" inline :primary="action.primary" :danger="action.danger" @click="() => { action.callback(); modal?.close(); }">{{ action.text }}</MkButton>
</div> </div>
</div> </div>
</MkModal> </MkModal>
@ -84,6 +84,7 @@ const props = withDefaults(defineProps<{
actions?: { actions?: {
text: string; text: string;
primary?: boolean, primary?: boolean,
danger?: boolean,
callback: (...args: any[]) => void; callback: (...args: any[]) => void;
}[]; }[];
showOkButton?: boolean; showOkButton?: boolean;

View file

@ -31,7 +31,7 @@
<i v-else-if="note.visibility === 'followers'" class="ti ti-lock"></i> <i v-else-if="note.visibility === 'followers'" class="ti ti-lock"></i>
<i v-else-if="note.visibility === 'specified'" ref="specified" class="ti ti-mail"></i> <i v-else-if="note.visibility === 'specified'" ref="specified" class="ti ti-mail"></i>
</span> </span>
<span v-if="note.localOnly" style="margin-left: 0.5em;" :title="i18n.ts._visibility['disableFederation']"><i class="ti ti-world-off"></i></span> <span v-if="note.localOnly" style="margin-left: 0.5em;" :title="i18n.ts._visibility['disableFederation']"><i class="ti ti-rocket-off"></i></span>
<span v-if="note.channel" style="margin-left: 0.5em;" :title="note.channel.name"><i class="ti ti-device-tv"></i></span> <span v-if="note.channel" style="margin-left: 0.5em;" :title="note.channel.name"><i class="ti ti-device-tv"></i></span>
</div> </div>
</div> </div>

View file

@ -30,7 +30,7 @@
<i v-else-if="note.visibility === 'followers'" class="ti ti-lock"></i> <i v-else-if="note.visibility === 'followers'" class="ti ti-lock"></i>
<i v-else-if="note.visibility === 'specified'" ref="specified" class="ti ti-mail"></i> <i v-else-if="note.visibility === 'specified'" ref="specified" class="ti ti-mail"></i>
</span> </span>
<span v-if="note.localOnly" style="margin-left: 0.5em;" :title="i18n.ts._visibility['disableFederation']"><i class="ti ti-world-off"></i></span> <span v-if="note.localOnly" style="margin-left: 0.5em;" :title="i18n.ts._visibility['disableFederation']"><i class="ti ti-rocket-off"></i></span>
</div> </div>
</div> </div>
<article class="article" @contextmenu.stop="onContextmenu"> <article class="article" @contextmenu.stop="onContextmenu">
@ -48,7 +48,7 @@
<i v-else-if="appearNote.visibility === 'followers'" class="ti ti-lock"></i> <i v-else-if="appearNote.visibility === 'followers'" class="ti ti-lock"></i>
<i v-else-if="appearNote.visibility === 'specified'" ref="specified" class="ti ti-mail"></i> <i v-else-if="appearNote.visibility === 'specified'" ref="specified" class="ti ti-mail"></i>
</span> </span>
<span v-if="appearNote.localOnly" style="margin-left: 0.5em;" :title="i18n.ts._visibility['disableFederation']"><i class="ti ti-world-off"></i></span> <span v-if="appearNote.localOnly" style="margin-left: 0.5em;" :title="i18n.ts._visibility['disableFederation']"><i class="ti ti-rocket-off"></i></span>
</div> </div>
</div> </div>
<div class="username"><MkAcct :user="appearNote.user"/></div> <div class="username"><MkAcct :user="appearNote.user"/></div>

View file

@ -17,7 +17,7 @@
<i v-else-if="note.visibility === 'followers'" class="ti ti-lock"></i> <i v-else-if="note.visibility === 'followers'" class="ti ti-lock"></i>
<i v-else-if="note.visibility === 'specified'" ref="specified" class="ti ti-mail"></i> <i v-else-if="note.visibility === 'specified'" ref="specified" class="ti ti-mail"></i>
</span> </span>
<span v-if="note.localOnly" style="margin-left: 0.5em;" :title="i18n.ts._visibility['disableFederation']"><i class="ti ti-world-off"></i></span> <span v-if="note.localOnly" style="margin-left: 0.5em;" :title="i18n.ts._visibility['disableFederation']"><i class="ti ti-rocket-off"></i></span>
<span v-if="note.channel" style="margin-left: 0.5em;" :title="note.channel.name"><i class="ti ti-device-tv"></i></span> <span v-if="note.channel" style="margin-left: 0.5em;" :title="note.channel.name"><i class="ti ti-device-tv"></i></span>
</div> </div>
</header> </header>

View file

@ -3,7 +3,7 @@
<MkAvatar :class="$style.avatar" :user="$i" link preview/> <MkAvatar :class="$style.avatar" :user="$i" link preview/>
<div :class="$style.main"> <div :class="$style.main">
<div :class="$style.header"> <div :class="$style.header">
<MkUserName :user="$i"/> <MkUserName :user="$i" :nowrap="true"/>
</div> </div>
<div> <div>
<div :class="$style.content"> <div :class="$style.content">
@ -50,6 +50,9 @@ const props = defineProps<{
.header { .header {
margin-bottom: 2px; margin-bottom: 2px;
font-weight: bold; font-weight: bold;
width: 100%;
overflow: clip;
text-overflow: ellipsis;
} }
@container (min-width: 350px) { @container (min-width: 350px) {

View file

@ -7,20 +7,35 @@
@drop.stop="onDrop" @drop.stop="onDrop"
> >
<header :class="$style.header"> <header :class="$style.header">
<button v-if="!fixed" :class="$style.cancel" class="_button" @click="cancel"><i class="ti ti-x"></i></button> <div :class="$style.headerLeft">
<button v-click-anime v-tooltip="i18n.ts.switchAccount" :class="$style.account" class="_button" @click="openAccountMenu"> <button v-if="!fixed" :class="$style.cancel" class="_button" @click="cancel"><i class="ti ti-x"></i></button>
<MkAvatar :user="postAccount ?? $i" :class="$style.avatar"/> <button v-click-anime v-tooltip="i18n.ts.switchAccount" :class="$style.account" class="_button" @click="openAccountMenu">
</button> <MkAvatar :user="postAccount ?? $i" :class="$style.avatar"/>
<div :class="$style.headerRight"> </button>
<span :class="[$style.textCount, { [$style.textOver]: textLength > maxTextLength }]">{{ maxTextLength - textLength }}</span> </div>
<span v-if="localOnly" :class="$style.localOnly"><i class="ti ti-world-off"></i></span> <div :class="$style.headerRight">
<button ref="visibilityButton" v-tooltip="i18n.ts.visibility" class="_button" :class="$style.visibility" :disabled="channel != null" @click="setVisibility"> <template v-if="!(channel != null && fixed)">
<span v-if="visibility === 'public'"><i class="ti ti-world"></i></span> <button v-if="channel == null" ref="visibilityButton" v-click-anime v-tooltip="i18n.ts.visibility" :class="['_button', $style.headerRightItem, $style.visibility]" @click="setVisibility">
<span v-if="visibility === 'home'"><i class="ti ti-home"></i></span> <span v-if="visibility === 'public'"><i class="ti ti-world"></i></span>
<span v-if="visibility === 'followers'"><i class="ti ti-lock"></i></span> <span v-if="visibility === 'home'"><i class="ti ti-home"></i></span>
<span v-if="visibility === 'specified'"><i class="ti ti-mail"></i></span> <span v-if="visibility === 'followers'"><i class="ti ti-lock"></i></span>
<span v-if="visibility === 'specified'"><i class="ti ti-mail"></i></span>
<span :class="$style.headerRightButtonText">{{ i18n.ts._visibility[visibility] }}</span>
</button>
<button v-else :class="['_button', $style.headerRightItem, $style.visibility]" disabled>
<span><i class="ti ti-device-tv"></i></span>
<span :class="$style.headerRightButtonText">{{ channel.name }}</span>
</button>
</template>
<button v-click-anime v-tooltip="i18n.ts._visibility.disableFederation" :class="['_button', $style.headerRightItem, $style.localOnly, { [$style.danger]: localOnly }]" :disabled="channel != null || visibility === 'specified'" @click="toggleLocalOnly">
<span v-if="!localOnly"><i class="ti ti-rocket"></i></span>
<span v-else><i class="ti ti-rocket-off"></i></span>
</button>
<button v-click-anime v-tooltip="i18n.ts.reactionAcceptance" :class="['_button', $style.headerRightItem, $style.reactionAcceptance, { [$style.danger]: reactionAcceptance }]" @click="toggleReactionAcceptance">
<span v-if="reactionAcceptance === 'likeOnly'"><i class="ti ti-heart"></i></span>
<span v-else-if="reactionAcceptance === 'likeOnlyForRemote'"><i class="ti ti-heart-plus"></i></span>
<span v-else><i class="ti ti-icons"></i></span>
</button> </button>
<button v-tooltip="i18n.ts.previewNoteText" class="_button" :class="[$style.previewButton, { [$style.previewButtonActive]: showPreview }]" @click="showPreview = !showPreview"><i class="ti ti-eye"></i></button>
<button v-click-anime class="_button" :class="[$style.submit, { [$style.submitPosting]: posting }]" :disabled="!canPost" data-cy-open-post-form-submit @click="post"> <button v-click-anime class="_button" :class="[$style.submit, { [$style.submitPosting]: posting }]" :disabled="!canPost" data-cy-open-post-form-submit @click="post">
<div :class="$style.submitInner"> <div :class="$style.submitInner">
<template v-if="posted"></template> <template v-if="posted"></template>
@ -31,50 +46,49 @@
</button> </button>
</div> </div>
</header> </header>
<div :class="[$style.form]"> <MkNoteSimple v-if="reply" :class="$style.targetNote" :note="reply"/>
<MkNoteSimple v-if="reply" :class="$style.targetNote" :note="reply"/> <MkNoteSimple v-if="renote" :class="$style.targetNote" :note="renote"/>
<MkNoteSimple v-if="renote" :class="$style.targetNote" :note="renote"/> <div v-if="quoteId" :class="$style.withQuote"><i class="ti ti-quote"></i> {{ i18n.ts.quoteAttached }}<button @click="quoteId = null"><i class="ti ti-x"></i></button></div>
<div v-if="quoteId" :class="$style.withQuote"><i class="ti ti-quote"></i> {{ i18n.ts.quoteAttached }}<button @click="quoteId = null"><i class="ti ti-x"></i></button></div> <div v-if="visibility === 'specified'" :class="$style.toSpecified">
<div v-if="visibility === 'specified'" :class="$style.toSpecified"> <span style="margin-right: 8px;">{{ i18n.ts.recipient }}</span>
<span style="margin-right: 8px;">{{ i18n.ts.recipient }}</span> <div :class="$style.visibleUsers">
<div :class="$style.visibleUsers"> <span v-for="u in visibleUsers" :key="u.id" :class="$style.visibleUser">
<span v-for="u in visibleUsers" :key="u.id" :class="$style.visibleUser"> <MkAcct :user="u"/>
<MkAcct :user="u"/> <button class="_button" style="padding: 4px 8px;" @click="removeVisibleUser(u)"><i class="ti ti-x"></i></button>
<button class="_button" style="padding: 4px 8px;" @click="removeVisibleUser(u)"><i class="ti ti-x"></i></button> </span>
</span> <button class="_buttonPrimary" style="padding: 4px; border-radius: 8px;" @click="addVisibleUser"><i class="ti ti-plus ti-fw"></i></button>
<button class="_buttonPrimary" style="padding: 4px; border-radius: 8px;" @click="addVisibleUser"><i class="ti ti-plus ti-fw"></i></button>
</div>
</div> </div>
<MkInfo v-if="localOnly && channel == null" warn :class="$style.disableFederationWarn">{{ i18n.ts.disableFederationWarn }}</MkInfo> </div>
<MkInfo v-if="hasNotSpecifiedMentions" warn :class="$style.hasNotSpecifiedMentions">{{ i18n.ts.notSpecifiedMentionWarning }} - <button class="_textButton" @click="addMissingMention()">{{ i18n.ts.add }}</button></MkInfo> <MkInfo v-if="hasNotSpecifiedMentions" warn :class="$style.hasNotSpecifiedMentions">{{ i18n.ts.notSpecifiedMentionWarning }} - <button class="_textButton" @click="addMissingMention()">{{ i18n.ts.add }}</button></MkInfo>
<input v-show="useCw" ref="cwInputEl" v-model="cw" :class="$style.cw" :placeholder="i18n.ts.annotation" @keydown="onKeydown"> <input v-show="useCw" ref="cwInputEl" v-model="cw" :class="$style.cw" :placeholder="i18n.ts.annotation" @keydown="onKeydown">
<textarea ref="textareaEl" v-model="text" :class="[$style.text, { [$style.withCw]: useCw }]" :disabled="posting || posted" :placeholder="placeholder" data-cy-post-form-text @keydown="onKeydown" @paste="onPaste" @compositionupdate="onCompositionUpdate" @compositionend="onCompositionEnd"/> <div :class="[$style.textOuter, { [$style.withCw]: useCw }]">
<input v-show="withHashtags" ref="hashtagsInputEl" v-model="hashtags" :class="$style.hashtags" :placeholder="i18n.ts.hashtags" list="hashtags"> <textarea ref="textareaEl" v-model="text" :class="[$style.text]" :disabled="posting || posted" :placeholder="placeholder" data-cy-post-form-text @keydown="onKeydown" @paste="onPaste" @compositionupdate="onCompositionUpdate" @compositionend="onCompositionEnd"/>
<XPostFormAttaches v-model="files" :class="$style.attaches" @detach="detachFile" @change-sensitive="updateFileSensitive" @change-name="updateFileName"/> <div v-if="maxTextLength - textLength < 100" :class="['_acrylic', $style.textCount, { [$style.textOver]: textLength > maxTextLength }]">{{ maxTextLength - textLength }}</div>
<MkPollEditor v-if="poll" v-model="poll" @destroyed="poll = null"/> </div>
<MkNotePreview v-if="showPreview" :class="$style.preview" :text="text"/> <input v-show="withHashtags" ref="hashtagsInputEl" v-model="hashtags" :class="$style.hashtags" :placeholder="i18n.ts.hashtags" list="hashtags">
<div v-if="showingOptions" style="padding: 0 16px;"> <XPostFormAttaches v-model="files" :class="$style.attaches" @detach="detachFile" @change-sensitive="updateFileSensitive" @change-name="updateFileName"/>
<MkSelect v-model="reactionAcceptance" small> <MkPollEditor v-if="poll" v-model="poll" @destroyed="poll = null"/>
<template #label>{{ i18n.ts.reactionAcceptance }}</template> <MkNotePreview v-if="showPreview" :class="$style.preview" :text="text"/>
<option :value="null">{{ i18n.ts.all }}</option> <div v-if="showingOptions" style="padding: 8px 16px;">
<option value="likeOnly">{{ i18n.ts.likeOnly }}</option> </div>
<option value="likeOnlyForRemote">{{ i18n.ts.likeOnlyForRemote }}</option> <footer :class="$style.footer">
</MkSelect> <div :class="$style.footerLeft">
</div>
<button v-tooltip="i18n.ts.emoji" class="_button" :class="$style.emojiButton" @click="insertEmoji"><i class="ti ti-mood-happy"></i></button>
<footer :class="$style.footer">
<button v-tooltip="i18n.ts.attachFile" class="_button" :class="$style.footerButton" @click="chooseFileFrom"><i class="ti ti-photo-plus"></i></button> <button v-tooltip="i18n.ts.attachFile" class="_button" :class="$style.footerButton" @click="chooseFileFrom"><i class="ti ti-photo-plus"></i></button>
<button v-tooltip="i18n.ts.poll" class="_button" :class="[$style.footerButton, { [$style.footerButtonActive]: poll }]" @click="togglePoll"><i class="ti ti-chart-arrows"></i></button> <button v-tooltip="i18n.ts.poll" class="_button" :class="[$style.footerButton, { [$style.footerButtonActive]: poll }]" @click="togglePoll"><i class="ti ti-chart-arrows"></i></button>
<button v-tooltip="i18n.ts.useCw" class="_button" :class="[$style.footerButton, { [$style.footerButtonActive]: useCw }]" @click="useCw = !useCw"><i class="ti ti-eye-off"></i></button> <button v-tooltip="i18n.ts.useCw" class="_button" :class="[$style.footerButton, { [$style.footerButtonActive]: useCw }]" @click="useCw = !useCw"><i class="ti ti-eye-off"></i></button>
<button v-tooltip="i18n.ts.mention" class="_button" :class="$style.footerButton" @click="insertMention"><i class="ti ti-at"></i></button> <button v-tooltip="i18n.ts.mention" class="_button" :class="$style.footerButton" @click="insertMention"><i class="ti ti-at"></i></button>
<button v-tooltip="i18n.ts.hashtags" class="_button" :class="[$style.footerButton, { [$style.footerButtonActive]: withHashtags }]" @click="withHashtags = !withHashtags"><i class="ti ti-hash"></i></button> <button v-tooltip="i18n.ts.hashtags" class="_button" :class="[$style.footerButton, { [$style.footerButtonActive]: withHashtags }]" @click="withHashtags = !withHashtags"><i class="ti ti-hash"></i></button>
<button v-if="postFormActions.length > 0" v-tooltip="i18n.ts.plugin" class="_button" :class="$style.footerButton" @click="showActions"><i class="ti ti-plug"></i></button> <button v-if="postFormActions.length > 0" v-tooltip="i18n.ts.plugin" class="_button" :class="$style.footerButton" @click="showActions"><i class="ti ti-plug"></i></button>
<button v-tooltip="i18n.ts.more" class="_button" :class="$style.footerButton" @click="showingOptions = !showingOptions"><i class="ti ti-dots"></i></button> <button v-tooltip="i18n.ts.emoji" :class="['_button', $style.footerButton]" @click="insertEmoji"><i class="ti ti-mood-happy"></i></button>
</footer> </div>
<datalist id="hashtags"> <div :class="$style.footerRight">
<option v-for="hashtag in recentHashtags" :key="hashtag" :value="hashtag"/> <button v-tooltip="i18n.ts.previewNoteText" class="_button" :class="[$style.footerButton, { [$style.previewButtonActive]: showPreview }]" @click="showPreview = !showPreview"><i class="ti ti-eye"></i></button>
</datalist> <!--<button v-tooltip="i18n.ts.more" class="_button" :class="$style.footerButton" @click="showingOptions = !showingOptions"><i class="ti ti-dots"></i></button>-->
</div> </div>
</footer>
<datalist id="hashtags">
<option v-for="hashtag in recentHashtags" :key="hashtag" :value="hashtag"/>
</datalist>
</div> </div>
</template> </template>
@ -85,7 +99,6 @@ import * as misskey from 'misskey-js';
import insertTextAtCursor from 'insert-text-at-cursor'; import insertTextAtCursor from 'insert-text-at-cursor';
import { toASCII } from 'punycode/'; import { toASCII } from 'punycode/';
import * as Acct from 'misskey-js/built/acct'; import * as Acct from 'misskey-js/built/acct';
import MkSelect from './MkSelect.vue';
import MkNoteSimple from '@/components/MkNoteSimple.vue'; import MkNoteSimple from '@/components/MkNoteSimple.vue';
import MkNotePreview from '@/components/MkNotePreview.vue'; import MkNotePreview from '@/components/MkNotePreview.vue';
import XPostFormAttaches from '@/components/MkPostFormAttaches.vue'; import XPostFormAttaches from '@/components/MkPostFormAttaches.vue';
@ -113,7 +126,7 @@ const modal = inject('modal');
const props = withDefaults(defineProps<{ const props = withDefaults(defineProps<{
reply?: misskey.entities.Note; reply?: misskey.entities.Note;
renote?: misskey.entities.Note; renote?: misskey.entities.Note;
channel?: any; // TODO channel?: misskey.entities.Channel; // TODO
mention?: misskey.entities.User; mention?: misskey.entities.User;
specified?: misskey.entities.User; specified?: misskey.entities.User;
initialText?: string; initialText?: string;
@ -401,13 +414,14 @@ function upload(file: File, name?: string) {
function setVisibility() { function setVisibility() {
if (props.channel) { if (props.channel) {
// TODO: information dialog visibility = 'public';
localOnly = true; // TODO:
return; return;
} }
os.popup(defineAsyncComponent(() => import('@/components/MkVisibilityPicker.vue')), { os.popup(defineAsyncComponent(() => import('@/components/MkVisibilityPicker.vue')), {
currentVisibility: visibility, currentVisibility: visibility,
currentLocalOnly: localOnly, localOnly: localOnly,
src: visibilityButton, src: visibilityButton,
}, { }, {
changeVisibility: v => { changeVisibility: v => {
@ -416,15 +430,65 @@ function setVisibility() {
defaultStore.set('visibility', visibility); defaultStore.set('visibility', visibility);
} }
}, },
changeLocalOnly: v => {
localOnly = v;
if (defaultStore.state.rememberNoteVisibility) {
defaultStore.set('localOnly', localOnly);
}
},
}, 'closed'); }, 'closed');
} }
async function toggleLocalOnly() {
if (props.channel) {
visibility = 'public';
localOnly = true; // TODO:
return;
}
const neverShowInfo = miLocalStorage.getItem('neverShowLocalOnlyInfo');
if (!localOnly && neverShowInfo !== 'true') {
const confirm = await os.actions({
type: 'question',
title: i18n.ts.disableFederationConfirm,
text: i18n.ts.disableFederationConfirmWarn,
actions: [
{
value: 'yes' as const,
text: i18n.ts.disableFederationOk,
primary: true,
},
{
value: 'neverShow' as const,
text: `${i18n.ts.disableFederationOk} (${i18n.ts.neverShow})`,
danger: true,
},
{
value: 'no' as const,
text: i18n.ts.cancel,
},
],
});
if (confirm.canceled) return;
if (confirm.result === 'no') return;
if (confirm.result === 'neverShow') {
miLocalStorage.setItem('neverShowLocalOnlyInfo', 'true');
}
}
localOnly = !localOnly;
}
async function toggleReactionAcceptance() {
const select = await os.select({
title: i18n.ts.reactionAcceptance,
items: [
{ value: null, text: i18n.ts.all },
{ value: 'likeOnly' as const, text: i18n.ts.likeOnly },
{ value: 'likeOnlyForRemote' as const, text: i18n.ts.likeOnlyForRemote },
],
default: reactionAcceptance,
});
if (select.canceled) return;
reactionAcceptance = select.result;
}
function pushVisibleUser(user) { function pushVisibleUser(user) {
if (!visibleUsers.some(u => u.username === user.username && u.host === user.host)) { if (!visibleUsers.some(u => u.username === user.username && u.host === user.host)) {
visibleUsers.push(user); visibleUsers.push(user);
@ -818,6 +882,7 @@ defineExpose({
<style lang="scss" module> <style lang="scss" module>
.root { .root {
position: relative; position: relative;
container-type: inline-size;
&.modal { &.modal {
width: 100%; width: 100%;
@ -825,21 +890,29 @@ defineExpose({
} }
} }
//#region header
.header { .header {
z-index: 1000; z-index: 1000;
height: 66px; min-height: 50px;
display: flex;
flex-wrap: nowrap;
gap: 4px;
}
.headerLeft {
display: grid;
grid-template-columns: repeat(2, minmax(36px, 50px));
grid-template-rows: minmax(40px, 100%);
} }
.cancel { .cancel {
padding: 0; padding: 0;
font-size: 1em; font-size: 1em;
width: 64px; height: 100%;
line-height: 66px;
} }
.account { .account {
height: 100%; height: 100%;
aspect-ratio: 1/1;
display: inline-flex; display: inline-flex;
vertical-align: bottom; vertical-align: bottom;
} }
@ -847,55 +920,23 @@ defineExpose({
.avatar { .avatar {
width: 28px; width: 28px;
height: 28px; height: 28px;
margin: auto; margin: auto 0;
} }
.headerRight { .headerRight {
position: absolute; display: flex;
top: 0; min-height: 48px;
right: 0; font-size: 0.9em;
} flex-wrap: nowrap;
align-items: center;
.textCount { margin-left: auto;
opacity: 0.7; gap: 4px;
line-height: 66px; overflow: clip;
} padding-left: 4px;
.visibility {
height: 34px;
width: 34px;
margin: 0 0 0 8px;
& + .localOnly {
margin-left: 0 !important;
}
}
.localOnly {
margin: 0 0 0 12px;
opacity: 0.7;
}
.previewButton {
display: inline-block;
padding: 0;
margin: 0 8px 0 0;
font-size: 16px;
width: 34px;
height: 34px;
border-radius: 6px;
&:hover {
background: var(--X5);
}
&.previewButtonActive {
color: var(--accent);
}
} }
.submit { .submit {
margin: 16px 16px 16px 0; margin: 12px 12px 12px 6px;
vertical-align: bottom; vertical-align: bottom;
&:disabled { &:disabled {
@ -924,16 +965,47 @@ defineExpose({
line-height: 34px; line-height: 34px;
font-weight: bold; font-weight: bold;
border-radius: 4px; border-radius: 4px;
font-size: 0.9em;
min-width: 90px; min-width: 90px;
box-sizing: border-box; box-sizing: border-box;
color: var(--fgOnAccent); color: var(--fgOnAccent);
background: linear-gradient(90deg, var(--buttonGradateA), var(--buttonGradateB)); background: linear-gradient(90deg, var(--buttonGradateA), var(--buttonGradateB));
} }
.form { .headerRightItem {
margin: 0;
padding: 8px;
border-radius: 6px;
&:hover {
background: var(--X5);
}
&:disabled {
background: none;
}
&.danger {
color: #ff2a2a;
}
} }
.headerRightButtonText {
padding-left: 6px;
}
.visibility {
overflow: clip;
text-overflow: ellipsis;
white-space: nowrap;
&:enabled {
> .headerRightButtonText {
opacity: 0.8;
}
}
}
//#endregion
.preview { .preview {
padding: 16px 20px 0 20px; padding: 16px 20px 0 20px;
} }
@ -967,10 +1039,6 @@ defineExpose({
background: var(--X4); background: var(--X4);
} }
.disableFederationWarn {
margin: 0 20px 16px 20px;
}
.hasNotSpecifiedMentions { .hasNotSpecifiedMentions {
margin: 0 20px 16px 20px; margin: 0 20px 16px 20px;
} }
@ -1012,18 +1080,61 @@ defineExpose({
border-top: solid 0.5px var(--divider); border-top: solid 0.5px var(--divider);
} }
.text { .textOuter {
max-width: 100%; width: 100%;
min-width: 100%; position: relative;
min-height: 90px;
&.withCw { &.withCw {
padding-top: 8px; padding-top: 8px;
} }
} }
.text {
max-width: 100%;
min-width: 100%;
width: 100%;
min-height: 90px;
height: 100%;
}
.textCount {
position: absolute;
top: 0;
right: 2px;
padding: 4px 6px;
font-size: .9em;
color: var(--warn);
border-radius: 6px;
min-width: 1.6em;
text-align: center;
&.textOver {
color: #ff2a2a;
}
}
.footer { .footer {
display: flex;
padding: 0 16px 16px 16px; padding: 0 16px 16px 16px;
font-size: 1em;
}
.footerLeft {
flex: 1;
display: grid;
grid-auto-flow: row;
grid-template-columns: repeat(auto-fill, minmax(42px, 1fr));
grid-auto-rows: 46px;
}
.footerRight {
flex: 0.5;
margin-left: auto;
display: grid;
grid-auto-flow: row;
grid-template-columns: repeat(auto-fill, minmax(42px, 1fr));
grid-auto-rows: 46px;
direction: rtl;
} }
.footerButton { .footerButton {
@ -1031,8 +1142,8 @@ defineExpose({
padding: 0; padding: 0;
margin: 0; margin: 0;
font-size: 1em; font-size: 1em;
width: 46px; width: auto;
height: 46px; height: 100%;
border-radius: 6px; border-radius: 6px;
&:hover { &:hover {
@ -1044,42 +1155,34 @@ defineExpose({
} }
} }
.emojiButton { .previewButtonActive {
position: absolute; color: var(--accent);
top: 55px;
right: 13px;
display: inline-block;
padding: 0;
margin: 0;
font-size: 1em;
width: 32px;
height: 32px;
} }
@container (max-width: 500px) { @container (max-width: 500px) {
.header { .headerRight {
height: 50px; font-size: .9em;
}
> .cancel { .headerRightButtonText {
width: 50px; display: none;
line-height: 50px; }
}
> .headerRight { .visibility {
> .textCount { overflow: initial;
line-height: 50px; }
}
> .submit { .submit {
margin: 8px; margin: 8px 8px 8px 4px;
}
}
} }
.toSpecified { .toSpecified {
padding: 6px 16px; padding: 6px 16px;
} }
.preview {
padding: 16px 14px 0 14px;
}
.cw, .cw,
.hashtags, .hashtags,
.text { .text {
@ -1095,11 +1198,13 @@ defineExpose({
} }
} }
@container (max-width: 310px) { @container (max-width: 330px) {
.footerButton { .headerRight {
gap: 0;
}
.footer {
font-size: 14px; font-size: 14px;
width: 44px;
height: 44px;
} }
} }
</style> </style>

View file

@ -24,19 +24,19 @@ const Sortable = defineAsyncComponent(() => import('vuedraggable').then(x => x.d
const props = defineProps<{ const props = defineProps<{
modelValue: any[]; modelValue: any[];
detachMediaFn: () => void; detachMediaFn?: (id: string) => void;
}>(); }>();
const emit = defineEmits<{ const emit = defineEmits<{
(ev: 'update:modelValue', value: any[]): void; (ev: 'update:modelValue', value: any[]): void;
(ev: 'detach'): void; (ev: 'detach', id: string): void;
(ev: 'changeSensitive'): void; (ev: 'changeSensitive'): void;
(ev: 'changeName'): void; (ev: 'changeName'): void;
}>(); }>();
let menuShowing = false; let menuShowing = false;
function detachMedia(id) { function detachMedia(id: string) {
if (props.detachMediaFn) { if (props.detachMediaFn) {
props.detachMediaFn(id); props.detachMediaFn(id);
} else { } else {

View file

@ -1,6 +1,9 @@
<template> <template>
<MkModal ref="modal" :z-priority="'high'" :src="src" @click="modal.close()" @closed="emit('closed')"> <MkModal ref="modal" v-slot="{ type }" :z-priority="'high'" :src="src" @click="modal.close()" @closed="emit('closed')">
<div class="_popup" :class="$style.root"> <div class="_popup" :class="{ [$style.root]: true, [$style.asDrawer]: type === 'drawer' }">
<div :class="[$style.label, $style.item]">
{{ i18n.ts.visibility }}
</div>
<button key="public" class="_button" :class="[$style.item, { [$style.active]: v === 'public' }]" data-index="1" @click="choose('public')"> <button key="public" class="_button" :class="[$style.item, { [$style.active]: v === 'public' }]" data-index="1" @click="choose('public')">
<div :class="$style.icon"><i class="ti ti-world"></i></div> <div :class="$style.icon"><i class="ti ti-world"></i></div>
<div :class="$style.body"> <div :class="$style.body">
@ -29,21 +32,12 @@
<span :class="$style.itemDescription">{{ i18n.ts._visibility.specifiedDescription }}</span> <span :class="$style.itemDescription">{{ i18n.ts._visibility.specifiedDescription }}</span>
</div> </div>
</button> </button>
<div :class="$style.divider"></div>
<button key="localOnly" class="_button" :class="[$style.item, $style.localOnly, { [$style.active]: localOnly }]" data-index="5" @click="localOnly = !localOnly">
<div :class="$style.icon"><i class="ti ti-world-off"></i></div>
<div :class="$style.body">
<span :class="$style.itemTitle">{{ i18n.ts._visibility.disableFederation }}</span>
<span :class="$style.itemDescription">{{ i18n.ts._visibility.disableFederationDescription }}</span>
</div>
<div :class="$style.toggle"><i :class="localOnly ? 'ti ti-toggle-right' : 'ti ti-toggle-left'"></i></div>
</button>
</div> </div>
</MkModal> </MkModal>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import { nextTick, watch } from 'vue'; import { nextTick } from 'vue';
import * as misskey from 'misskey-js'; import * as misskey from 'misskey-js';
import MkModal from '@/components/MkModal.vue'; import MkModal from '@/components/MkModal.vue';
import { i18n } from '@/i18n'; import { i18n } from '@/i18n';
@ -52,42 +46,58 @@ const modal = $shallowRef<InstanceType<typeof MkModal>>();
const props = withDefaults(defineProps<{ const props = withDefaults(defineProps<{
currentVisibility: typeof misskey.noteVisibilities[number]; currentVisibility: typeof misskey.noteVisibilities[number];
currentLocalOnly: boolean; localOnly: boolean;
src?: HTMLElement; src?: HTMLElement;
}>(), { }>(), {
}); });
const emit = defineEmits<{ const emit = defineEmits<{
(ev: 'changeVisibility', v: typeof misskey.noteVisibilities[number]): void; (ev: 'changeVisibility', v: typeof misskey.noteVisibilities[number]): void;
(ev: 'changeLocalOnly', v: boolean): void;
(ev: 'closed'): void; (ev: 'closed'): void;
}>(); }>();
let v = $ref(props.currentVisibility); let v = $ref(props.currentVisibility);
let localOnly = $ref(props.currentLocalOnly);
watch($$(localOnly), () => {
emit('changeLocalOnly', localOnly);
});
function choose(visibility: typeof misskey.noteVisibilities[number]): void { function choose(visibility: typeof misskey.noteVisibilities[number]): void {
v = visibility; v = visibility;
emit('changeVisibility', visibility); emit('changeVisibility', visibility);
nextTick(() => { nextTick(() => {
modal.close(); if (modal) modal.close();
}); });
} }
</script> </script>
<style lang="scss" module> <style lang="scss" module>
.root { .root {
width: 240px; min-width: 240px;
padding: 8px 0; padding: 8px 0;
&.asDrawer {
padding: 12px 0 max(env(safe-area-inset-bottom, 0px), 12px) 0;
width: 100%;
border-radius: 24px;
border-bottom-right-radius: 0;
border-bottom-left-radius: 0;
.label {
pointer-events: none;
font-size: 12px;
padding-bottom: 4px;
opacity: 0.7;
}
.item {
font-size: 14px;
padding: 10px 24px;
}
}
} }
.divider { .label {
margin: 8px 0; pointer-events: none;
border-top: solid 0.5px var(--divider); font-size: 10px;
padding-bottom: 4px;
opacity: 0.7;
} }
.item { .item {
@ -107,13 +117,7 @@ function choose(visibility: typeof misskey.noteVisibilities[number]): void {
} }
&.active { &.active {
color: var(--fgOnAccent);
background: var(--accent);
}
&.localOnly.active {
color: var(--accent); color: var(--accent);
background: inherit;
} }
} }
@ -144,16 +148,4 @@ function choose(visibility: typeof misskey.noteVisibilities[number]): void {
.itemDescription { .itemDescription {
opacity: 0.6; opacity: 0.6;
} }
.toggle {
display: flex;
justify-content: center;
align-items: center;
margin-left: 10px;
width: 16px;
top: 0;
bottom: 0;
margin-top: auto;
margin-bottom: auto;
}
</style> </style>

View file

@ -6,6 +6,7 @@ type Keys =
'accounts' | 'accounts' |
'latestDonationInfoShownAt' | 'latestDonationInfoShownAt' |
'neverShowDonationInfo' | 'neverShowDonationInfo' |
'neverShowLocalOnlyInfo' |
'lastUsed' | 'lastUsed' |
'lang' | 'lang' |
'drafts' | 'drafts' |

View file

@ -215,6 +215,7 @@ export function actions<T extends {
value: string; value: string;
text: string; text: string;
primary?: boolean, primary?: boolean,
danger?: boolean,
}[]>(props: { }[]>(props: {
type: 'error' | 'info' | 'success' | 'warning' | 'waiting' | 'question'; type: 'error' | 'info' | 'success' | 'warning' | 'waiting' | 'question';
title?: string | null; title?: string | null;
@ -229,6 +230,7 @@ export function actions<T extends {
actions: props.actions.map(a => ({ actions: props.actions.map(a => ({
text: a.text, text: a.text,
primary: a.primary, primary: a.primary,
danger: a.danger,
callback: () => { callback: () => {
resolve({ canceled: false, result: a.value }); resolve({ canceled: false, result: a.value });
}, },

View file

@ -98,9 +98,7 @@ function edit() {
function openPostForm() { function openPostForm() {
os.post({ os.post({
channel: { channel,
id: channel.id,
},
}); });
} }

View file

@ -88,7 +88,7 @@ export const defaultStore = markRaw(new Storage('base', {
}, },
reactionAcceptance: { reactionAcceptance: {
where: 'account', where: 'account',
default: null, default: null as 'likeOnly' | 'likeOnlyForRemote' | null,
}, },
mutedWords: { mutedWords: {
where: 'account', where: 'account',

View file

@ -14,13 +14,13 @@
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import { } from 'vue';
import XColumn from './column.vue'; import XColumn from './column.vue';
import { updateColumn, Column } from './deck-store'; import { updateColumn, Column } from './deck-store';
import MkTimeline from '@/components/MkTimeline.vue'; import MkTimeline from '@/components/MkTimeline.vue';
import MkButton from '@/components/MkButton.vue'; import MkButton from '@/components/MkButton.vue';
import * as os from '@/os'; import * as os from '@/os';
import { i18n } from '@/i18n'; import { i18n } from '@/i18n';
import * as misskey from 'misskey-js';
const props = defineProps<{ const props = defineProps<{
column: Column; column: Column;
@ -33,6 +33,7 @@ const emit = defineEmits<{
}>(); }>();
let timeline = $shallowRef<InstanceType<typeof MkTimeline>>(); let timeline = $shallowRef<InstanceType<typeof MkTimeline>>();
let channel = $shallowRef<misskey.entities.Channel>();
if (props.column.channelId == null) { if (props.column.channelId == null) {
setChannel(); setChannel();
@ -56,11 +57,15 @@ async function setChannel() {
}); });
} }
function post() { async function post() {
if (!channel || channel.id !== props.column.channelId) {
channel = await os.api('channels/show', {
channelId: props.column.channelId,
});
}
os.post({ os.post({
channel: { channel,
id: props.column.channelId,
},
}); });
} }

View file

@ -2,14 +2,31 @@ import { describe, test, assert, afterEach } from 'vitest';
import { render, cleanup, type RenderResult } from '@testing-library/vue'; import { render, cleanup, type RenderResult } from '@testing-library/vue';
import './init'; import './init';
import type { DriveFile } from 'misskey-js/built/entities'; import type { DriveFile } from 'misskey-js/built/entities';
import { components } from '@/components';
import { directives } from '@/directives'; import { directives } from '@/directives';
import MkMediaImage from '@/components/MkMediaImage.vue'; import MkMediaImage from '@/components/MkMediaImage.vue';
describe('MkMediaImage', () => { describe('MkMediaImage', () => {
const renderMediaImage = (image: Partial<DriveFile>): RenderResult => { const renderMediaImage = (image: Partial<DriveFile>): RenderResult => {
return render(MkMediaImage, { return render(MkMediaImage, {
props: { image }, props: {
global: { directives }, image: {
id: 'xxxxxxxx',
createdAt: (new Date()).toJSON(),
isSensitive: false,
name: 'example.png',
thumbnailUrl: null,
url: '',
type: 'application/octet-stream',
size: 1,
md5: '15eca7fba0480996e2245f5185bf39f2',
blurhash: null,
comment: null,
properties: {},
...image,
} as DriveFile,
},
global: { directives, components },
}); });
}; };

View file

@ -2,6 +2,7 @@ import { describe, test, assert, afterEach } from 'vitest';
import { render, cleanup, type RenderResult } from '@testing-library/vue'; import { render, cleanup, type RenderResult } from '@testing-library/vue';
import './init'; import './init';
import type { summaly } from 'summaly'; import type { summaly } from 'summaly';
import { components } from '@/components';
import { directives } from '@/directives'; import { directives } from '@/directives';
import MkUrlPreview from '@/components/MkUrlPreview.vue'; import MkUrlPreview from '@/components/MkUrlPreview.vue';
@ -27,7 +28,7 @@ describe('MkMediaImage', () => {
const result = render(MkUrlPreview, { const result = render(MkUrlPreview, {
props: { url: summary.url }, props: { url: summary.url },
global: { directives }, global: { directives, components },
}); });
await new Promise<void>(resolve => { await new Promise<void>(resolve => {