This commit is contained in:
ThatOneCalculator 2022-11-06 14:04:18 -08:00
parent c772bf2307
commit 9ea3af662d
2 changed files with 44 additions and 44 deletions

View file

@ -1,6 +1,6 @@
{ {
"name": "calckey", "name": "calckey",
"version": "12.119.0-calc.8-rc.10", "version": "12.119.0-calc.8-rc.11",
"codename": "aqua", "codename": "aqua",
"repository": { "repository": {
"type": "git", "type": "git",

View file

@ -17,10 +17,10 @@
<MkPagination v-slot="{items}" :pagination="dmsPagination"> <MkPagination v-slot="{items}" :pagination="dmsPagination">
<MkChatPreview v-for="message in items" :key="message.id" class="yweeujhr message _block" :message="message"/> <MkChatPreview v-for="message in items" :key="message.id" class="yweeujhr message _block" :message="message"/>
</MkPagination> </MkPagination>
<div v-if="messages.length == 0" class="_fullinfo"> <!-- <div v-if="messages.length == 0" class="_fullinfo">
<img src="/static-assets/badges/info.png" class="_ghost" alt="Info"/> <img src="/static-assets/badges/info.png" class="_ghost" alt="Info"/>
<div>{{ i18n.ts.noHistory }}</div> <div>{{ i18n.ts.noHistory }}</div>
</div> </div> -->
</div> </div>
</swiper-slide> </swiper-slide>
<swiper-slide> <swiper-slide>
@ -61,8 +61,8 @@ import 'swiper/scss/virtual';
const router = useRouter(); const router = useRouter();
let messages = $ref([]); // let messages = $ref([]);
let connection = $ref(null); // let connection = $ref(null);
const tabs = ['dms', 'groups']; const tabs = ['dms', 'groups'];
let tab = $ref(tabs[0]); let tab = $ref(tabs[0]);
@ -100,31 +100,31 @@ const groupsPagination = {
}, },
}; };
function onMessage(message): void { // function onMessage(message): void {
if (message.recipientId) { // if (message.recipientId) {
messages = messages.filter(m => !( // messages = messages.filter(m => !(
(m.recipientId === message.recipientId && m.userId === message.userId) || // (m.recipientId === message.recipientId && m.userId === message.userId) ||
(m.recipientId === message.userId && m.userId === message.recipientId))); // (m.recipientId === message.userId && m.userId === message.recipientId)));
messages.unshift(message); // messages.unshift(message);
} else if (message.groupId) { // } else if (message.groupId) {
messages = messages.filter(m => m.groupId !== message.groupId); // messages = messages.filter(m => m.groupId !== message.groupId);
messages.unshift(message); // messages.unshift(message);
} // }
} // }
function onRead(ids): void { // function onRead(ids): void {
for (const id of ids) { // for (const id of ids) {
const found = messages.find(m => m.id === id); // const found = messages.find(m => m.id === id);
if (found) { // if (found) {
if (found.recipientId) { // if (found.recipientId) {
found.isRead = true; // found.isRead = true;
} else if (found.groupId) { // } else if (found.groupId) {
found.reads.push($i.id); // found.reads.push($i.id);
} // }
} // }
} // }
} // }
async function startUser(): void { async function startUser(): void {
os.selectUser().then(user => { os.selectUser().then(user => {
@ -168,25 +168,25 @@ function syncSlide(index) {
swiperRef.slideTo(index); swiperRef.slideTo(index);
} }
onMounted(() => { // onMounted(() => {
connection = markRaw(stream.useChannel('messagingIndex')); // connection = markRaw(stream.useChannel('messagingIndex'));
connection.on('message', onMessage); // connection.on('message', onMessage);
connection.on('read', onRead); // connection.on('read', onRead);
os.api('messaging/history', { group: false, limit: 5 }).then(userMessages => { // os.api('messaging/history', { group: false, limit: 5 }).then(userMessages => {
os.api('messaging/history', { group: true, limit: 5 }).then(groupMessages => { // os.api('messaging/history', { group: true, limit: 5 }).then(groupMessages => {
const _messages = userMessages.concat(groupMessages); // const _messages = userMessages.concat(groupMessages);
_messages.sort((a, b) => new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime()); // _messages.sort((a, b) => new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime());
messages = _messages; // messages = _messages;
fetching = false; // fetching = false;
}); // });
}); // });
}); // });
onUnmounted(() => { // onUnmounted(() => {
if (connection) connection.dispose(); // if (connection) connection.dispose();
}); // });
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>