mirror of
https://git.sr.ht/~cadence/bibliogram
synced 2025-12-14 18:45:06 +00:00
Cache enhancements:
- Use quota for /p/ requests - Correctly detect owner.full_name to save unneeded requests out - Unify quota reached pages - Unify post presentation into function that fetches prerequisites - Add getByID method to userRequestCache
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import {q, ElemJS} from "./elemjs/elemjs.js"
|
||||
import {timeline} from "./post_series.js"
|
||||
import {quota} from "./quota.js"
|
||||
|
||||
/** @type {PostOverlay[]} */
|
||||
const postOverlays = []
|
||||
@@ -139,6 +140,12 @@ function loadPostOverlay(shortcode, stateChangeType) {
|
||||
window.location.assign(root.redirectTo)
|
||||
return
|
||||
}
|
||||
|
||||
if (root.quota) {
|
||||
quota.set(root.quota)
|
||||
delete root.quota // don't apply the old quota next time the post is opened
|
||||
}
|
||||
|
||||
shortcodeDataMap.set(shortcode, root)
|
||||
if (overlay.available) {
|
||||
const {title, html} = root
|
||||
|
||||
@@ -6,6 +6,11 @@ class Quota extends ElemJS {
|
||||
this.value = +this.element.textContent
|
||||
}
|
||||
|
||||
set(value) {
|
||||
this.value = value
|
||||
this.text(this.value)
|
||||
}
|
||||
|
||||
change(difference) {
|
||||
this.value += difference
|
||||
this.value = Math.max(0, this.value)
|
||||
|
||||
Reference in New Issue
Block a user