Skip to content

Commit 664f2c1

Browse files
limit request list to 25 items (frontend config maxRequests)
1 parent 0a949e5 commit 664f2c1

2 files changed

Lines changed: 8 additions & 3 deletions

File tree

‎client/src/models/Config.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ export type DebugbarConfigOptions = {
1212
interval: number
1313
}
1414
height: number
15+
maxRequests: number
1516
}
1617

1718
export type DebugbarConfig = DebugbarConfigOptions & {
@@ -32,6 +33,7 @@ export function newDebugbarConfig(options: DebugbarConfigOptions) {
3233
interval: 500,
3334
},
3435
height: 360,
36+
maxRequests: 25,
3537
} as DebugbarConfigOptions)
3638

3739
obj.actionCableUrl = `${obj.cable.url}${obj.prefix}/cable`

‎client/src/stores/RequestsStore.ts‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { defineStore } from "pinia"
22
import { BackendRequest, BackendRequestData } from "@/models/Request.ts"
3+
import { useConfigStore } from "@/stores/configStore.ts"
34

45
export let useRequestsStore = defineStore("requests", {
56
state: () => {
@@ -20,6 +21,11 @@ export let useRequestsStore = defineStore("requests", {
2021
}
2122
ids.push(r.id)
2223
})
24+
25+
while (this.requests.length > useConfigStore().config.maxRequests) {
26+
this.requests.shift()
27+
}
28+
2329
return ids
2430
},
2531
setCurrentRequestById(id: string) {
@@ -29,8 +35,5 @@ export let useRequestsStore = defineStore("requests", {
2935
this.requests = []
3036
this.currentRequest = null
3137
},
32-
// removeRequest(request) {
33-
// this.requests.splice(this.requests.indexOf(request), 1)
34-
// },
3538
},
3639
})

0 commit comments

Comments
 (0)