diff --git a/package.json b/package.json index 162864fc..848118bb 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "impro", - "version": "0.17.137", + "version": "0.17.138", "type": "module", "scripts": { "start": "rm -rf \"${BUILD_DIR:-build}\" && NODE_ENV=development eleventy --serve", diff --git a/src/js/config.js b/src/js/config.js index da2c5f21..0c0e722f 100644 --- a/src/js/config.js +++ b/src/js/config.js @@ -5,7 +5,7 @@ export const FEED_PAGE_SIZE = 40; export const HASHTAG_FEED_PAGE_SIZE = 40; export const BOOKMARKS_PAGE_SIZE = 40; export const AUTHOR_FEED_PAGE_SIZE = 40; -export const DISCOVER_FEED_URI = +export const LOGGED_OUT_FEED_URI = "at://did:plc:z72i7hdynmk6r22z27h6tvur/app.bsky.feed.generator/whats-hot"; export const CHAT_MESSAGES_PAGE_SIZE = 100; diff --git a/src/js/dataHelpers.js b/src/js/dataHelpers.js index e8a5e53c..0b555790 100644 --- a/src/js/dataHelpers.js +++ b/src/js/dataHelpers.js @@ -38,6 +38,10 @@ export function buildUri({ repo, collection, rkey }) { return `at://${repo}/${collection}/${rkey}`; } +export function isListFeed(feedURI) { + return feedURI.includes("/app.bsky.graph.list/"); +} + export function getRKey(record) { return record.uri.split("/").pop(); } diff --git a/src/js/dataLayer/requests.js b/src/js/dataLayer/requests.js index ce98816a..cf698fdb 100644 --- a/src/js/dataLayer/requests.js +++ b/src/js/dataLayer/requests.js @@ -9,6 +9,7 @@ import { getPostUrisFromNotifications, buildUri, parseUri, + isListFeed, isGroupConvo, getGroupConvoDetails, getJoinLinkCodesFromPosts, @@ -473,11 +474,10 @@ export class Requests { const cursor = reload ? "" : readCollectionCursor(this.dataStore.$feeds, { key: feedURI }); - const isListFeed = feedURI.includes("/app.bsky.graph.list/"); const feed = feedURI === "following" ? await this.api.getFollowingFeed({ limit, cursor, labelers }) - : isListFeed + : isListFeed(feedURI) ? await this.api.getListFeed(feedURI, { limit, cursor, labelers }) : await this.api.getFeed(feedURI, { limit, cursor, labelers }); // Save posts diff --git a/src/js/preferences.js b/src/js/preferences.js index 077c7687..9ebb3668 100644 --- a/src/js/preferences.js +++ b/src/js/preferences.js @@ -10,8 +10,9 @@ import { } from "/js/dataHelpers.js"; import { deepClone } from "/js/utils.js"; import { generateTid } from "/js/atproto.js"; -import { DISCOVER_FEED_URI, BSKY_LABELER_DID } from "/js/config.js"; +import { LOGGED_OUT_FEED_URI, BSKY_LABELER_DID } from "/js/config.js"; import { getTagsFromFacets } from "/js/facetHelpers.js"; +import { isListFeed } from "/js/dataHelpers.js"; function getContentTextFromEmbed(embed) { const texts = []; @@ -611,8 +612,8 @@ export class Preferences { items: [ { id: "3l6ovcmm2vd2j", - type: "feed", - value: DISCOVER_FEED_URI, + type: isListFeed(LOGGED_OUT_FEED_URI) ? "list" : "feed", + value: LOGGED_OUT_FEED_URI, pinned: true, }, ], diff --git a/src/js/views/home.view.js b/src/js/views/home.view.js index 232989eb..bc822435 100644 --- a/src/js/views/home.view.js +++ b/src/js/views/home.view.js @@ -5,7 +5,7 @@ import { postFeedTemplate } from "/js/templates/postFeed.template.js"; import { headerTemplate } from "/js/templates/header.template.js"; import "/js/components/tab-bar.js"; import { PostSeenObserver } from "/js/postSeenObserver.js"; -import { FEED_PAGE_SIZE, DISCOVER_FEED_URI } from "/js/config.js"; +import { FEED_PAGE_SIZE, LOGGED_OUT_FEED_URI } from "/js/config.js"; import { bindToPage, pageEffect } from "/js/router.js"; import { showToast } from "/js/toasts.js"; import { Signal, ReactiveStore } from "/js/signals.js"; @@ -38,7 +38,7 @@ class HomeView extends View { function resetToDefaultFeed() { state.$currentFeedUri.set( - isAuthenticated ? "following" : DISCOVER_FEED_URI, + isAuthenticated ? "following" : LOGGED_OUT_FEED_URI, ); } @@ -81,7 +81,7 @@ class HomeView extends View { return; } const interactableItems = pinnedItems.filter( - (item) => item.acceptsInteractions || item.uri === DISCOVER_FEED_URI, + (item) => item.acceptsInteractions || item.uri === LOGGED_OUT_FEED_URI, ); for (const observer of postSeenObservers.values()) { observer.disconnect(); @@ -220,7 +220,8 @@ class HomeView extends View {
${pinnedItems.map((item) => { const acceptsInteractions = - item.acceptsInteractions || item.uri === DISCOVER_FEED_URI; + item.acceptsInteractions || + item.uri === LOGGED_OUT_FEED_URI; const feed = dataLayer.derived.$hydratedFeeds.get(item.uri); const feedRequestStatus = dataLayer.requests.statusStore.$statuses.get( diff --git a/tests/unit/specs/dataHelpers.test.js b/tests/unit/specs/dataHelpers.test.js index d86f67d9..c56129c7 100644 --- a/tests/unit/specs/dataHelpers.test.js +++ b/tests/unit/specs/dataHelpers.test.js @@ -4,6 +4,7 @@ import { avatarThumbnailUrl, getRKey, getIsLiked, + isListFeed, getQuotedPost, getBlockedQuote, createEmbedFromPost, @@ -82,6 +83,26 @@ describe("getRKey", () => { }); }); +describe("isListFeed", () => { + it("should return true for a list URI", () => { + assert.deepEqual( + isListFeed("at://did:plc:123/app.bsky.graph.list/3ltcvl4ver723"), + true, + ); + }); + + it("should return false for a feed generator URI", () => { + assert.deepEqual( + isListFeed("at://did:plc:123/app.bsky.feed.generator/whats-hot"), + false, + ); + }); + + it("should return false for the following feed", () => { + assert.deepEqual(isListFeed("following"), false); + }); +}); + describe("getIsLiked", () => { it("should return true when post has viewer like", () => { const post = { viewer: { like: "at://did:plc:123/like/abc123" } };