diff --git a/server/ui-src/components/ListMessages.vue b/server/ui-src/components/ListMessages.vue index 6da9525..6d74582 100644 --- a/server/ui-src/components/ListMessages.vue +++ b/server/ui-src/components/ListMessages.vue @@ -2,7 +2,7 @@ import { mailbox } from '../stores/mailbox' import CommonMixins from '../mixins/CommonMixins' import dayjs from 'dayjs' -import {pagination} from "../stores/pagination"; +import { pagination } from "../stores/pagination"; export default { mixins: [ @@ -16,6 +16,7 @@ export default { data() { return { mailbox, + pagination, } }, @@ -102,11 +103,17 @@ export default { }, toTagUrl: function (t) { - const params = new URLSearchParams({ - start: String(0), - limit: pagination.limit.toString(), - }) - return '/search?q=' + this.tagEncodeURI(t) + '&' + params.toString() + if (t.match(/ /)) { + t = `"${t}"` + } + const p = { + q: 'tag:' + t + } + if (pagination.limit != pagination.defaultLimit) { + p.limit = pagination.limit.toString() + } + const params = new URLSearchParams(p) + return '/search?' + params.toString() }, } } @@ -153,6 +160,7 @@ export default {
{{ t }} diff --git a/server/ui-src/components/NavTags.vue b/server/ui-src/components/NavTags.vue index b023343..0b1ae29 100644 --- a/server/ui-src/components/NavTags.vue +++ b/server/ui-src/components/NavTags.vue @@ -11,25 +11,11 @@ export default { data() { return { mailbox, + pagination, } }, methods: { - // if the current filter is active then reload view - reloadFilter: function (tag) { - const urlParams = new URLSearchParams(window.location.search) - const query = urlParams.get('q') - if (!query) { - return false - } - - let re = new RegExp(`^tag:"?${tag}"?$`, 'i') - if (query.match(re)) { - pagination.start = 0 - this.$emit('loadMessages') - } - }, - // test whether a tag is currently being searched for (in the URL) inSearch: function (tag) { const urlParams = new URLSearchParams(window.location.search) @@ -76,12 +62,18 @@ export default { } }, - toTagUrl(tag) { - const params = new URLSearchParams({ - start: String(0), - limit: pagination.limit.toString(), - }) - return '/search?q=' + this.tagEncodeURI(tag) + '&' + params.toString() + toTagUrl(t) { + if (t.match(/ /)) { + t = `"${t}"` + } + const p = { + q: 'tag:' + t + } + if (pagination.limit != pagination.defaultLimit) { + p.limit = pagination.limit.toString() + } + const params = new URLSearchParams(p) + return '/search?' + params.toString() }, } } @@ -105,7 +97,7 @@ export default {
diff --git a/server/ui-src/components/Notifications.vue b/server/ui-src/components/Notifications.vue index 945e5a1..e872ac7 100644 --- a/server/ui-src/components/Notifications.vue +++ b/server/ui-src/components/Notifications.vue @@ -15,7 +15,8 @@ export default { reconnectRefresh: false, socketURI: false, pauseNotifications: false, // prevent spamming - version: false + version: false, + paginationDelayed: false, // for delayed pagination URL changes } }, @@ -60,13 +61,8 @@ export default { } else { // update pagination offset pagination.start++ - const path = self.$route.path - const params = new URLSearchParams({ - ...self.$route.query, - start: pagination.start.toString(), - limit: pagination.limit.toString(), - }) - self.$router.push(path + '?' + params.toString()) + // prevent "Too many calls to Location or History APIs within a short timeframe" + self.delayedPaginationUpdate() } } @@ -128,6 +124,38 @@ export default { } }, + // This will only update the pagination offset at a maximum of 2x per second + // when viewing the inbox on > page 1, while receiving an influx of new messages. + delayedPaginationUpdate: function () { + if (this.paginationDelayed) { + return + } + + this.paginationDelayed = true + + window.setTimeout(() => { + const path = this.$route.path + const p = { + ...this.$route.query + } + if (pagination.start > 0) { + p.start = pagination.start.toString() + } else { + delete p.start + } + if (pagination.limit != pagination.defaultLimit) { + p.limit = pagination.limit.toString() + } else { + delete p.limit + } + + const params = new URLSearchParams(p) + this.$router.push(path + '?' + params.toString()) + + this.paginationDelayed = false + }, 500) + }, + browserNotify: function (title, message) { if (!("Notification" in window)) { return diff --git a/server/ui-src/components/Pagination.vue b/server/ui-src/components/Pagination.vue index 9998061..6d029f1 100644 --- a/server/ui-src/components/Pagination.vue +++ b/server/ui-src/components/Pagination.vue @@ -1,7 +1,7 @@