2023-11-03 10:00:03 -05:00
|
|
|
import { createAction } from '@reduxjs/toolkit';
|
|
|
|
|
|
|
|
import type { ApiAccountJSON } from 'flavours/glitch/api_types/accounts';
|
|
|
|
import type { ApiRelationshipJSON } from 'flavours/glitch/api_types/relationships';
|
|
|
|
|
|
|
|
export const revealAccount = createAction<{
|
|
|
|
id: string;
|
|
|
|
}>('accounts/revealAccount');
|
|
|
|
|
|
|
|
export const importAccounts = createAction<{ accounts: ApiAccountJSON[] }>(
|
|
|
|
'accounts/importAccounts',
|
|
|
|
);
|
|
|
|
|
|
|
|
function actionWithSkipLoadingTrue<Args extends object>(args: Args) {
|
|
|
|
return {
|
|
|
|
payload: {
|
|
|
|
...args,
|
|
|
|
skipLoading: true,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
export const followAccountSuccess = createAction(
|
2023-12-18 17:19:27 -06:00
|
|
|
'accounts/followAccount/SUCCESS',
|
2023-11-03 10:00:03 -05:00
|
|
|
actionWithSkipLoadingTrue<{
|
|
|
|
relationship: ApiRelationshipJSON;
|
|
|
|
alreadyFollowing: boolean;
|
|
|
|
}>,
|
|
|
|
);
|
|
|
|
|
|
|
|
export const unfollowAccountSuccess = createAction(
|
2023-12-18 17:19:27 -06:00
|
|
|
'accounts/unfollowAccount/SUCCESS',
|
2023-11-03 10:00:03 -05:00
|
|
|
actionWithSkipLoadingTrue<{
|
|
|
|
relationship: ApiRelationshipJSON;
|
|
|
|
statuses: unknown;
|
|
|
|
alreadyFollowing?: boolean;
|
|
|
|
}>,
|
|
|
|
);
|
|
|
|
|
|
|
|
export const authorizeFollowRequestSuccess = createAction<{ id: string }>(
|
2023-12-18 17:19:27 -06:00
|
|
|
'accounts/followRequestAuthorize/SUCCESS',
|
2023-11-03 10:00:03 -05:00
|
|
|
);
|
|
|
|
|
|
|
|
export const rejectFollowRequestSuccess = createAction<{ id: string }>(
|
2023-12-18 17:19:27 -06:00
|
|
|
'accounts/followRequestReject/SUCCESS',
|
2023-11-03 10:00:03 -05:00
|
|
|
);
|
|
|
|
|
|
|
|
export const followAccountRequest = createAction(
|
2023-12-18 17:19:27 -06:00
|
|
|
'accounts/follow/REQUEST',
|
2023-11-03 10:00:03 -05:00
|
|
|
actionWithSkipLoadingTrue<{ id: string; locked: boolean }>,
|
|
|
|
);
|
|
|
|
|
|
|
|
export const followAccountFail = createAction(
|
2023-12-18 17:19:27 -06:00
|
|
|
'accounts/follow/FAIL',
|
2023-11-03 10:00:03 -05:00
|
|
|
actionWithSkipLoadingTrue<{ id: string; error: string; locked: boolean }>,
|
|
|
|
);
|
|
|
|
|
|
|
|
export const unfollowAccountRequest = createAction(
|
2023-12-18 17:19:27 -06:00
|
|
|
'accounts/unfollow/REQUEST',
|
2023-11-03 10:00:03 -05:00
|
|
|
actionWithSkipLoadingTrue<{ id: string }>,
|
|
|
|
);
|
|
|
|
|
|
|
|
export const unfollowAccountFail = createAction(
|
2023-12-18 17:19:27 -06:00
|
|
|
'accounts/unfollow/FAIL',
|
2023-11-03 10:00:03 -05:00
|
|
|
actionWithSkipLoadingTrue<{ id: string; error: string }>,
|
|
|
|
);
|
|
|
|
|
|
|
|
export const blockAccountSuccess = createAction<{
|
|
|
|
relationship: ApiRelationshipJSON;
|
|
|
|
statuses: unknown;
|
2023-12-18 17:19:27 -06:00
|
|
|
}>('accounts/block/SUCCESS');
|
2023-11-03 10:00:03 -05:00
|
|
|
|
|
|
|
export const unblockAccountSuccess = createAction<{
|
|
|
|
relationship: ApiRelationshipJSON;
|
2023-12-18 17:19:27 -06:00
|
|
|
}>('accounts/unblock/SUCCESS');
|
2023-11-03 10:00:03 -05:00
|
|
|
|
|
|
|
export const muteAccountSuccess = createAction<{
|
|
|
|
relationship: ApiRelationshipJSON;
|
|
|
|
statuses: unknown;
|
2023-12-18 17:19:27 -06:00
|
|
|
}>('accounts/mute/SUCCESS');
|
2023-11-03 10:00:03 -05:00
|
|
|
|
|
|
|
export const unmuteAccountSuccess = createAction<{
|
|
|
|
relationship: ApiRelationshipJSON;
|
2023-12-18 17:19:27 -06:00
|
|
|
}>('accounts/unmute/SUCCESS');
|
2023-11-03 10:00:03 -05:00
|
|
|
|
|
|
|
export const pinAccountSuccess = createAction<{
|
|
|
|
relationship: ApiRelationshipJSON;
|
2023-12-18 17:19:27 -06:00
|
|
|
}>('accounts/pin/SUCCESS');
|
2023-11-03 10:00:03 -05:00
|
|
|
|
|
|
|
export const unpinAccountSuccess = createAction<{
|
|
|
|
relationship: ApiRelationshipJSON;
|
2023-12-18 17:19:27 -06:00
|
|
|
}>('accounts/unpin/SUCCESS');
|
2023-11-03 10:00:03 -05:00
|
|
|
|
|
|
|
export const fetchRelationshipsSuccess = createAction(
|
2023-12-18 17:19:27 -06:00
|
|
|
'relationships/fetch/SUCCESS',
|
2023-11-03 10:00:03 -05:00
|
|
|
actionWithSkipLoadingTrue<{ relationships: ApiRelationshipJSON[] }>,
|
|
|
|
);
|