diff --git a/src/pages/catchup.jsx b/src/pages/catchup.jsx index 30000bfd..80f3d513 100644 --- a/src/pages/catchup.jsx +++ b/src/pages/catchup.jsx @@ -41,6 +41,7 @@ import states, { statusKey } from '../utils/states'; import statusPeek from '../utils/status-peek'; import store from '../utils/store'; import { getCurrentAccountID, getCurrentAccountNS } from '../utils/store-utils'; +import supports from '../utils/supports'; import { assignFollowedTags } from '../utils/timeline-utils'; import useTitle from '../utils/useTitle'; @@ -116,6 +117,8 @@ function Catchup() { }, []); const isSelf = (accountID) => accountID === currentAccount; + const supportsPixelfed = supports('@pixelfed/home-include-reblogs'); + async function fetchHome({ maxCreatedAt }) { const maxCreatedAtDate = maxCreatedAt ? new Date(maxCreatedAt) : null; console.debug('fetchHome', maxCreatedAtDate); @@ -123,6 +126,13 @@ function Catchup() { const homeIterator = masto.v1.timelines.home.list({ limit: 40 }); mainloop: while (true) { try { + if (supportsPixelfed && homeIterator.nextParams) { + if (typeof homeIterator.nextParams === 'string') { + homeIterator.nextParams += '&include_reblogs=true'; + } else { + homeIterator.nextParams.include_reblogs = true; + } + } const results = await homeIterator.next(); const { value } = results; if (value?.length) { diff --git a/src/pages/following.jsx b/src/pages/following.jsx index 0192788a..5a48de29 100644 --- a/src/pages/following.jsx +++ b/src/pages/following.jsx @@ -6,6 +6,7 @@ import { api } from '../utils/api'; import { filteredItems } from '../utils/filters'; import states from '../utils/states'; import { getStatus, saveStatus } from '../utils/states'; +import supports from '../utils/supports'; import { assignFollowedTags, clearFollowedTagsState, @@ -23,11 +24,19 @@ function Following({ title, path, id, ...props }) { const latestItem = useRef(); console.debug('RENDER Following', title, id); + const supportsPixelfed = supports('@pixelfed/home-include-reblogs'); async function fetchHome(firstLoad) { if (firstLoad || !homeIterator.current) { homeIterator.current = masto.v1.timelines.home.list({ limit: LIMIT }); } + if (supportsPixelfed && homeIterator.current?.nextParams) { + if (typeof homeIterator.current.nextParams === 'string') { + homeIterator.current.nextParams += '&include_reblogs=true'; + } else { + homeIterator.current.nextParams.include_reblogs = true; + } + } const results = await homeIterator.current.next(); let { value } = results; if (value?.length) { @@ -63,12 +72,14 @@ function Following({ title, path, id, ...props }) { async function checkForUpdates() { try { - const results = await masto.v1.timelines.home - .list({ - limit: 5, - since_id: latestItem.current, - }) - .next(); + const opts = { + limit: 5, + since_id: latestItem.current, + }; + if (supports('@pixelfed/home-include-reblogs')) { + opts.include_reblogs = true; + } + const results = await masto.v1.timelines.home.list(opts).next(); let { value } = results; console.log('checkForUpdates', latestItem.current, value); const valueContainsLatestItem = value[0]?.id === latestItem.current; // since_id might not be supported diff --git a/src/utils/supports.js b/src/utils/supports.js index 6b94126e..95d613c1 100644 --- a/src/utils/supports.js +++ b/src/utils/supports.js @@ -18,6 +18,7 @@ const platformFeatures = { '@mastodon/profile-edit': notContainPixelfed, '@mastodon/profile-private-note': notContainPixelfed, '@pixelfed/trending': containPixelfed, + '@pixelfed/home-include-reblogs': containPixelfed, }; const supportsCache = {};