This commit is contained in:
yawhn 2023-01-19 19:54:27 +02:00
commit 8453d05115
2 changed files with 14 additions and 7 deletions

View File

@ -90,6 +90,7 @@ const backed = ref(false); // 遡り中か否か
const isBackTop = ref(false); const isBackTop = ref(false);
const empty = computed(() => items.value.length === 0); const empty = computed(() => items.value.length === 0);
const error = ref(false); const error = ref(false);
const alreadyInitedOnce = ref(false);
const init = async (): Promise<void> => { const init = async (): Promise<void> => {
queue.value = []; queue.value = [];
@ -344,10 +345,14 @@ init();
onActivated(() => { onActivated(() => {
isBackTop.value = false; isBackTop.value = false;
if(alreadyInitedOnce.value) {
reload();
}
}); });
onDeactivated(() => { onDeactivated(() => {
isBackTop.value = window.scrollY === 0; isBackTop.value = window.scrollY === 0;
alreadyInitedOnce.value = true;
}); });
defineExpose({ defineExpose({

View File

@ -13,8 +13,8 @@
<MkButton primary class="start" @click="startUser"><i class="ph-plus-bold ph-lg"></i> {{ <MkButton primary class="start" @click="startUser"><i class="ph-plus-bold ph-lg"></i> {{
i18n.ts.startMessaging i18n.ts.startMessaging
}}</MkButton> }}</MkButton>
<MkPagination v-slot="{ items }" :externalItemArray="messages" :pagination="dmsPagination"> <MkPagination v-slot="{ items }" :pagination="dmsPagination">
<MkChatPreview v-for="message in messages" :key="message.id" class="yweeujhr message _block" <MkChatPreview v-for="message in items" :key="message.id" class="yweeujhr message _block"
:message="message" /> :message="message" />
</MkPagination> </MkPagination>
</div> </div>
@ -28,8 +28,8 @@
i18n.ts.startMessaging i18n.ts.startMessaging
}}</MkButton> }}</MkButton>
</div> </div>
<MkPagination v-slot="{ items }" :externalItemArray="groupMessages" :pagination="groupsPagination"> <MkPagination v-slot="{ items }" :pagination="groupsPagination">
<MkChatPreview v-for="message in groupMessages" :key="message.id" class="yweeujhr message _block" <MkChatPreview v-for="message in items" :key="message.id" class="yweeujhr message _block"
:message="message" /> :message="message" />
</MkPagination> </MkPagination>
</div> </div>
@ -62,8 +62,9 @@ import 'swiper/scss/virtual';
const router = useRouter(); const router = useRouter();
let messages = $ref([]); let messages = $ref([]);
let groupMessages = $ref([]);
let connection = $ref(null); let connection = $ref(null);
let paginationComponentUser = $ref<InstanceType<typeof MkPagination>>();
let paginationComponentGroup = $ref<InstanceType<typeof MkPagination>>();
const tabs = ['dms', 'groups']; const tabs = ['dms', 'groups'];
let tab = $ref(tabs[0]); let tab = $ref(tabs[0]);
@ -116,9 +117,10 @@ function onMessage(message): void {
messages.unshift(message); messages.unshift(message);
} else if (message.groupId) { } else if (message.groupId) {
groupMessages = groupMessages.filter(m => m.groupId !== message.groupId); messages = messages.filter(m => m.groupId !== message.groupId);
groupMessages.unshift(message); messages.unshift(message);
} }
forceRerender();
} }
function onRead(ids): void { function onRead(ids): void {