fix: use reacive MkSubNoteContent
This commit is contained in:
parent
42886f054d
commit
31168cc7b2
1 changed files with 28 additions and 17 deletions
|
@ -178,7 +178,7 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { ref } from "vue";
|
import { computed, ref, watch } from "vue";
|
||||||
import type { entities } from "firefish-js";
|
import type { entities } from "firefish-js";
|
||||||
import * as mfm from "mfm-js";
|
import * as mfm from "mfm-js";
|
||||||
import * as os from "@/os";
|
import * as os from "@/os";
|
||||||
|
@ -226,24 +226,35 @@ const emit = defineEmits<{
|
||||||
const cwButton = ref<HTMLElement>();
|
const cwButton = ref<HTMLElement>();
|
||||||
const showMoreButton = ref<HTMLElement>();
|
const showMoreButton = ref<HTMLElement>();
|
||||||
|
|
||||||
const isLong =
|
const isLong = computed(
|
||||||
|
() =>
|
||||||
!props.detailedView &&
|
!props.detailedView &&
|
||||||
props.note.cw == null &&
|
props.note.cw == null &&
|
||||||
props.isLongJudger(props.note);
|
props.isLongJudger(props.note),
|
||||||
const collapsed = ref(props.note.cw == null && isLong);
|
);
|
||||||
const urls = props.note.text
|
const urls = computed(() =>
|
||||||
|
props.note.text
|
||||||
? extractUrlFromMfm(mfm.parse(props.note.text)).slice(0, 5)
|
? extractUrlFromMfm(mfm.parse(props.note.text)).slice(0, 5)
|
||||||
: null;
|
: null,
|
||||||
|
);
|
||||||
const showContent = ref(false);
|
const mfms = computed(() =>
|
||||||
|
props.note.text ? extractMfmWithAnimation(mfm.parse(props.note.text)) : null,
|
||||||
const mfms = props.note.text
|
);
|
||||||
? extractMfmWithAnimation(mfm.parse(props.note.text))
|
const hasMfm = computed(() => mfms.value && mfms.value.length > 0);
|
||||||
: null;
|
|
||||||
|
|
||||||
const hasMfm = ref(mfms && mfms.length > 0);
|
|
||||||
|
|
||||||
const disableMfm = ref(defaultStore.state.animatedMfm);
|
const disableMfm = ref(defaultStore.state.animatedMfm);
|
||||||
|
const showContent = ref(false);
|
||||||
|
const collapsed = ref(props.note.cw == null && isLong.value);
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => props.note.id,
|
||||||
|
(o, n) => {
|
||||||
|
if (o !== n) return;
|
||||||
|
disableMfm.value = defaultStore.state.animatedMfm;
|
||||||
|
showContent.value = false;
|
||||||
|
collapsed.value = props.note.cw == null && isLong.value;
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
async function toggleMfm() {
|
async function toggleMfm() {
|
||||||
if (disableMfm.value) {
|
if (disableMfm.value) {
|
||||||
|
|
Loading…
Reference in a new issue