diff --git a/backend/lib/authorize.js b/backend/lib/authorize.js index f2bdb7b..a7b724f 100644 --- a/backend/lib/authorize.js +++ b/backend/lib/authorize.js @@ -28,7 +28,7 @@ module.exports = async function (req, res, next) { }) if (user) { if (user.banned) { - res.status(401).json(Errors.banned) + res.status(401).json({ errors: [Errors.banned] }) return } await user.update({ @@ -38,7 +38,7 @@ module.exports = async function (req, res, next) { next() } } else { - res.status(401).json(Errors.unauthorized) + res.status(401).json({ errors: [Errors.unauthorized] }) } } else { res.status(401).json({ diff --git a/backend/routes/communications.js b/backend/routes/communications.js index 5ad475c..3df59c8 100644 --- a/backend/routes/communications.js +++ b/backend/routes/communications.js @@ -531,6 +531,7 @@ router.get("/:id/pins", auth, async (req, res, next) => { { model: Message, as: "message", + required: true, include: [ { model: User, @@ -950,7 +951,7 @@ router.get("/:id/search", auth, async (req, res, next) => { } ] }) - const page = parseInt(req.params.page) || 1 + const page = parseInt(req.query.page) || 1 const pager = paginate(messages.length, page, 15) const result = messages.slice(pager.startIndex, pager.endIndex + 1) res.json({ diff --git a/frontend/package.json b/frontend/package.json index dbeffc0..25f7dba 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -1,6 +1,6 @@ { "name": "colubrina", - "version": "1.0.24", + "version": "1.0.25", "description": "Simple instant communication.", "private": true, "author": "Troplo ", diff --git a/frontend/src/App.vue b/frontend/src/App.vue index d0a1958..a9b05ce 100644 --- a/frontend/src/App.vue +++ b/frontend/src/App.vue @@ -804,6 +804,7 @@ export default { } }) .catch(() => { + this.$store.dispatch("logout") this.$router.push("/login") }) this.getThemes() diff --git a/frontend/src/views/Communications/CommunicationsChat.vue b/frontend/src/views/Communications/CommunicationsChat.vue index 3b9ee19..dab38ca 100644 --- a/frontend/src/views/Communications/CommunicationsChat.vue +++ b/frontend/src/views/Communications/CommunicationsChat.vue @@ -8,8 +8,9 @@ absolute transition="scroll-y-transition" :close-on-content-click="false" + style="z-index: 15" > - + Pins @@ -28,6 +29,7 @@ :index="index" :key="pin.message.keyId" > + mdi-close @@ -414,6 +416,7 @@ class="" id="search-col" v-if="$store.state.searchPanel && !$vuetify.breakpoint.mobile" + style="z-index: 15" > + @@ -607,7 +616,7 @@ export default { display: false } }, - offset: 0, + offset: null, nickname: { dialog: false, nickname: "", @@ -637,7 +646,9 @@ export default { search: { query: "", results: [], - pager: {}, + pager: { + totalPages: 1 + }, loading: false, page: 1 }, @@ -706,6 +717,9 @@ export default { lastRead: 0 }), computed: { + offsetValue() { + return this.offset || this.messages[0]?.id || 0 + }, associations() { if (this.chat) { return this.chat.chat.associations.slice().sort((a, b) => { @@ -799,7 +813,6 @@ export default { !this.loadingMessages ) { this.rateLimit = true - this.offset += 50 this.loadingMessages = true const element = document.getElementById("message-0") await this.getMessages() @@ -1001,9 +1014,10 @@ export default { lastMessage.style.backgroundColor = "" }, 1500) } else { - this.offset = id + this.offset = id + 10 await this.getMessages() this.jumpToMessage(id) + this.offset = null } } catch (e) { console.log(e) @@ -1072,7 +1086,7 @@ export default { "/api/v1/communications/" + this.$route.params.id + "/messages?limit=50&offset=" + - this.messages[0]?.id || 0 + this.offsetValue ) .then((res) => { if (!res.data.length) { @@ -1237,7 +1251,7 @@ export default { this.replying = null this.reachedTop = false this.avoidAutoScroll = false - this.offset = 0 + this.offset = null this.pins = [] this.messages = [] this.getMessages()