mirror of
https://github.com/PR0M3TH3AN/bitvid.git
synced 2026-11-08 22:02:54 +00:00
Improve relay hygiene and count status
This commit is contained in:
1 parent
6ae4b7ab4f
commit
c3e986c9d3
12 files changed
+286
-59
No files matched your search
@@ -1134,16 +1134,20 @@ export class VideoListView {
|
||||
elements: new Set(),
|
||||
lastTotal: null,
|
||||
lastStatus: "idle",
|
||||
lastPartial: false,
|
||||
lastText: "– views",
|
||||
};
|
||||
|
||||
try {
|
||||
const token = subscribeToVideoViewCount(pointerInfo.pointer, ({ total, status }) => {
|
||||
const token = subscribeToVideoViewCount(pointerInfo.pointer, ({ total, status, partial }) => {
|
||||
let text;
|
||||
if (Number.isFinite(total)) {
|
||||
const numeric = Number(total);
|
||||
entry.lastTotal = numeric;
|
||||
text = this.formatters.formatViewCountLabel(numeric);
|
||||
if (partial) {
|
||||
text = `${text} (partial)`;
|
||||
}
|
||||
} else if (status === "hydrating") {
|
||||
text = "Loading views…";
|
||||
} else {
|
||||
@@ -1151,6 +1155,7 @@ export class VideoListView {
|
||||
}
|
||||
|
||||
entry.lastStatus = status;
|
||||
entry.lastPartial = Boolean(partial);
|
||||
entry.lastText = text;
|
||||
|
||||
for (const el of Array.from(entry.elements)) {
|
||||
@@ -1159,6 +1164,11 @@ export class VideoListView {
|
||||
continue;
|
||||
}
|
||||
el.textContent = text;
|
||||
if (entry.lastPartial) {
|
||||
el.dataset.viewCountState = "partial";
|
||||
} else {
|
||||
el.dataset.viewCountState = status;
|
||||
}
|
||||
}
|
||||
});
|
||||
entry.token = token;
|
||||
@@ -1193,6 +1203,9 @@ export class VideoListView {
|
||||
if (typeof pointerInfo.key === "string") {
|
||||
viewCountEl.dataset.viewPointer = pointerInfo.key;
|
||||
}
|
||||
viewCountEl.dataset.viewCountState = entry.lastPartial
|
||||
? "partial"
|
||||
: entry.lastStatus;
|
||||
viewCountEl.textContent = entry.lastText;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user