Skip to content

Commit

Permalink
feat: メディアを含むすべてのノートを省略して表示ことができる
Browse files Browse the repository at this point in the history
  • Loading branch information
noridev committed Oct 1, 2023
1 parent 719d6c9 commit d8f3f7e
Show file tree
Hide file tree
Showing 9 changed files with 40 additions and 8 deletions.
1 change: 1 addition & 0 deletions CHANGELOG_CHERRYPICK.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ Misskey의 전체 변경 사항을 확인하려면, [CHANGELOG.md#2023xx](CHANGE
- Feat: 움직이는 이미지를 표시하는 방법을 세분화
- 마우스를 움직이거나 화면을 터치하고 있으면 이미지를 재생
- 일정 시간이 경과하면 이미지 재생을 중지
- Feat: 미디어가 포함된 모든 노트를 접을 수 있음
- Fix: 로그인하지 않은 상태에서 노트 상세 페이지의 노트 작성 폼을 조작할 수 있음

### Server
Expand Down
1 change: 1 addition & 0 deletions locales/en-US.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
_lang_: "English"
allMediaNoteCollapse: "Collapse all media notes"
showingAnimatedImagesDescription: "When set to \"Animate on interaction\", the image will play when you hover over it or touch it."
showFixedPostFormInReplies: "Show posting form in replies"
showFixedPostFormInRepliesDescription: "Only visible in desktop and tablet environments."
Expand Down
1 change: 1 addition & 0 deletions locales/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// Do not edit this file directly.
export interface Locale {
"_lang_": string;
"allMediaNoteCollapse": string;
"showingAnimatedImagesDescription": string;
"showFixedPostFormInReplies": string;
"showFixedPostFormInRepliesDescription": string;
Expand Down
1 change: 1 addition & 0 deletions locales/ja-JP.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
_lang_: "日本語"

allMediaNoteCollapse: "すべてのメディアノートを省略して表示"
showingAnimatedImagesDescription: "「インタラクト時に再生」に設定すると、画像の上にマウスを置いたり、画像をタッチすると再生されます。"
showFixedPostFormInReplies: "返信に投稿フォームを表示する"
showFixedPostFormInRepliesDescription: "デスクトップとタブレット環境でのみ表示されます。"
Expand Down
1 change: 1 addition & 0 deletions locales/ko-KR.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
_lang_: "한국어"
allMediaNoteCollapse: "모든 미디어 노트 간략화하기"
showingAnimatedImagesDescription: "'건드리면 움직임'으로 설정하면 이미지 위에 마우스를 올리거나 이미지를 터치하면 움직여요."
showFixedPostFormInReplies: "답글에 글 작성란 표시"
showFixedPostFormInRepliesDescription: "데스크톱과 태블릿 환경에서만 표시돼요."
Expand Down
18 changes: 14 additions & 4 deletions packages/frontend/src/components/MkNote.vue
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,13 @@ SPDX-License-Identifier: AGPL-3.0-only
</div>
<MkPoll v-if="appearNote.poll" :note="appearNote" :class="$style.poll"/>
<MkUrlPreview v-for="url in urls" :key="url" :url="url" :compact="true" :detail="false" :class="$style.urlPreview"/>
<button v-if="(isLong || (isMFM && defaultStore.state.collapseDefault)) && collapsed" v-vibrate="5" :class="$style.collapsed" class="_button" @click="collapsed = false">
<span :class="$style.collapsedLabel">{{ i18n.ts.showMore }}</span>
<button v-if="(isLong || (isMFM && defaultStore.state.collapseDefault) || defaultStore.state.allMediaNoteCollapse) && collapsed" v-vibrate="5" :class="$style.collapsed" class="_button" @click="collapsed = false">
<span :class="$style.collapsedLabel">
{{ i18n.ts.showMore }}
<span v-if="appearNote.files.length > 0" :class="$style.label">({{ collapseLabel }})</span>
</span>
</button>
<button v-else-if="(isLong || (isMFM && defaultStore.state.collapseDefault)) && !collapsed" v-vibrate="5" :class="$style.showLess" class="_button" @click="collapsed = true">
<button v-else-if="(isLong || (isMFM && defaultStore.state.collapseDefault) || defaultStore.state.allMediaNoteCollapse) && !collapsed" v-vibrate="5" :class="$style.showLess" class="_button" @click="collapsed = true">
<span :class="$style.showLessLabel">{{ i18n.ts.showLess }}</span>
</button>
</div>
Expand Down Expand Up @@ -212,6 +215,7 @@ import { mainRouter } from '@/router.js';
import { notePage } from '@/filters/note.js';
import { miLocalStorage } from '@/local-storage.js';
import { instance } from '@/instance.js';
import { concat } from '@/scripts/array.js';

let showEl = $ref(false);

Expand Down Expand Up @@ -259,14 +263,20 @@ const showContent = ref(false);
const urls = appearNote.text ? extractUrlFromMfm(mfm.parse(appearNote.text)) : null;
const isLong = shouldCollapsed(appearNote);
const isMFM = shouldMfmCollapsed(appearNote);
const collapsed = ref(appearNote.cw == null && (isLong || (isMFM && defaultStore.state.collapseDefault)));
const collapsed = ref(appearNote.cw == null && (isLong || (isMFM && defaultStore.state.collapseDefault) || defaultStore.state.allMediaNoteCollapse));
const isDeleted = ref(false);
const muted = ref(checkWordMute(appearNote, $i, defaultStore.state.mutedWords));
const translation = ref<any>(null);
const translating = ref(false);
const canRenote = computed(() => ['public', 'home'].includes(appearNote.visibility) || appearNote.userId === $i.id);
let renoteCollapsed = $ref(defaultStore.state.collapseRenotes && isRenote && (($i && ($i.id === note.userId || $i.id === appearNote.userId)) || (appearNote.myReaction != null)));

const collapseLabel = computed(() => {
return concat([
appearNote.files && appearNote.files.length !== 0 ? [i18n.t('_cw.files', { count: appearNote.files.length })] : [],
] as string[][]).join(' / ');
});

const keymap = {
'r': () => reply(true),
'e|a|plus': () => react(true),
Expand Down
18 changes: 14 additions & 4 deletions packages/frontend/src/components/MkSubNoteContent.vue
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,13 @@ SPDX-License-Identifier: AGPL-3.0-only
</div>
</div>
</div>
<button v-if="(isLong || (isMFM && defaultStore.state.collapseDefault)) && collapsed" v-vibrate="5" :class="$style.fade" class="_button" @click="collapsed = false">
<span :class="$style.fadeLabel">{{ i18n.ts.showMore }}</span>
<button v-if="(isLong || (isMFM && defaultStore.state.collapseDefault) || defaultStore.state.allMediaNoteCollapse) && collapsed" v-vibrate="5" :class="$style.fade" class="_button" @click="collapsed = false">
<span :class="$style.fadeLabel">
{{ i18n.ts.showMore }}
<span v-if="note.files.length > 0" :class="$style.label">({{ collapseLabel }})</span>
</span>
</button>
<button v-else-if="(isLong || (isMFM && defaultStore.state.collapseDefault)) && !collapsed" v-vibrate="5" :class="$style.showLess" class="_button" @click="collapsed = true">
<button v-else-if="(isLong || (isMFM && defaultStore.state.collapseDefault) || defaultStore.state.allMediaNoteCollapse) && !collapsed" v-vibrate="5" :class="$style.showLess" class="_button" @click="collapsed = true">
<span :class="$style.showLessLabel">{{ i18n.ts.showLess }}</span>
</button>
<div v-if="showSubNoteFooterButton">
Expand Down Expand Up @@ -124,6 +127,7 @@ import { reactionPicker } from '@/scripts/reaction-picker.js';
import { claimAchievement } from '@/scripts/achievements.js';
import { useNoteCapture } from '@/scripts/use-note-capture.js';
import { MenuItem } from '@/types/menu.js';
import { concat } from '@/scripts/array.js';

const el = shallowRef<HTMLElement>();
const menuButton = shallowRef<HTMLElement>();
Expand All @@ -139,6 +143,12 @@ const showContent = ref(false);
const translation = ref<any>(null);
const translating = ref(false);

const collapseLabel = computed(() => {
return concat([
props.note.files && props.note.files.length !== 0 ? [i18n.t('_cw.files', { count: props.note.files.length })] : [],
] as string[][]).join(' / ');
});

const props = defineProps<{
note: Misskey.entities.Note;
showSubNoteFooterButton: boolean;
Expand All @@ -149,7 +159,7 @@ let note = $ref(deepClone(props.note));
const isLong = shouldCollapsed(props.note);
const isMFM = shouldMfmCollapsed(props.note);

const collapsed = $ref(isLong || (isMFM && defaultStore.state.collapseDefault));
const collapsed = $ref(isLong || (isMFM && defaultStore.state.collapseDefault) || defaultStore.state.allMediaNoteCollapse);

useNoteCapture({
rootEl: el,
Expand Down
3 changes: 3 additions & 0 deletions packages/frontend/src/pages/settings/general.vue
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ SPDX-License-Identifier: AGPL-3.0-only
<MkSwitch v-model="showReplyInNotification">{{ i18n.ts.showReplyInNotification }} <span class="_beta">CherryPick</span></MkSwitch>
<MkSwitch v-model="renoteQuoteButtonSeparation">{{ i18n.ts.renoteQuoteButtonSeparation }} <span class="_beta">CherryPick</span></MkSwitch>
<MkSwitch v-model="showFixedPostFormInReplies">{{ i18n.ts.showFixedPostFormInReplies }}<template #caption>{{ i18n.ts.showFixedPostFormInRepliesDescription }}</template> <span class="_beta">CherryPick</span></MkSwitch>
<MkSwitch v-model="allMediaNoteCollapse">{{ i18n.ts.allMediaNoteCollapse }} <span class="_beta">CherryPick</span></MkSwitch>
</div>

<MkSelect v-model="instanceTicker">
Expand Down Expand Up @@ -366,6 +367,7 @@ const showReplyInNotification = computed(defaultStore.makeGetterSetter('showRepl
const renoteQuoteButtonSeparation = computed(defaultStore.makeGetterSetter('renoteQuoteButtonSeparation'));
const showFixedPostFormInReplies = computed(defaultStore.makeGetterSetter('showFixedPostFormInReplies'));
const showingAnimatedImages = computed(defaultStore.makeGetterSetter('showingAnimatedImages'));
const allMediaNoteCollapse = computed(defaultStore.makeGetterSetter('allMediaNoteCollapse'));

watch(lang, () => {
miLocalStorage.setItem('lang', lang.value as string);
Expand Down Expand Up @@ -423,6 +425,7 @@ watch([
renoteQuoteButtonSeparation,
showFixedPostFormInReplies,
showingAnimatedImages,
allMediaNoteCollapse,
], async () => {
await reloadAsk();
});
Expand Down
4 changes: 4 additions & 0 deletions packages/frontend/src/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,10 @@ export const defaultStore = markRaw(new Storage('base', {
where: 'device',
default: true,
},
allMediaNoteCollapse: {
where: 'device',
default: false,
},

// - Settings/Timeline
enableHomeTimeline: {
Expand Down

0 comments on commit d8f3f7e

Please sign in to comment.