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:
thePR0M3TH3AN authored and GitHub committed 2026-01-22 19:24:08 -05:00
commit a1a4d0bf6b
2 files changed
+25 -13

No files matched your search

+15 -9
View File
@@ -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) {
+10 -4
View File
@@ -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) => ({