nicolium: restore error handling
Signed-off-by: nicole mikołajczyk <git@mkljczk.pl>
This commit is contained in:
@ -1,5 +1,5 @@
|
||||
import clsx from 'clsx';
|
||||
import React, { useState } from 'react';
|
||||
import React from 'react';
|
||||
import { FormattedMessage } from 'react-intl';
|
||||
|
||||
import { PublicTimelineColumn } from '@/columns/timeline';
|
||||
@ -12,6 +12,7 @@ import Stack from '@/components/ui/stack';
|
||||
import { useInstance } from '@/hooks/use-instance';
|
||||
import { useRegistrationStatus } from '@/hooks/use-registration-status';
|
||||
import { About } from '@/pages/utils/about';
|
||||
import { usePublicTimeline } from '@/queries/timelines/use-timelines';
|
||||
import { getTextDirection } from '@/utils/rtl';
|
||||
|
||||
interface ILogoText extends Pick<React.HTMLAttributes<HTMLHeadingElement>, 'className' | 'dir'> {
|
||||
@ -53,8 +54,7 @@ const LandingTimelinePage = () => {
|
||||
const instance = useInstance();
|
||||
const { isOpen } = useRegistrationStatus();
|
||||
|
||||
// todo fix this
|
||||
const [timelineFailed, _setTimelineFailed] = useState(false);
|
||||
const { isError } = usePublicTimeline({ local: true });
|
||||
|
||||
const timelineEnabled = !instance.pleroma.metadata.restrict_unauthenticated.timelines.local;
|
||||
|
||||
@ -75,7 +75,7 @@ const LandingTimelinePage = () => {
|
||||
)}
|
||||
</HStack>
|
||||
|
||||
{timelineEnabled && !timelineFailed ? (
|
||||
{timelineEnabled && !isError ? (
|
||||
<PublicTimelineColumn
|
||||
local
|
||||
emptyMessageText={
|
||||
|
||||
@ -21,7 +21,7 @@ const useTimeline = (timelineId: string, fetcher: TimelineFetcher, streamConfig?
|
||||
useTimelineStream(streamConfig?.stream ?? '', streamConfig?.params, !!streamConfig?.stream);
|
||||
|
||||
useEffect(() => {
|
||||
if (!timeline.isPending) return;
|
||||
if (!timeline.isPending || timeline.isFetching) return;
|
||||
fetchInitial();
|
||||
}, []);
|
||||
|
||||
@ -32,7 +32,7 @@ const useTimeline = (timelineId: string, fetcher: TimelineFetcher, streamConfig?
|
||||
importEntities({ statuses: response.items });
|
||||
timelineActions.expandTimeline(timelineId, response.items, !!response.next, true);
|
||||
} catch (error) {
|
||||
//
|
||||
timelineActions.setError(timelineId, true);
|
||||
}
|
||||
}, [timelineId]);
|
||||
|
||||
@ -46,7 +46,7 @@ const useTimeline = (timelineId: string, fetcher: TimelineFetcher, streamConfig?
|
||||
|
||||
timelineActions.expandTimeline(timelineId, response.items, !!response.next, false);
|
||||
} catch (error) {
|
||||
//
|
||||
timelineActions.setError(timelineId, true);
|
||||
}
|
||||
}, [timelineId, timeline.oldestStatusId]);
|
||||
|
||||
|
||||
@ -31,6 +31,7 @@ interface TimelineData {
|
||||
queuedCount: number;
|
||||
isFetching: boolean;
|
||||
isPending: boolean;
|
||||
isError: boolean;
|
||||
hasNextPage: boolean;
|
||||
oldestStatusId?: string;
|
||||
}
|
||||
@ -47,6 +48,7 @@ interface State {
|
||||
receiveStreamingStatus: (timelineId: string, status: Status) => void;
|
||||
deleteStatus: (statusId: string) => void;
|
||||
setLoading: (timelineId: string, isFetching: boolean) => void;
|
||||
setError: (timelineId: string, isError: boolean) => void;
|
||||
dequeueEntries: (timelineId: string) => void;
|
||||
importPendingStatus: (params: CreateStatusParams, idempotencyKey: string) => void;
|
||||
replacePendingStatus: (idempotencyKey: string, newId: string) => void;
|
||||
@ -193,6 +195,15 @@ const useTimelinesStore = create<State>()(
|
||||
if (!isFetching) timeline.isPending = false;
|
||||
state.timelines[timelineId] = timeline;
|
||||
}),
|
||||
setError: (timelineId, isError) =>
|
||||
set((state) => {
|
||||
const timeline = state.timelines[timelineId] ?? createEmptyTimeline();
|
||||
|
||||
timeline.isFetching = false;
|
||||
timeline.isPending = false;
|
||||
timeline.isError = isError;
|
||||
state.timelines[timelineId] = timeline;
|
||||
}),
|
||||
dequeueEntries: (timelineId) =>
|
||||
set((state) => {
|
||||
const timeline = state.timelines[timelineId];
|
||||
@ -289,6 +300,7 @@ const createEmptyTimeline = (): TimelineData => ({
|
||||
queuedCount: 0,
|
||||
isFetching: false,
|
||||
isPending: true,
|
||||
isError: false,
|
||||
hasNextPage: true,
|
||||
oldestStatusId: undefined,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user