pl-fe: use more specific zustand selectors

Signed-off-by: nicole mikołajczyk <git@mkljczk.pl>
This commit is contained in:
nicole mikołajczyk
2025-10-22 21:42:11 +02:00
parent 80654146a2
commit ea86246647
93 changed files with 398 additions and 349 deletions

View File

@@ -129,7 +129,7 @@ const redactStatus = (statusId: string) => (dispatch: AppDispatch, getState: ()
return getClient(state).statuses.getStatusSource(statusId).then(response => {
dispatch(setComposeToStatus(status, poll, response.text, response.spoiler_text, response.content_type, false, undefined, undefined, true));
useModalsStore.getState().openModal('COMPOSE');
useModalsStore.getState().actions.openModal('COMPOSE');
}).catch(error => {
dispatch<StatusesAction>({ type: STATUS_FETCH_SOURCE_FAIL, error });
});

View File

@@ -211,7 +211,7 @@ const replyCompose = (
approvalRequired,
conversationScope: features.createStatusConversationScope,
});
useModalsStore.getState().openModal('COMPOSE');
useModalsStore.getState().actions.openModal('COMPOSE');
};
const cancelReplyCompose = () => ({
@@ -243,7 +243,7 @@ const quoteCompose = (status: ComposeQuoteAction['status']) =>
explicitAddressing,
conversationScope: createStatusConversationScope,
});
useModalsStore.getState().openModal('COMPOSE');
useModalsStore.getState().actions.openModal('COMPOSE');
};
const cancelQuoteCompose = (composeId: string) => ({
@@ -256,7 +256,7 @@ const groupComposeModal = (group: Pick<Group, 'id'>) =>
const composeId = `group:${group.id}`;
dispatch(groupCompose(composeId, group.id));
useModalsStore.getState().openModal('COMPOSE', { composeId });
useModalsStore.getState().actions.openModal('COMPOSE', { composeId });
};
const resetCompose = (composeId = 'compose-modal') => ({
@@ -279,7 +279,7 @@ const mentionCompose = (account: ComposeMentionAction['account']) =>
composeId: 'compose-modal',
account: account,
});
useModalsStore.getState().openModal('COMPOSE');
useModalsStore.getState().actions.openModal('COMPOSE');
};
interface ComposeDirectAction {
@@ -295,7 +295,7 @@ const directCompose = (account: ComposeDirectAction['account']) =>
composeId: 'compose-modal',
account,
});
useModalsStore.getState().openModal('COMPOSE');
useModalsStore.getState().actions.openModal('COMPOSE');
};
const handleComposeSubmit = (dispatch: AppDispatch, getState: () => RootState, composeId: string, data: BaseStatus | ScheduledStatus, status: string, edit?: boolean, redact?: boolean) => {
@@ -377,9 +377,9 @@ const submitCompose = (composeId: string, opts: SubmitComposeOpts = {}, preview
}
if (!force && needsDescriptions(state, composeId)) {
useModalsStore.getState().openModal('MISSING_DESCRIPTION', {
useModalsStore.getState().actions.openModal('MISSING_DESCRIPTION', {
onContinue: () => {
useModalsStore.getState().closeModal('MISSING_DESCRIPTION');
useModalsStore.getState().actions.closeModal('MISSING_DESCRIPTION');
dispatch(submitCompose(composeId, { history, force: true, onSuccess }));
},
});
@@ -397,7 +397,7 @@ const submitCompose = (composeId: string, opts: SubmitComposeOpts = {}, preview
if (!preview) {
dispatch(submitComposeRequest(composeId));
useModalsStore.getState().closeModal('COMPOSE');
useModalsStore.getState().actions.closeModal('COMPOSE');
if (compose.language && !statusId && !preview) {
useSettingsStore.getState().rememberLanguageUse(compose.language);
@@ -877,7 +877,7 @@ const changePollSettings = (composeId: string, expiresIn?: number, isMultiple?:
const openComposeWithText = (composeId: string, text = '') =>
(dispatch: AppDispatch) => {
dispatch(resetCompose(composeId));
useModalsStore.getState().openModal('COMPOSE');
useModalsStore.getState().actions.openModal('COMPOSE');
dispatch(changeCompose(composeId, text));
};

View File

@@ -54,7 +54,7 @@ const deactivateUserModal = (intl: IntlShape, accountId: string, afterConfirm =
</Stack>
);
useModalsStore.getState().openModal('CONFIRM', {
useModalsStore.getState().actions.openModal('CONFIRM', {
heading: intl.formatMessage(messages.deactivateUserHeading, { acct }),
message,
confirm: intl.formatMessage(messages.deactivateUserConfirm, { name }),
@@ -91,7 +91,7 @@ const deleteUserModal = (intl: IntlShape, accountId: string, afterConfirm = () =
const confirm = intl.formatMessage(messages.deleteUserConfirm, { name });
const checkbox = local ? intl.formatMessage(messages.deleteLocalUserCheckbox) : false;
useModalsStore.getState().openModal('CONFIRM', {
useModalsStore.getState().actions.openModal('CONFIRM', {
heading: intl.formatMessage(messages.deleteUserHeading, { acct }),
message,
confirm,
@@ -112,7 +112,7 @@ const toggleStatusSensitivityModal = (intl: IntlShape, statusId: string, sensiti
const state = getState();
const acct = state.statuses[statusId]!.account.acct;
useModalsStore.getState().openModal('CONFIRM', {
useModalsStore.getState().actions.openModal('CONFIRM', {
heading: intl.formatMessage(sensitive === false ? messages.markStatusSensitiveHeading : messages.markStatusNotSensitiveHeading),
message: intl.formatMessage(sensitive === false ? messages.markStatusSensitivePrompt : messages.markStatusNotSensitivePrompt, { acct }),
confirm: intl.formatMessage(sensitive === false ? messages.markStatusSensitiveConfirm : messages.markStatusNotSensitiveConfirm),
@@ -131,7 +131,7 @@ const deleteStatusModal = (intl: IntlShape, statusId: string, afterConfirm = ()
const state = getState();
const acct = state.statuses[statusId]!.account.acct;
useModalsStore.getState().openModal('CONFIRM', {
useModalsStore.getState().actions.openModal('CONFIRM', {
heading: intl.formatMessage(messages.deleteStatusHeading),
message: intl.formatMessage(messages.deleteStatusPrompt, { acct: <strong className='break-words'>{acct}</strong> }),
confirm: intl.formatMessage(messages.deleteStatusConfirm),

View File

@@ -18,7 +18,7 @@ type ReportedEntity = {
const initReport = (entityType: ReportableEntities, account: Pick<Account, 'id'>, entities?: ReportedEntity) => (dispatch: AppDispatch) => {
const { status } = entities || {};
return useModalsStore.getState().openModal('REPORT', {
return useModalsStore.getState().actions.openModal('REPORT', {
accountId: account.id,
entityType,
statusIds: status ? [status.id] : [],

View File

@@ -98,7 +98,7 @@ const editStatus = (statusId: string) => (dispatch: AppDispatch, getState: () =>
return getClient(state).statuses.getStatusSource(statusId).then(response => {
dispatch<StatusesAction>({ type: STATUS_FETCH_SOURCE_SUCCESS });
dispatch(setComposeToStatus(status, poll, response.text, response.spoiler_text, response.content_type, false));
useModalsStore.getState().openModal('COMPOSE');
useModalsStore.getState().actions.openModal('COMPOSE');
}).catch(error => {
dispatch<StatusesAction>({ type: STATUS_FETCH_SOURCE_FAIL, error });
});
@@ -137,7 +137,7 @@ const deleteStatus = (statusId: string, groupId?: string, withRedraft = false) =
if (withRedraft) {
dispatch(setComposeToStatus(status, poll, response.text || '', response.spoiler_text, (response as StatusSource).content_type, withRedraft));
useModalsStore.getState().openModal('COMPOSE');
useModalsStore.getState().actions.openModal('COMPOSE');
}
})
.catch(error => {