Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rework timelines #187

Draft
wants to merge 49 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
27e2071
pl-fe: start reworking timelines, migrating to queryOptions
mkljczk Dec 9, 2024
2eb502d
pl-fe: update most queries to queryOptions
mkljczk Dec 9, 2024
c8002c3
pl-fe: migrations to query options
mkljczk Dec 9, 2024
4d89701
pl-fe: do not use scrobble query inside account queries
mkljczk Dec 10, 2024
c19bd1e
pl-fe: migrate more queries
mkljczk Dec 10, 2024
09ca820
pl-fe: bump tanstack query version
mkljczk Dec 10, 2024
3603591
pl-fe: save changes actually
mkljczk Dec 10, 2024
dd16631
pl-fe: remove unused
mkljczk Dec 10, 2024
c52501c
pl-fe: fix
mkljczk Dec 10, 2024
2f2aabd
pl-fe: cleanup remaining queries
mkljczk Dec 11, 2024
911dc34
pl-fe: i hate my life
mkljczk Dec 11, 2024
c4c21c6
pl-fe: updated reblogs display
mkljczk Dec 12, 2024
459c147
pl-fe: workaround
mkljczk Dec 12, 2024
e0a0836
pl-fe: wip migrations
mkljczk Dec 12, 2024
5e225dc
pl-fe: migrate status interactions to tanstack query
mkljczk Dec 13, 2024
f7d6674
pl-fe: move force show status to status meta
mkljczk Dec 13, 2024
23a99d0
pl-fe: migrate emoji reactions
mkljczk Dec 13, 2024
4fa7a59
pl-fe: migrate event actions to tanstack query
mkljczk Dec 13, 2024
b6cef36
pl-fe: set initial search offset to undefined
mkljczk Dec 14, 2024
7174f86
pl-fe: lint
mkljczk Dec 14, 2024
09f5ea8
Merge branch 'develop' into timelines-refactor
mkljczk Dec 14, 2024
0caf155
pl-fe: migrate mute status
mkljczk Dec 14, 2024
152c6f5
pl-fe: migrate scheduled statuses
mkljczk Dec 14, 2024
b9bbbdb
pl-fe: cleanup
mkljczk Dec 14, 2024
db14b1e
pl-fe: wip create/edit status mutations
mkljczk Dec 14, 2024
de2aebd
Merge branch 'develop' into timelines-refactor
mkljczk Dec 15, 2024
4ec0a21
pl-fe: moar migrations
mkljczk Dec 15, 2024
08db517
pl-fe: fix
mkljczk Dec 15, 2024
a42d08e
pl-fe: mostly get rid of statuses reducer usage
mkljczk Dec 15, 2024
8e894b5
pl-fe: remove makeGetStatus
mkljczk Dec 16, 2024
a53a6ca
pl-fe: minify normalized statuses
mkljczk Dec 16, 2024
56ebee8
pl-fe: more minification
mkljczk Dec 16, 2024
1baae5c
pl-fe: migrate cliebnt-side status filtering
mkljczk Dec 16, 2024
6d3ce5c
pl-fe: memoize filtered
mkljczk Dec 16, 2024
ac31eae
pl-fe: fix filters
mkljczk Dec 16, 2024
66abed4
Merge branch 'develop' into timelines-refactor
mkljczk Dec 16, 2024
3ee4b8c
pl-fe: migrate status deletion
mkljczk Dec 16, 2024
e6a8fef
pl-fe: remove fetchStatus
mkljczk Dec 16, 2024
bb9dc58
pl-fe: remove unused import
mkljczk Dec 16, 2024
1130a17
pl-fe: add back bookmark toasts
mkljczk Dec 16, 2024
c95623e
Merge branch 'develop' into timelines-refactor
mkljczk Dec 16, 2024
f91d293
Merge branch 'develop' into timelines-refactor
mkljczk Dec 18, 2024
c288d5d
pl-fe: update media panels to use tanstack query
mkljczk Dec 18, 2024
bf3fc45
Merge branch 'develop' into timelines-refactor
mkljczk Dec 27, 2024
a1d5645
pl-fe: fix duplicated grouped reblogs
mkljczk Dec 27, 2024
6c1aa2b
pl-fe: delete unused or sth
mkljczk Dec 27, 2024
4c9c7b2
Merge branch 'develop' into timelines-refactor
mkljczk Jan 2, 2025
f70881c
Merge branch 'develop' into timelines-refactor
mkljczk Jan 8, 2025
122e931
pl-fe: fix
mkljczk Jan 8, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/pl-fe/src/actions/accounts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { getClient, type PlfeResponse } from '../api';

