This commit is contained in:
Troplo 2022-07-30 18:14:33 +10:00
parent 91386b68c0
commit fd174f7355
2 changed files with 27 additions and 33 deletions

View file

@ -25,10 +25,7 @@
<v-list-item @click="groupSettings(context.user.id)"> <v-list-item @click="groupSettings(context.user.id)">
<v-list-item-title>Group Settings</v-list-item-title> <v-list-item-title>Group Settings</v-list-item-title>
</v-list-item> </v-list-item>
<v-list-item <v-list-item @click="groupLeave(context.user.id)" color="error">
@click="groupLeave(context.user.id)"
color="error"
>
<v-list-item-title>Leave Group</v-list-item-title> <v-list-item-title>Leave Group</v-list-item-title>
</v-list-item> </v-list-item>
</v-list> </v-list>
@ -325,6 +322,13 @@
> >
Style Toggle Style Toggle
</button> </button>
<button
style="display: none"
v-shortkey="['ctrl', 'f']"
@shortkey="$store.state.searchPanel = true"
>
Debug
</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="$store.state.selectedChat?.chat?.type">
{{ {{
@ -677,9 +681,7 @@ export default {
this.settings.dialog = true this.settings.dialog = true
}, },
groupLeave(id) { groupLeave(id) {
this.leave.item = this.$store.state.chats.find( this.leave.item = this.$store.state.chats.find((chat) => chat.id === id)
(chat) => chat.id === id
)
this.leave.dialog = true this.leave.dialog = true
}, },
show(e, context, item, id) { show(e, context, item, id) {
@ -741,12 +743,7 @@ export default {
}, },
removeUserFromGroup(user) { removeUserFromGroup(user) {
this.axios this.axios
.delete( .delete("/api/v1/association/" + this.settings.item.id + "/" + user.id)
"/api/v1/association/" +
this.settings.item.id +
"/" +
user.id
)
.then(() => { .then(() => {
this.$toast.success("User has been removed from the group.") this.$toast.success("User has been removed from the group.")
}) })
@ -756,15 +753,9 @@ export default {
}, },
giveUserAdmin(user) { giveUserAdmin(user) {
this.axios this.axios
.put( .put("/api/v1/association/" + this.settings.item.id + "/" + user.id, {
"/api/v1/association/" + rank: "admin"
this.settings.item.id + })
"/" +
user.id,
{
rank: "admin"
}
)
.then(() => { .then(() => {
this.$toast.success("User has been promoted to admin.") this.$toast.success("User has been promoted to admin.")
}) })
@ -797,12 +788,9 @@ export default {
}, },
addMembersToGroup() { addMembersToGroup() {
this.axios this.axios
.post( .post("/api/v1/association/" + this.settings.item.chat.id, {
"/api/v1/association/" + this.settings.item.chat.id, users: this.settings.addMembers.users
{ })
users: this.settings.addMembers.users
}
)
.then(() => { .then(() => {
this.settings.item.chat.users = this.settings.item.chat.users.concat( this.settings.item.chat.users = this.settings.item.chat.users.concat(
this.settings.addMembers.users this.settings.addMembers.users
@ -821,7 +809,7 @@ export default {
.then(() => { .then(() => {
this.leave.dialog = false this.leave.dialog = false
this.$store.state.chats = this.$store.state.chats.filter( this.$store.state.chats = this.$store.state.chats.filter(
(chat) => chat.id !== this.leave.item.id (chat) => chat.id !== this.leave.item.id
) )
this.$router.push("/communications/friends") this.$router.push("/communications/friends")
this.leave.item = null this.leave.item = null

View file

@ -282,6 +282,7 @@
outlined outlined
autofocus autofocus
@keydown.enter="doSearch" @keydown.enter="doSearch"
@keydown.esc="$store.state.searchPanel = false"
></v-text-field> ></v-text-field>
<v-list two-line color="card" ref="message-list-search"> <v-list two-line color="card" ref="message-list-search">
<template v-for="(message, index) in search.results"> <template v-for="(message, index) in search.results">
@ -1071,7 +1072,7 @@ export default {
AjaxErrorHandler(this.$store)(e) AjaxErrorHandler(this.$store)(e)
}) })
}, },
jumpToMessage(id) { async jumpToMessage(id) {
try { try {
console.log("Jumping to message", id) console.log("Jumping to message", id)
const index = this.messages.findIndex((message) => message.id === id) const index = this.messages.findIndex((message) => message.id === id)
@ -1086,8 +1087,13 @@ export default {
setTimeout(() => { setTimeout(() => {
lastMessage.style.backgroundColor = "" lastMessage.style.backgroundColor = ""
}, 1500) }, 1500)
} else {
this.offset = id
await this.getMessages()
this.jumpToMessage(id)
} }
} catch { } catch (e) {
console.log(e)
console.log("Could not auto scroll (Jump to message)") console.log("Could not auto scroll (Jump to message)")
} }
}, },
@ -1144,9 +1150,9 @@ export default {
} }
}) })
}, },
getMessages() { async getMessages() {
this.loadingMessages = true this.loadingMessages = true
this.axios await this.axios
.get( .get(
process.env.VUE_APP_BASE_URL + process.env.VUE_APP_BASE_URL +
"/api/v1/communications/" + "/api/v1/communications/" +