mirror of
https://github.com/axllent/mailpit.git
synced 2025-06-17 00:07:54 +02:00
Improve pagination & limit URL parameter handling
This commit is contained in:
@ -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
|
||||
|
Reference in New Issue
Block a user