mirror of
https://github.com/PR0M3TH3AN/bitvid.git
synced 2026-10-27 07:52:24 +00:00
Merge pull request #1529 from PR0M3TH3AN/codex/add-feed-aware-video-ordering-option
Preserve explore feed ordering in video list rendering
This commit is contained in:
2 files changed
+25
-13
No files matched your search
@@ -5952,12 +5952,20 @@ class Application {
|
||||
const runtime = this.buildExploreFeedRuntime();
|
||||
const normalizedReason = typeof reason === "string" ? reason : undefined;
|
||||
const fallback = Array.isArray(fallbackVideos) ? fallbackVideos : [];
|
||||
const applyExploreOrderingMetadata = (source) => {
|
||||
const next = source && typeof source === "object" ? { ...source } : {};
|
||||
if (!next.sortOrder) {
|
||||
next.sortOrder = "explore";
|
||||
}
|
||||
next.preserveOrder = true;
|
||||
return next;
|
||||
};
|
||||
|
||||
if (!this.feedEngine || typeof this.feedEngine.run !== "function") {
|
||||
const metadata = {
|
||||
const metadata = applyExploreOrderingMetadata({
|
||||
reason: normalizedReason,
|
||||
engine: "unavailable",
|
||||
};
|
||||
});
|
||||
this.latestFeedMetadata = metadata;
|
||||
this.videosMap = this.nostrService.getVideosMap();
|
||||
if (this.videoListView) {
|
||||
@@ -5971,12 +5979,10 @@ class Application {
|
||||
.run("explore", { runtime })
|
||||
.then((result) => {
|
||||
const videos = Array.isArray(result?.videos) ? result.videos : [];
|
||||
const metadata = {
|
||||
const metadata = applyExploreOrderingMetadata({
|
||||
...(result?.metadata || {}),
|
||||
};
|
||||
if (normalizedReason) {
|
||||
metadata.reason = normalizedReason;
|
||||
}
|
||||
...(normalizedReason ? { reason: normalizedReason } : {}),
|
||||
});
|
||||
|
||||
this.latestFeedMetadata = metadata;
|
||||
this.videosMap = this.nostrService.getVideosMap();
|
||||
@@ -5990,10 +5996,10 @@ class Application {
|
||||
})
|
||||
.catch((error) => {
|
||||
devLogger.error("[Application] Failed to run explore feed:", error);
|
||||
const metadata = {
|
||||
const metadata = applyExploreOrderingMetadata({
|
||||
reason: normalizedReason || "error:explore-feed",
|
||||
error: true,
|
||||
};
|
||||
});
|
||||
this.latestFeedMetadata = metadata;
|
||||
this.videosMap = this.nostrService.getVideosMap();
|
||||
if (this.videoListView) {
|
||||
|
||||
@@ -599,10 +599,16 @@ export class VideoListView {
|
||||
return displayVideos;
|
||||
}
|
||||
|
||||
displayVideos.sort(
|
||||
(a, b) =>
|
||||
this.getVideoPostedAtForSort(b) - this.getVideoPostedAtForSort(a),
|
||||
);
|
||||
const preserveOrder =
|
||||
normalizedMetadata?.sortOrder === "explore" ||
|
||||
normalizedMetadata?.preserveOrder === true;
|
||||
|
||||
if (!preserveOrder) {
|
||||
displayVideos.sort(
|
||||
(a, b) =>
|
||||
this.getVideoPostedAtForSort(b) - this.getVideoPostedAtForSort(a),
|
||||
);
|
||||
}
|
||||
this.currentVideos = displayVideos.slice();
|
||||
|
||||
const signaturePayload = displayVideos.map((video) => ({
|
||||
|
||||
Reference in new issue
Block a user