import { importEntities } from './importer';

import type { MinifiedSuggestion } from 'pl-fe/queries/trends/use-suggested-accounts';
import type { MinifiedSuggestion } from 'pl-fe/queries/trends/suggested-accounts';
import type { MinifiedStatus } from 'pl-fe/reducers/statuses';
import type { AppDispatch, RootState } from 'pl-fe/store';
import type { History } from 'pl-fe/types/history';
Expand Down
10 changes: 0 additions & 10 deletions packages/pl-fe/src/actions/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ const AUTH_APP_AUTHORIZED = 'AUTH_APP_AUTHORIZED' as const;
const AUTH_LOGGED_IN = 'AUTH_LOGGED_IN' as const;
const AUTH_LOGGED_OUT = 'AUTH_LOGGED_OUT' as const;

const VERIFY_CREDENTIALS_REQUEST = 'VERIFY_CREDENTIALS_REQUEST' as const;
const VERIFY_CREDENTIALS_SUCCESS = 'VERIFY_CREDENTIALS_SUCCESS' as const;
const VERIFY_CREDENTIALS_FAIL = 'VERIFY_CREDENTIALS_FAIL' as const;

Expand Down Expand Up @@ -158,11 +157,6 @@ const otpVerify = (code: string, mfa_token: string) =>
}).then((token) => dispatch(authLoggedIn(token)));
};

interface VerifyCredentialsRequestAction {
type: typeof VERIFY_CREDENTIALS_REQUEST;
token: string;
}

