fix double component rendering ( only hidden )
This commit is contained in:
@@ -12,7 +12,6 @@ export const useMessageStore = defineStore('message', () => {
|
|||||||
try {
|
try {
|
||||||
let uri = `/api/message-count/${subjectId}`;
|
let uri = `/api/message-count/${subjectId}`;
|
||||||
const response = await client.get(uri);
|
const response = await client.get(uri);
|
||||||
console.log(response);
|
|
||||||
messageCount.value = response.data.count;
|
messageCount.value = response.data.count;
|
||||||
trackedSubject.value = subjectId;
|
trackedSubject.value = subjectId;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
@@ -190,6 +190,7 @@ function openDeleteConfirmationDialog() {
|
|||||||
function addMessage(newMessage) {
|
function addMessage(newMessage) {
|
||||||
messages.value.unshift(newMessage);
|
messages.value.unshift(newMessage);
|
||||||
messagesVisible.value = true;
|
messagesVisible.value = true;
|
||||||
|
messageCount.value ++;
|
||||||
}
|
}
|
||||||
|
|
||||||
function toggleComments() {
|
function toggleComments() {
|
||||||
|
|||||||
@@ -5,15 +5,11 @@
|
|||||||
class="md:gap-2">
|
class="md:gap-2">
|
||||||
|
|
||||||
<template v-for="content in contents" :key="content.id">
|
<template v-for="content in contents" :key="content.id">
|
||||||
|
<component
|
||||||
<div class="d-sm-none mb-1">
|
:is="isSmallScreen ? ContentCardSm : ContentCardNormal"
|
||||||
<content-card-sm :content="content" @content-deleted="onContentDeleted"></content-card-sm>
|
:content="content"
|
||||||
</div>
|
@content-deleted="onContentDeleted"
|
||||||
|
></component>
|
||||||
|
|
||||||
<div class="d-none d-sm-flex">
|
|
||||||
<content-card-normal :content="content" @content-deleted="onContentDeleted"></content-card-normal>
|
|
||||||
</div>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<template v-slot:empty>
|
<template v-slot:empty>
|
||||||
@@ -31,7 +27,7 @@
|
|||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import {useClient} from '@/plugins/api.js';
|
import {useClient} from '@/plugins/api.js';
|
||||||
import {ref, watch} from 'vue';
|
import {onBeforeUnmount, onMounted, ref, watch} from 'vue';
|
||||||
import ContentCardNormal from "@/views/contents/contentcards/NContentCard.vue";
|
import ContentCardNormal from "@/views/contents/contentcards/NContentCard.vue";
|
||||||
import ContentCardSm from "@/views/contents/contentcards/SmContentCard.vue";
|
import ContentCardSm from "@/views/contents/contentcards/SmContentCard.vue";
|
||||||
|
|
||||||
@@ -51,6 +47,21 @@ const contents = ref(props.contents)
|
|||||||
const errorMessage = ref()
|
const errorMessage = ref()
|
||||||
let last_id = null
|
let last_id = null
|
||||||
|
|
||||||
|
const isSmallScreen = ref(false);
|
||||||
|
|
||||||
|
const updateScreenSize = () => {
|
||||||
|
isSmallScreen.value = window.matchMedia('(max-width: 600px)').matches;
|
||||||
|
};
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
updateScreenSize();
|
||||||
|
window.addEventListener('resize', updateScreenSize);
|
||||||
|
});
|
||||||
|
|
||||||
|
onBeforeUnmount(() => {
|
||||||
|
window.removeEventListener('resize', updateScreenSize);
|
||||||
|
});
|
||||||
|
|
||||||
async function onContentDeleted(contentId) {
|
async function onContentDeleted(contentId) {
|
||||||
contents.value = contents.value.filter(c => c.id !== contentId)
|
contents.value = contents.value.filter(c => c.id !== contentId)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -191,6 +191,7 @@ function openDeleteConfirmationDialog() {
|
|||||||
function addMessage(newMessage) {
|
function addMessage(newMessage) {
|
||||||
messages.value.unshift(newMessage);
|
messages.value.unshift(newMessage);
|
||||||
messagesVisible.value = true;
|
messagesVisible.value = true;
|
||||||
|
messageCount.value ++;
|
||||||
}
|
}
|
||||||
|
|
||||||
function toggleComments() {
|
function toggleComments() {
|
||||||
|
|||||||
@@ -190,6 +190,7 @@ function openDeleteConfirmationDialog() {
|
|||||||
function addMessage(newMessage) {
|
function addMessage(newMessage) {
|
||||||
messages.value.unshift(newMessage);
|
messages.value.unshift(newMessage);
|
||||||
messagesVisible.value = true;
|
messagesVisible.value = true;
|
||||||
|
messageCount.value ++;
|
||||||
}
|
}
|
||||||
|
|
||||||
function toggleComments() {
|
function toggleComments() {
|
||||||
|
|||||||
Reference in New Issue
Block a user