revert "shouldCollapsed -> shouldCollapse"

This commit is contained in:
FineArchs 2025-04-22 18:09:33 +09:00
parent 83b44155e3
commit 51ec1914f9
7 changed files with 17 additions and 17 deletions

View File

@ -125,7 +125,7 @@ import EmUserName from '@/components/EmUserName.vue';
import EmTime from '@/components/EmTime.vue'; import EmTime from '@/components/EmTime.vue';
import { userPage } from '@/utils.js'; import { userPage } from '@/utils.js';
import { i18n } from '@/i18n.js'; import { i18n } from '@/i18n.js';
import { shouldCollapse } from '@@/js/collapsed.js'; import { shouldCollapsed } from '@@/js/collapsed.js';
function getAppearNote(note: Misskey.entities.Note) { function getAppearNote(note: Misskey.entities.Note) {
return Misskey.note.isPureRenote(note) ? note.renote : note; return Misskey.note.isPureRenote(note) ? note.renote : note;
@ -153,7 +153,7 @@ const renoteTime = shallowRef<HTMLElement>();
const appearNote = computed(() => getAppearNote(note.value)); const appearNote = computed(() => getAppearNote(note.value));
const showContent = ref(false); const showContent = ref(false);
const parsed = computed(() => appearNote.value.text ? mfm.parse(appearNote.value.text) : null); const parsed = computed(() => appearNote.value.text ? mfm.parse(appearNote.value.text) : null);
const isLong = shouldCollapse(appearNote.value, 13.5, parsed.value); const isLong = shouldCollapsed(appearNote.value, 13.5, parsed.value);
const collapsed = ref(appearNote.value.cw == null && isLong); const collapsed = ref(appearNote.value.cw == null && isLong);
const isDeleted = ref(false); const isDeleted = ref(false);
</script> </script>

View File

@ -145,7 +145,7 @@ import { userPage } from '@/utils.js';
import { notePage } from '@/utils.js'; import { notePage } from '@/utils.js';
import { i18n } from '@/i18n.js'; import { i18n } from '@/i18n.js';
import { DI } from '@/di.js'; import { DI } from '@/di.js';
import { shouldCollapse } from '@@/js/collapsed.js'; import { shouldCollapsed } from '@@/js/collapsed.js';
import { url } from '@@/js/config.js'; import { url } from '@@/js/config.js';
import EmMfm from '@/components/EmMfm.js'; import EmMfm from '@/components/EmMfm.js';
@ -172,7 +172,7 @@ const appearNote = computed(() => isRenote ? note.value.renote as Misskey.entiti
const showContent = ref(false); const showContent = ref(false);
const isDeleted = ref(false); const isDeleted = ref(false);
const parsed = appearNote.value.text ? mfm.parse(appearNote.value.text) : null; const parsed = appearNote.value.text ? mfm.parse(appearNote.value.text) : null;
const isLong = shouldCollapse(appearNote.value, 13.5, parsed.value); const isLong = shouldCollapsed(appearNote.value, 13.5, parsed.value);
const collapsed = ref(appearNote.value.cw == null && isLong); const collapsed = ref(appearNote.value.cw == null && isLong);
</script> </script>

View File

@ -36,7 +36,7 @@ import EmMediaList from '@/components/EmMediaList.vue';
import EmPoll from '@/components/EmPoll.vue'; import EmPoll from '@/components/EmPoll.vue';
import { i18n } from '@/i18n.js'; import { i18n } from '@/i18n.js';
import { url } from '@@/js/config.js'; import { url } from '@@/js/config.js';
import { shouldCollapse } from '@@/js/collapsed.js'; import { shouldCollapsed } from '@@/js/collapsed.js';
import EmA from '@/components/EmA.vue'; import EmA from '@/components/EmA.vue';
import EmMfm from '@/components/EmMfm.js'; import EmMfm from '@/components/EmMfm.js';
@ -44,7 +44,7 @@ const props = defineProps<{
note: Misskey.entities.Note; note: Misskey.entities.Note;
}>(); }>();
const isLong = shouldCollapse(props.note, 13.5); const isLong = shouldCollapsed(props.note, 13.5);
const collapsed = ref(isLong); const collapsed = ref(isLong);
</script> </script>

View File

@ -13,7 +13,7 @@ function safeParseFloat(str: unknown): number | null {
return num; return num;
} }
export function shouldCollapseLegacy(note: Misskey.entities.Note, urls: string[]): boolean { export function shouldCollapsedLegacy(note: Misskey.entities.Note, urls: string[]): boolean {
const collapsed = note.cw == null && ( const collapsed = note.cw == null && (
(note.text != null && ( (note.text != null && (
(note.text.includes('$[x2')) || (note.text.includes('$[x2')) ||
@ -29,7 +29,7 @@ export function shouldCollapseLegacy(note: Misskey.entities.Note, urls: string[]
return collapsed; return collapsed;
} }
export function shouldCollapse(note: Misskey.entities.Note, limitY: number, ast?: mfm.MfmNode[] | null, urls?: string[]): boolean { export function shouldCollapsed(note: Misskey.entities.Note, limitY: number, ast?: mfm.MfmNode[] | null, urls?: string[]): boolean {
if (note.cw != null) return false; if (note.cw != null) return false;
if (note.text == null) return false; if (note.text == null) return false;
if (note.files && note.files.length >= 5) return true; if (note.files && note.files.length >= 5) return true;

View File

@ -218,7 +218,7 @@ import { claimAchievement } from '@/utility/achievements.js';
import { getNoteSummary } from '@/utility/get-note-summary.js'; import { getNoteSummary } from '@/utility/get-note-summary.js';
import MkRippleEffect from '@/components/MkRippleEffect.vue'; import MkRippleEffect from '@/components/MkRippleEffect.vue';
import { showMovedDialog } from '@/utility/show-moved-dialog.js'; import { showMovedDialog } from '@/utility/show-moved-dialog.js';
import { shouldCollapseLegacy, shouldCollapse } from '@@/js/collapsed.js'; import { shouldCollapsedLegacy, shouldCollapsed } from '@@/js/collapsed.js';
import { isEnabledUrlPreview } from '@/instance.js'; import { isEnabledUrlPreview } from '@/instance.js';
import { focusPrev, focusNext } from '@/utility/focus.js'; import { focusPrev, focusNext } from '@/utility/focus.js';
import { getAppearNote } from '@/utility/get-appear-note.js'; import { getAppearNote } from '@/utility/get-appear-note.js';
@ -315,14 +315,14 @@ const collapseSize = defaultStore.state.collapsingNoteSize;
const isLong = ref(true); const isLong = ref(true);
switch (collapsingNoteCondition) { switch (collapsingNoteCondition) {
case 'detailedCalculation': case 'detailedCalculation':
isLong.value = shouldCollapse(appearNote.value, collapseSize, parsed.value, urls.value ?? []); isLong.value = shouldCollapsed(appearNote.value, collapseSize, parsed.value, urls.value ?? []);
break; break;
case 'seeRenderedSize': case 'seeRenderedSize':
break; break;
// fail safe // fail safe
case 'legacyCalculation': case 'legacyCalculation':
default: default:
isLong.value = shouldCollapseLegacy(appearNote.value, urls.value ?? []); isLong.value = shouldCollapsedLegacy(appearNote.value, urls.value ?? []);
break; break;
} }
const collapsed = ref(appearNote.value.cw == null && isLong.value); const collapsed = ref(appearNote.value.cw == null && isLong.value);

View File

@ -35,7 +35,7 @@ SPDX-License-Identifier: AGPL-3.0-only
import { ref, computed, onMounted } from 'vue'; import { ref, computed, onMounted } from 'vue';
import * as Misskey from 'misskey-js'; import * as Misskey from 'misskey-js';
import * as mfm from 'mfm-js'; import * as mfm from 'mfm-js';
import { shouldCollapseLegacy, shouldCollapse } from '@@/js/collapsed.js'; import { shouldCollapsedLegacy, shouldCollapsed } from '@@/js/collapsed.js';
import MkMediaList from '@/components/MkMediaList.vue'; import MkMediaList from '@/components/MkMediaList.vue';
import MkPoll from '@/components/MkPoll.vue'; import MkPoll from '@/components/MkPoll.vue';
import { i18n } from '@/i18n.js'; import { i18n } from '@/i18n.js';
@ -63,7 +63,7 @@ const isLong = ref(true);
switch (collapsingNoteCondition) { switch (collapsingNoteCondition) {
case 'detailedCalculation': case 'detailedCalculation':
// eslint-disable-next-line vue/no-setup-props-destructure // eslint-disable-next-line vue/no-setup-props-destructure
isLong.value = shouldCollapse(props.note, collapseSize, ast.value); isLong.value = shouldCollapsed(props.note, collapseSize, ast.value);
break; break;
case 'seeRenderedSize': case 'seeRenderedSize':
break; break;
@ -71,7 +71,7 @@ switch (collapsingNoteCondition) {
case 'legacyCalculation': case 'legacyCalculation':
default: default:
// eslint-disable-next-line vue/no-setup-props-destructure // eslint-disable-next-line vue/no-setup-props-destructure
isLong.value = shouldCollapseLegacy(props.note, []); isLong.value = shouldCollapsedLegacy(props.note, []);
break; break;
} }
const collapsed = ref(isLong.value); const collapsed = ref(isLong.value);

View File

@ -15,7 +15,7 @@ SPDX-License-Identifier: AGPL-3.0-only
<MkA v-if="note.renoteId" class="rp" :to="`/notes/${note.renoteId}`">RN: ...</MkA> <MkA v-if="note.renoteId" class="rp" :to="`/notes/${note.renoteId}`">RN: ...</MkA>
</div> </div>
</div> </div>
<div v-else ref="noteTextEl" :class="[$style.text, { [$style.collapsed]: shouldCollapse }]"> <div v-else ref="noteTextEl" :class="[$style.text, { [$style.collapsed]: shouldCollapsed }]">
<MkA v-if="note.replyId" class="reply" :to="`/notes/${note.replyId}`"><i class="ti ti-arrow-back-up"></i></MkA> <MkA v-if="note.replyId" class="reply" :to="`/notes/${note.replyId}`"><i class="ti ti-arrow-back-up"></i></MkA>
<Mfm v-if="note.text" :text="note.text" :author="note.user"/> <Mfm v-if="note.text" :text="note.text" :author="note.user"/>
<MkA v-if="note.renoteId" class="rp" :to="`/notes/${note.renoteId}`">RN: ...</MkA> <MkA v-if="note.renoteId" class="rp" :to="`/notes/${note.renoteId}`">RN: ...</MkA>
@ -46,14 +46,14 @@ defineProps<{
}>(); }>();
const noteTextEl = useTemplateRef('noteTextEl'); const noteTextEl = useTemplateRef('noteTextEl');
const shouldCollapse = ref(false); const shouldCollapsed = ref(false);
const showContent = ref(false); const showContent = ref(false);
function calcCollapse() { function calcCollapse() {
if (noteTextEl.value) { if (noteTextEl.value) {
const height = noteTextEl.value.scrollHeight; const height = noteTextEl.value.scrollHeight;
if (height > 200) { if (height > 200) {
shouldCollapse.value = true; shouldCollapsed.value = true;
} }
} }
} }