Skip to content

Commit

Permalink
limit request list to 25 items (frontend config maxRequests)
Browse files Browse the repository at this point in the history
  • Loading branch information
julienbourdeau committed Mar 31, 2024
1 parent 0a949e5 commit 664f2c1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
2 changes: 2 additions & 0 deletions client/src/models/Config.ts
Expand Up @@ -12,6 +12,7 @@ export type DebugbarConfigOptions = {
interval: number
}
height: number
maxRequests: number
}

export type DebugbarConfig = DebugbarConfigOptions & {
Expand All @@ -32,6 +33,7 @@ export function newDebugbarConfig(options: DebugbarConfigOptions) {
interval: 500,
},
height: 360,
maxRequests: 25,
} as DebugbarConfigOptions)

obj.actionCableUrl = `${obj.cable.url}${obj.prefix}/cable`
Expand Down
9 changes: 6 additions & 3 deletions client/src/stores/RequestsStore.ts
@@ -1,5 +1,6 @@
import { defineStore } from "pinia"
import { BackendRequest, BackendRequestData } from "@/models/Request.ts"
import { useConfigStore } from "@/stores/configStore.ts"

export let useRequestsStore = defineStore("requests", {
state: () => {
Expand All @@ -20,6 +21,11 @@ export let useRequestsStore = defineStore("requests", {
}
ids.push(r.id)
})

while (this.requests.length > useConfigStore().config.maxRequests) {
this.requests.shift()
}

return ids
},
setCurrentRequestById(id: string) {
Expand All @@ -29,8 +35,5 @@ export let useRequestsStore = defineStore("requests", {
this.requests = []
this.currentRequest = null
},
// removeRequest(request) {
// this.requests.splice(this.requests.indexOf(request), 1)
// },
},
})

0 comments on commit 664f2c1

Please sign in to comment.