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