mirror of
https://github.com/Troplo/Colubrina.git
synced 2024-12-25 07:55:15 +11:00
1.0.33
This commit is contained in:
parent
5edbd5ad4d
commit
fa26fafcde
5 changed files with 56 additions and 25 deletions
|
@ -17,6 +17,7 @@ module.exports = {
|
|||
}
|
||||
})
|
||||
if (user && socket.user.id) {
|
||||
console.log(user.id + " client connect")
|
||||
console.log(socket.user.id)
|
||||
socket.join(user.id)
|
||||
socket.emit("siteState", {
|
||||
|
@ -48,6 +49,7 @@ module.exports = {
|
|||
})
|
||||
})
|
||||
socket.on("ping", () => {
|
||||
console.log(user.id + " client ping")
|
||||
socket.emit("pong")
|
||||
})
|
||||
socket.on("bcBots/deleteMessage", (e) => {
|
||||
|
@ -60,11 +62,7 @@ module.exports = {
|
|||
}
|
||||
})
|
||||
socket.on("idle", async () => {
|
||||
const user = await User.findOne({
|
||||
where: {
|
||||
id: socket.user.id
|
||||
}
|
||||
})
|
||||
console.log(user.id + " client online")
|
||||
if (user.storedStatus === "online") {
|
||||
friends.forEach((friend) => {
|
||||
io.to(friend.friendId).emit("userStatus", {
|
||||
|
@ -82,11 +80,7 @@ module.exports = {
|
|||
}
|
||||
})
|
||||
socket.on("online", async () => {
|
||||
const user = await User.findOne({
|
||||
where: {
|
||||
id: socket.user.id
|
||||
}
|
||||
})
|
||||
console.log(user.id + " client online")
|
||||
if (user.storedStatus === "online") {
|
||||
friends.forEach((friend) => {
|
||||
io.to(friend.friendId).emit("userStatus", {
|
||||
|
@ -104,6 +98,7 @@ module.exports = {
|
|||
}
|
||||
})
|
||||
socket.on("disconnect", async function () {
|
||||
console.log(user.id + " client disconnected")
|
||||
const clients = io.sockets.adapter.rooms.get(user.id) || new Set()
|
||||
if (!clients.size || clients.size === 0) {
|
||||
friends.forEach((friend) => {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "colubrina",
|
||||
"version": "1.0.32",
|
||||
"version": "1.0.33",
|
||||
"description": "Simple instant communication.",
|
||||
"private": true,
|
||||
"author": "Troplo <troplo@troplo.com>",
|
||||
|
|
|
@ -490,6 +490,15 @@ export default {
|
|||
touchEndX: null
|
||||
}),
|
||||
computed: {
|
||||
/*chat() {
|
||||
try {
|
||||
return this.$store.state.chats.find(
|
||||
(item) => item.id === parseInt(this.$route.params.id)
|
||||
)
|
||||
} catch {
|
||||
return null
|
||||
}
|
||||
},*/
|
||||
creatorJSON: {
|
||||
get() {
|
||||
return JSON.stringify(this.$store.state.themeEngine.theme)
|
||||
|
|
|
@ -545,11 +545,11 @@
|
|||
Debug
|
||||
</button>
|
||||
<template v-if="$route.name === 'Communications'">
|
||||
<v-toolbar-title v-if="$store.state.selectedChat?.chat?.type">
|
||||
<v-toolbar-title v-if="chat?.chat?.type">
|
||||
{{
|
||||
$store.state.selectedChat?.chat?.type === "direct"
|
||||
? getDirectRecipient($store.state.selectedChat).username
|
||||
: $store.state.selectedChat?.chat?.name
|
||||
chat?.chat?.type === "direct"
|
||||
? getDirectRecipient(chat).username
|
||||
: chat?.chat?.name
|
||||
}}
|
||||
</v-toolbar-title>
|
||||
<v-spacer></v-spacer>
|
||||
|
@ -954,6 +954,15 @@ export default {
|
|||
}
|
||||
},
|
||||
computed: {
|
||||
chat() {
|
||||
try {
|
||||
return this.$store.state.chats.find(
|
||||
(item) => item.id === parseInt(this.$route.params.id)
|
||||
)
|
||||
} catch {
|
||||
return null
|
||||
}
|
||||
},
|
||||
chats() {
|
||||
if (!this.search?.length) {
|
||||
return this.$store.state.chats
|
||||
|
|
|
@ -1160,11 +1160,13 @@ export default {
|
|||
this.message = drafts[this.$route.params.id]
|
||||
}
|
||||
this.$socket.on("readChat", (data) => {
|
||||
if (data.id === this.chat.id) {
|
||||
if (!this.chat) return
|
||||
if (data.id === this.chat?.id) {
|
||||
this.lastRead = data.lastRead
|
||||
}
|
||||
})
|
||||
this.$socket.on("readReceipt", (data) => {
|
||||
if (!this.chat) return
|
||||
try {
|
||||
if (
|
||||
data.messageId &&
|
||||
|
@ -1186,16 +1188,21 @@ export default {
|
|||
}
|
||||
})
|
||||
this.$socket.on("message", (message) => {
|
||||
if (message.chatId === this.chat.chatId) {
|
||||
this.messages.push(message)
|
||||
this.autoScroll()
|
||||
if (document.hasFocus()) {
|
||||
this.markRead()
|
||||
}
|
||||
if (this.messages.length > 50 && !this.avoidAutoScroll) {
|
||||
this.messages.shift()
|
||||
this.reachedTop = false
|
||||
try {
|
||||
if (!this.chat) return
|
||||
if (message.chatId === this.chat.chatId) {
|
||||
this.messages.push(message)
|
||||
this.autoScroll()
|
||||
if (document.hasFocus()) {
|
||||
this.markRead()
|
||||
}
|
||||
if (this.messages.length > 50 && !this.avoidAutoScroll) {
|
||||
this.messages.shift()
|
||||
this.reachedTop = false
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
console.log("Message error", e)
|
||||
}
|
||||
})
|
||||
this.$socket.on("editMessage", (message) => {
|
||||
|
@ -1248,6 +1255,17 @@ export default {
|
|||
userPanel() {
|
||||
localStorage.setItem("userPanel", JSON.stringify(this.userPanel))
|
||||
},
|
||||
"$route.path"() {
|
||||
const tryParse = this.$route.params.id
|
||||
if (!tryParse) {
|
||||
// remove event listeners
|
||||
document.removeEventListener("keypress", this.focusKey)
|
||||
document
|
||||
.getElementById("message-list")
|
||||
.removeEventListener("scroll", this.scrollEvent)
|
||||
clearInterval(this.interval)
|
||||
}
|
||||
},
|
||||
"$route.params.id"(val, oldVal) {
|
||||
this.focusInput()
|
||||
let drafts = {}
|
||||
|
|
Loading…
Reference in a new issue