interface VerifyCredentialsSuccessAction {
type: typeof VERIFY_CREDENTIALS_SUCCESS;
token: string;
Expand All @@ -179,8 +173,6 @@ const verifyCredentials = (token: string, accountUrl?: string) =>
(dispatch: AppDispatch, getState: () => RootState) => {
const baseURL = parseBaseURL(accountUrl) || BuildConfig.BACKEND_URL;

dispatch<VerifyCredentialsRequestAction>({ type: VERIFY_CREDENTIALS_REQUEST, token });

const client = new PlApiClient(baseURL, token);

return client.settings.verifyCredentials().then((account) => {
Expand Down Expand Up @@ -336,7 +328,6 @@ type AuthAction =
| AuthAppAuthorizedAction
| AuthLoggedInAction
| AuthLoggedOutAction
| VerifyCredentialsRequestAction
| VerifyCredentialsSuccessAction
| VerifyCredentialsFailAction
| AuthAccountRememberSuccessAction;
Expand All @@ -347,7 +338,6 @@ export {
AUTH_APP_AUTHORIZED,
AUTH_LOGGED_IN,
AUTH_LOGGED_OUT,
VERIFY_CREDENTIALS_REQUEST,
VERIFY_CREDENTIALS_SUCCESS,
VERIFY_CREDENTIALS_FAIL,
AUTH_ACCOUNT_REMEMBER_SUCCESS,
Expand Down
2 changes: 1 addition & 1 deletion packages/pl-fe/src/actions/domain-blocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { getClient } from '../api';
import type { PaginatedResponse } from 'pl-api';
import type { EntityStore } from 'pl-fe/entity-store/types';
import type { Account } from 'pl-fe/normalizers/account';
import type { MinifiedSuggestion } from 'pl-fe/queries/trends/use-suggested-accounts';
import type { MinifiedSuggestion } from 'pl-fe/queries/trends/suggested-accounts';
import type { AppDispatch, RootState } from 'pl-fe/store';

const DOMAIN_UNBLOCK_SUCCESS = 'DOMAIN_UNBLOCK_SUCCESS' as const;
Expand Down
88 changes: 0 additions & 88 deletions packages/pl-fe/src/actions/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,6 @@ import { STATUS_FETCH_SOURCE_FAIL, STATUS_FETCH_SOURCE_REQUEST, STATUS_FETCH_SOU
import type { CreateEventParams, Location, MediaAttachment, PaginatedResponse, Status } from 'pl-api';
import type { AppDispatch, RootState } from 'pl-fe/store';

const EVENT_JOIN_REQUEST = 'EVENT_JOIN_REQUEST' as const;
const EVENT_JOIN_FAIL = 'EVENT_JOIN_FAIL' as const;

const EVENT_LEAVE_REQUEST = 'EVENT_LEAVE_REQUEST' as const;
const EVENT_LEAVE_FAIL = 'EVENT_LEAVE_FAIL' as const;

const EVENT_COMPOSE_CANCEL = 'EVENT_COMPOSE_CANCEL' as const;

const EVENT_FORM_SET = 'EVENT_FORM_SET' as const;
Expand All @@ -26,8 +20,6 @@ const JOINED_EVENTS_FETCH_REQUEST = 'JOINED_EVENTS_FETCH_REQUEST' as const;
const JOINED_EVENTS_FETCH_SUCCESS = 'JOINED_EVENTS_FETCH_SUCCESS' as const;
const JOINED_EVENTS_FETCH_FAIL = 'JOINED_EVENTS_FETCH_FAIL' as const;

const noOp = () => new Promise(f => f(undefined));

const messages = defineMessages({
exceededImageSizeLimit: { id: 'upload_error.image_size_limit', defaultMessage: 'Image exceeds the current file size limit ({limit})' },
success: { id: 'compose_event.submit_success', defaultMessage: 'Your event was created' },
Expand Down Expand Up @@ -95,75 +87,6 @@ const submitEvent = ({
});
};

const joinEvent = (statusId: string, participationMessage?: string) =>
(dispatch: AppDispatch, getState: () => RootState) => {
const status = getState().statuses[statusId];

if (!status || !status.event || status.event.join_state) {
return dispatch(noOp);
}

dispatch(joinEventRequest(status.id));

return getClient(getState).events.joinEvent(statusId, participationMessage).then((data) => {
dispatch(importEntities({ statuses: [data] }));
toast.success(
data.event?.join_state === 'pending' ? messages.joinRequestSuccess : messages.joinSuccess,
{
actionLabel: messages.view,
actionLink: `/@${data.account.acct}/events/${data.id}`,
},
);
}).catch((error) => {
dispatch(joinEventFail(error, status.id, status?.event?.join_state || null));
});
};

const joinEventRequest = (statusId: string) => ({
type: EVENT_JOIN_REQUEST,
statusId,
});

const joinEventFail = (error: unknown, statusId: string, previousState: Exclude<Status['event'], null>['join_state'] | null) => ({
type: EVENT_JOIN_FAIL,
error,
statusId,
previousState,
});

const leaveEvent = (statusId: string) =>
(dispatch: AppDispatch, getState: () => RootState) => {
const status = getState().statuses[statusId];

if (!status || !status.event || !status.event.join_state) {
return dispatch(noOp);
}

dispatch(leaveEventRequest(status.id));

return getClient(getState).events.leaveEvent(statusId).then((data) => {
dispatch(importEntities({ statuses: [data] }));
}).catch((error) => {
dispatch(leaveEventFail(error, status.id, status?.event?.join_state || null));
});
};

const leaveEventRequest = (statusId: string) => ({
type: EVENT_LEAVE_REQUEST,
statusId,
});

const leaveEventFail = (error: unknown, statusId: string, previousState: Exclude<Status['event'], null>['join_state'] | null) => ({
type: EVENT_LEAVE_FAIL,
statusId,
error,
previousState,
});

const fetchEventIcs = (statusId: string) =>
(dispatch: AppDispatch, getState: () => RootState) =>
getClient(getState).events.getEventIcs(statusId);

const cancelEventCompose = () => ({
type: EVENT_COMPOSE_CANCEL,
});
Expand Down Expand Up @@ -233,10 +156,6 @@ const fetchJoinedEvents = () =>
};

type EventsAction =
| ReturnType<typeof joinEventRequest>
| ReturnType<typeof joinEventFail>
| ReturnType<typeof leaveEventRequest>
| ReturnType<typeof leaveEventFail>
| ReturnType<typeof cancelEventCompose>
| EventFormSetAction
| { type: typeof RECENT_EVENTS_FETCH_REQUEST }
Expand All @@ -247,10 +166,6 @@ type EventsAction =
| { type: typeof JOINED_EVENTS_FETCH_FAIL; error: unknown }

export {
EVENT_JOIN_REQUEST,
EVENT_JOIN_FAIL,
EVENT_LEAVE_REQUEST,
EVENT_LEAVE_FAIL,
EVENT_COMPOSE_CANCEL,
EVENT_FORM_SET,
RECENT_EVENTS_FETCH_REQUEST,
Expand All @@ -260,9 +175,6 @@ export {
JOINED_EVENTS_FETCH_SUCCESS,
JOINED_EVENTS_FETCH_FAIL,
submitEvent,
joinEvent,
leaveEvent,
fetchEventIcs,
cancelEventCompose,
initEventEdit,
fetchRecentEvents,
Expand Down
Loading
Loading