From 4c9201e8b43ba57655c49689d307fac20e57de35 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?marcin=20miko=C5=82ajczak?= Date: Wed, 26 Jul 2023 00:53:22 +0200 Subject: [PATCH] Improve compose page styles, propagate compose toast to other tabs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: marcin mikołajczak --- app/soapbox/actions/compose.ts | 13 ++++++++----- app/soapbox/components/autosuggest-textarea.tsx | 6 ++++-- app/soapbox/containers/soapbox.tsx | 6 +----- .../features/compose/components/compose-form.tsx | 8 +++++--- app/soapbox/features/compose/index.tsx | 8 ++++---- app/soapbox/toast.tsx | 14 +++++++++++++- 6 files changed, 35 insertions(+), 20 deletions(-) diff --git a/app/soapbox/actions/compose.ts b/app/soapbox/actions/compose.ts index eff4e2a2b..213fa3d25 100644 --- a/app/soapbox/actions/compose.ts +++ b/app/soapbox/actions/compose.ts @@ -274,15 +274,18 @@ const directComposeById = (accountId: string) => dispatch(openModal('COMPOSE')); }; -const handleComposeSubmit = (dispatch: AppDispatch, getState: () => RootState, composeId: string, data: APIEntity, status: string, edit?: boolean) => { +const handleComposeSubmit = (dispatch: AppDispatch, getState: () => RootState, composeId: string, data: APIEntity, status: string, edit?: boolean, propagate?: boolean) => { if (!dispatch || !getState) return; dispatch(insertIntoTagHistory(composeId, data.tags || [], status)); dispatch(submitComposeSuccess(composeId, { ...data })); - toast.success(edit ? messages.editSuccess : messages.success, { + const toastMessage = edit ? messages.editSuccess : messages.success; + const toastOpts = { actionLabel: messages.view, actionLink: `/@${data.account.acct}/posts/${data.id}`, - }); + }; + if (propagate) toast.propagate('success', toastMessage, toastOpts); + else toast.success(toastMessage, toastOpts); }; const needsDescriptions = (state: RootState, composeId: string) => { @@ -303,7 +306,7 @@ const validateSchedule = (state: RootState, composeId: string) => { return schedule.getTime() > fiveMinutesFromNow.getTime(); }; -const submitCompose = (composeId: string, routerHistory?: History, force = false, onSubmit?: () => void) => +const submitCompose = (composeId: string, routerHistory?: History, force = false, onSubmit?: () => void, propagate?: boolean) => (dispatch: AppDispatch, getState: () => RootState) => { if (!isLoggedIn(getState)) return; const state = getState(); @@ -368,7 +371,7 @@ const submitCompose = (composeId: string, routerHistory?: History, force = false if (!statusId && data.visibility === 'direct' && getState().conversations.mounted <= 0 && routerHistory) { routerHistory.push('/messages'); } - handleComposeSubmit(dispatch, getState, composeId, data, status, !!statusId); + handleComposeSubmit(dispatch, getState, composeId, data, status, !!statusId, propagate); if (onSubmit) onSubmit(); }).catch(function(error) { dispatch(submitComposeFail(composeId, error)); diff --git a/app/soapbox/components/autosuggest-textarea.tsx b/app/soapbox/components/autosuggest-textarea.tsx index e0be3c958..e190e4c41 100644 --- a/app/soapbox/components/autosuggest-textarea.tsx +++ b/app/soapbox/components/autosuggest-textarea.tsx @@ -30,6 +30,7 @@ interface IAutosuggesteTextarea { onFocus: () => void onBlur?: () => void condensed?: boolean + fullScreen?: boolean children: React.ReactNode } @@ -227,7 +228,7 @@ class AutosuggestTextarea extends ImmutablePureComponent } render() { - const { value, suggestions, disabled, placeholder, onKeyUp, autoFocus, children, condensed, id } = this.props; + const { value, suggestions, disabled, placeholder, onKeyUp, autoFocus, children, condensed, id, fullScreen } = this.props; const { suggestionsHidden } = this.state; const style = { direction: 'ltr', minRows: 10 }; @@ -237,7 +238,7 @@ class AutosuggestTextarea extends ImmutablePureComponent } return [ -
+