isLoading --> isSubmitting for action hooks
This commit is contained in:
parent
c9a724525e
commit
a4992eec4d
7 changed files with 16 additions and 16 deletions
|
@ -15,7 +15,7 @@ function useDeleteEntity(
|
|||
) {
|
||||
const dispatch = useAppDispatch();
|
||||
const getState = useGetState();
|
||||
const [isLoading, setPromise] = useLoading();
|
||||
const [isSubmitting, setPromise] = useLoading();
|
||||
|
||||
async function deleteEntity(entityId: string, callbacks: EntityCallbacks<string> = {}): Promise<void> {
|
||||
// Get the entity before deleting, so we can reverse the action if the API request fails.
|
||||
|
@ -47,7 +47,7 @@ function useDeleteEntity(
|
|||
|
||||
return {
|
||||
deleteEntity,
|
||||
isLoading,
|
||||
isSubmitting,
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -24,16 +24,16 @@ function useEntityActions<TEntity extends Entity = Entity, Data = any>(
|
|||
const api = useApi();
|
||||
const { entityType, path } = parseEntitiesPath(expandedPath);
|
||||
|
||||
const { deleteEntity, isLoading: deleteLoading } =
|
||||
const { deleteEntity, isSubmitting: deleteSubmitting } =
|
||||
useDeleteEntity(entityType, (entityId) => api.delete(endpoints.delete!.replaceAll(':id', entityId)));
|
||||
|
||||
const { createEntity, isSubmitting: createLoading } =
|
||||
const { createEntity, isSubmitting: createSubmitting } =
|
||||
useCreateEntity<TEntity, Data>(path, (data) => api.post(endpoints.post!, data), opts);
|
||||
|
||||
return {
|
||||
createEntity,
|
||||
deleteEntity,
|
||||
isLoading: createLoading || deleteLoading,
|
||||
isSubmitting: createSubmitting || deleteSubmitting,
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -89,7 +89,7 @@ const GroupActionButton = ({ group }: IGroupActionButton) => {
|
|||
<Button
|
||||
theme='primary'
|
||||
onClick={onJoinGroup}
|
||||
disabled={joinGroup.isLoading}
|
||||
disabled={joinGroup.isSubmitting}
|
||||
>
|
||||
{group.locked
|
||||
? <FormattedMessage id='group.join.private' defaultMessage='Request Access' />
|
||||
|
@ -103,7 +103,7 @@ const GroupActionButton = ({ group }: IGroupActionButton) => {
|
|||
<Button
|
||||
theme='secondary'
|
||||
onClick={onCancelRequest}
|
||||
disabled={cancelRequest.isLoading}
|
||||
disabled={cancelRequest.isSubmitting}
|
||||
>
|
||||
<FormattedMessage id='group.cancel_request' defaultMessage='Cancel Request' />
|
||||
</Button>
|
||||
|
@ -114,7 +114,7 @@ const GroupActionButton = ({ group }: IGroupActionButton) => {
|
|||
<Button
|
||||
theme='secondary'
|
||||
onClick={onLeaveGroup}
|
||||
disabled={leaveGroup.isLoading}
|
||||
disabled={leaveGroup.isSubmitting}
|
||||
>
|
||||
<FormattedMessage id='group.leave' defaultMessage='Leave Group' />
|
||||
</Button>
|
||||
|
|
|
@ -7,14 +7,14 @@ import type { Group, GroupRelationship } from 'soapbox/schemas';
|
|||
function useCancelMembershipRequest(group: Group) {
|
||||
const me = useOwnAccount();
|
||||
|
||||
const { createEntity, isLoading } = useEntityActions<GroupRelationship>(
|
||||
const { createEntity, isSubmitting } = useEntityActions<GroupRelationship>(
|
||||
[Entities.GROUP_RELATIONSHIPS, group.id],
|
||||
{ post: `/api/v1/groups/${group.id}/membership_requests/${me?.id}/reject` },
|
||||
);
|
||||
|
||||
return {
|
||||
mutate: createEntity,
|
||||
isLoading,
|
||||
isSubmitting,
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -4,14 +4,14 @@ import { useEntityActions } from 'soapbox/entity-store/hooks';
|
|||
import type { Group } from 'soapbox/schemas';
|
||||
|
||||
function useDeleteGroup() {
|
||||
const { deleteEntity, isLoading } = useEntityActions<Group>(
|
||||
const { deleteEntity, isSubmitting } = useEntityActions<Group>(
|
||||
[Entities.GROUPS],
|
||||
{ delete: '/api/v1/groups/:id' },
|
||||
);
|
||||
|
||||
return {
|
||||
mutate: deleteEntity,
|
||||
isLoading,
|
||||
isSubmitting,
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ import type { Group, GroupRelationship } from 'soapbox/schemas';
|
|||
function useJoinGroup(group: Group) {
|
||||
const { invalidate } = useGroups();
|
||||
|
||||
const { createEntity, isLoading } = useEntityActions<GroupRelationship>(
|
||||
const { createEntity, isSubmitting } = useEntityActions<GroupRelationship>(
|
||||
[Entities.GROUP_RELATIONSHIPS, group.id],
|
||||
{ post: `/api/v1/groups/${group.id}/join` },
|
||||
{ schema: groupRelationshipSchema },
|
||||
|
@ -17,7 +17,7 @@ function useJoinGroup(group: Group) {
|
|||
|
||||
return {
|
||||
mutate: createEntity,
|
||||
isLoading,
|
||||
isSubmitting,
|
||||
invalidate,
|
||||
};
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@ import type { Group, GroupRelationship } from 'soapbox/schemas';
|
|||
function useLeaveGroup(group: Group) {
|
||||
const { invalidate } = useGroups();
|
||||
|
||||
const { createEntity, isLoading } = useEntityActions<GroupRelationship>(
|
||||
const { createEntity, isSubmitting } = useEntityActions<GroupRelationship>(
|
||||
[Entities.GROUP_RELATIONSHIPS, group.id],
|
||||
{ post: `/api/v1/groups/${group.id}/leave` },
|
||||
{ schema: groupRelationshipSchema },
|
||||
|
@ -17,7 +17,7 @@ function useLeaveGroup(group: Group) {
|
|||
|
||||
return {
|
||||
mutate: createEntity,
|
||||
isLoading,
|
||||
isSubmitting,
|
||||
invalidate,
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue