Test fix Pixelfed home timeline not showing reblogs

This commit is contained in:
Lim Chee Aun 2024-05-28 13:44:24 +08:00
parent ed712d15f1
commit d16221e296
3 changed files with 28 additions and 6 deletions

View file

@ -41,6 +41,7 @@ import states, { statusKey } from '../utils/states';
import statusPeek from '../utils/status-peek'; import statusPeek from '../utils/status-peek';
import store from '../utils/store'; import store from '../utils/store';
import { getCurrentAccountID, getCurrentAccountNS } from '../utils/store-utils'; import { getCurrentAccountID, getCurrentAccountNS } from '../utils/store-utils';
import supports from '../utils/supports';
import { assignFollowedTags } from '../utils/timeline-utils'; import { assignFollowedTags } from '../utils/timeline-utils';
import useTitle from '../utils/useTitle'; import useTitle from '../utils/useTitle';
@ -116,6 +117,8 @@ function Catchup() {
}, []); }, []);
const isSelf = (accountID) => accountID === currentAccount; const isSelf = (accountID) => accountID === currentAccount;
const supportsPixelfed = supports('@pixelfed/home-include-reblogs');
async function fetchHome({ maxCreatedAt }) { async function fetchHome({ maxCreatedAt }) {
const maxCreatedAtDate = maxCreatedAt ? new Date(maxCreatedAt) : null; const maxCreatedAtDate = maxCreatedAt ? new Date(maxCreatedAt) : null;
console.debug('fetchHome', maxCreatedAtDate); console.debug('fetchHome', maxCreatedAtDate);
@ -123,6 +126,13 @@ function Catchup() {
const homeIterator = masto.v1.timelines.home.list({ limit: 40 }); const homeIterator = masto.v1.timelines.home.list({ limit: 40 });
mainloop: while (true) { mainloop: while (true) {
try { 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 results = await homeIterator.next();
const { value } = results; const { value } = results;
if (value?.length) { if (value?.length) {

View file

@ -6,6 +6,7 @@ import { api } from '../utils/api';
import { filteredItems } from '../utils/filters'; import { filteredItems } from '../utils/filters';
import states from '../utils/states'; import states from '../utils/states';
import { getStatus, saveStatus } from '../utils/states'; import { getStatus, saveStatus } from '../utils/states';
import supports from '../utils/supports';
import { import {
assignFollowedTags, assignFollowedTags,
clearFollowedTagsState, clearFollowedTagsState,
@ -23,11 +24,19 @@ function Following({ title, path, id, ...props }) {
const latestItem = useRef(); const latestItem = useRef();
console.debug('RENDER Following', title, id); console.debug('RENDER Following', title, id);
const supportsPixelfed = supports('@pixelfed/home-include-reblogs');
async function fetchHome(firstLoad) { async function fetchHome(firstLoad) {
if (firstLoad || !homeIterator.current) { if (firstLoad || !homeIterator.current) {
homeIterator.current = masto.v1.timelines.home.list({ limit: LIMIT }); 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(); const results = await homeIterator.current.next();
let { value } = results; let { value } = results;
if (value?.length) { if (value?.length) {
@ -63,12 +72,14 @@ function Following({ title, path, id, ...props }) {
async function checkForUpdates() { async function checkForUpdates() {
try { try {
const results = await masto.v1.timelines.home const opts = {
.list({ limit: 5,
limit: 5, since_id: latestItem.current,
since_id: latestItem.current, };
}) if (supports('@pixelfed/home-include-reblogs')) {
.next(); opts.include_reblogs = true;
}
const results = await masto.v1.timelines.home.list(opts).next();
let { value } = results; let { value } = results;
console.log('checkForUpdates', latestItem.current, value); console.log('checkForUpdates', latestItem.current, value);
const valueContainsLatestItem = value[0]?.id === latestItem.current; // since_id might not be supported const valueContainsLatestItem = value[0]?.id === latestItem.current; // since_id might not be supported

View file

@ -18,6 +18,7 @@ const platformFeatures = {
'@mastodon/profile-edit': notContainPixelfed, '@mastodon/profile-edit': notContainPixelfed,
'@mastodon/profile-private-note': notContainPixelfed, '@mastodon/profile-private-note': notContainPixelfed,
'@pixelfed/trending': containPixelfed, '@pixelfed/trending': containPixelfed,
'@pixelfed/home-include-reblogs': containPixelfed,
}; };
const supportsCache = {}; const supportsCache = {};