Skip to content

Commit

Permalink
PostFormのプレフィックスにVisivilityもしくはチャンネル名を表示
Browse files Browse the repository at this point in the history
  • Loading branch information
tar-bin committed Aug 19, 2023
1 parent 4e6af7f commit 1cc0071
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions packages/frontend/src/components/MkPostForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@
</template>

<script lang="ts" setup>
import { inject, watch, nextTick, computed, onMounted, defineAsyncComponent, onUnmounted, ref } from 'vue';
import { inject, watch, nextTick, computed, onMounted, defineAsyncComponent, onUnmounted, ref, WritableComputedRef } from 'vue';
import * as mfm from 'tfm-js';
import * as misskey from 'misskey-js';
import insertTextAtCursor from 'insert-text-at-cursor';
Expand Down Expand Up @@ -190,7 +190,7 @@ let hasNotSpecifiedMentions = $ref(false);
let recentHashtags = $ref(JSON.parse(miLocalStorage.getItem('hashtags') ?? '[]'));
let imeText = $ref('');
let showingOptions = $ref(false);
let postChannel = computed(defaultStore.makeGetterSetter('postChannel'));
let postChannel: WritableComputedRef<misskey.entities.Channel> = computed(defaultStore.makeGetterSetter('postChannel'));
watch(postChannel, () => {
if (postChannel.value) {
Expand All @@ -217,12 +217,19 @@ const draftKey = $computed((): string => {
});
const placeholder = $computed((): string => {
let postTo = '';
if (postChannel.value) {
postTo = '[' + postChannel.value.name + '] ';
} else {
postTo = '[' + i18n.ts._visibility[visibility] + '] ';
}
if (props.renote) {
return i18n.ts._postForm.quotePlaceholder;
return postTo + i18n.ts._postForm.quotePlaceholder;
} else if (props.reply) {
return i18n.ts._postForm.replyPlaceholder;
return postTo + i18n.ts._postForm.replyPlaceholder;
} else if (postChannel.value) {
return i18n.ts._postForm.channelPlaceholder;
return postTo + i18n.ts._postForm.channelPlaceholder;
} else {
const xs = [
i18n.ts._postForm._placeholders.a,
Expand All @@ -232,7 +239,7 @@ const placeholder = $computed((): string => {
i18n.ts._postForm._placeholders.e,
i18n.ts._postForm._placeholders.f,
];
return xs[Math.floor(Math.random() * xs.length)];
return postTo + xs[Math.floor(Math.random() * xs.length)];
}
});
Expand Down

0 comments on commit 1cc0071

Please sign in to comment.