1
0
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:
Cadence Ember
2020-07-29 21:51:41 +12:00
parent 736de3063a
commit 44c8e96a94
7 changed files with 145 additions and 80 deletions

View File

@@ -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

View File

@@ -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)