|
1 | | -import { $$, ajax, replaceToolbarState } from "./utils.js"; |
| 1 | +import { $$, ajax, replaceToolbarState, debounce } from "./utils.js"; |
2 | 2 |
|
3 | 3 | function onKeyDown(event) { |
4 | 4 | if (event.keyCode === 27) { |
@@ -259,27 +259,21 @@ const djdt = { |
259 | 259 | update_on_ajax() { |
260 | 260 | const sidebar_url = |
261 | 261 | document.getElementById("djDebug").dataset.sidebarUrl; |
| 262 | + const slowjax = debounce(ajax, 400); |
262 | 263 |
|
263 | 264 | const origOpen = XMLHttpRequest.prototype.open; |
264 | 265 | XMLHttpRequest.prototype.open = function () { |
265 | 266 | this.addEventListener("load", function () { |
266 | | - if ( |
267 | | - this.responseURL !== "" && |
268 | | - this.responseURL.indexOf("__debug__") === -1 |
269 | | - ) { |
270 | | - let signed = this.getResponseHeader( |
271 | | - "dj-toolbar-store-id-signature" |
272 | | - ); |
273 | | - const store_id = this.getResponseHeader( |
274 | | - "dj-toolbar-store-id" |
275 | | - ); |
276 | | - if (signed !== null) { |
277 | | - signed = encodeURIComponent(signed); |
278 | | - const dest = `${sidebar_url}?signed=${signed}`; |
279 | | - ajax(dest).then(function (data) { |
280 | | - replaceToolbarState(store_id, data); |
281 | | - }); |
282 | | - } |
| 267 | + let signed = this.getResponseHeader( |
| 268 | + "dj-toolbar-store-id-signature" |
| 269 | + ); |
| 270 | + const store_id = this.getResponseHeader("dj-toolbar-store-id"); |
| 271 | + if (signed !== null) { |
| 272 | + signed = encodeURIComponent(signed); |
| 273 | + const dest = `${sidebar_url}?signed=${signed}`; |
| 274 | + slowjax(dest).then(function (data) { |
| 275 | + replaceToolbarState(store_id, data); |
| 276 | + }); |
283 | 277 | } |
284 | 278 | }); |
285 | 279 | origOpen.apply(this, arguments); |
|
0 commit comments