From 4c1b3dd88b30dbd916fd13fded949b9bf3739694 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Fri, 12 Nov 2021 11:48:43 -0600 Subject: [PATCH 1/5] ThumbNavigation: balance the width of the icons so the labels overflow --- app/styles/navigation.scss | 1 + 1 file changed, 1 insertion(+) diff --git a/app/styles/navigation.scss b/app/styles/navigation.scss index f590cbd5c..e53d1383b 100644 --- a/app/styles/navigation.scss +++ b/app/styles/navigation.scss @@ -87,6 +87,7 @@ color: var(--primary-text-color); text-decoration: none; font-size: 20px; + width: 55px; span { margin-top: 1px; From a354fd325db5569a96cf8134f77adacde5cf5e83 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Fri, 12 Nov 2021 12:18:11 -0600 Subject: [PATCH 2/5] Statuses: optimistic reply counter --- .../reducers/__tests__/statuses-test.js | 35 ++++++++++++++++++- app/soapbox/reducers/statuses.js | 22 ++++++++++++ 2 files changed, 56 insertions(+), 1 deletion(-) diff --git a/app/soapbox/reducers/__tests__/statuses-test.js b/app/soapbox/reducers/__tests__/statuses-test.js index 00687224a..7bcc67c9e 100644 --- a/app/soapbox/reducers/__tests__/statuses-test.js +++ b/app/soapbox/reducers/__tests__/statuses-test.js @@ -1,8 +1,41 @@ import reducer from '../statuses'; -import { Map as ImmutableMap } from 'immutable'; +import { Map as ImmutableMap, fromJS } from 'immutable'; +import { + STATUS_CREATE_REQUEST, + STATUS_CREATE_FAIL, +} from 'soapbox/actions/statuses'; + describe('statuses reducer', () => { it('should return the initial state', () => { expect(reducer(undefined, {})).toEqual(ImmutableMap()); }); + + describe('STATUS_CREATE_REQUEST', () => { + it('increments the replies_count of its parent', () => { + const state = fromJS({ '123': { replies_count: 4 } }); + + const action = { + type: STATUS_CREATE_REQUEST, + params: { in_reply_to_id: '123' }, + }; + + const result = reducer(state, action).getIn(['123', 'replies_count']); + expect(result).toEqual(5); + }); + }); + + describe('STATUS_CREATE_FAIL', () => { + it('decrements the replies_count of its parent', () => { + const state = fromJS({ '123': { replies_count: 5 } }); + + const action = { + type: STATUS_CREATE_FAIL, + params: { in_reply_to_id: '123' }, + }; + + const result = reducer(state, action).getIn(['123', 'replies_count']); + expect(result).toEqual(4); + }); + }); }); diff --git a/app/soapbox/reducers/statuses.js b/app/soapbox/reducers/statuses.js index f8c01ed2b..118d2d7aa 100644 --- a/app/soapbox/reducers/statuses.js +++ b/app/soapbox/reducers/statuses.js @@ -6,6 +6,8 @@ import { FAVOURITE_FAIL, } from '../actions/interactions'; import { + STATUS_CREATE_REQUEST, + STATUS_CREATE_FAIL, STATUS_MUTE_SUCCESS, STATUS_UNMUTE_SUCCESS, STATUS_REVEAL, @@ -33,6 +35,22 @@ const deleteStatus = (state, id, references) => { return state.delete(id); }; +const importPendingStatus = (state, { in_reply_to_id }) => { + if (in_reply_to_id) { + return state.updateIn([in_reply_to_id, 'replies_count'], 0, count => count + 1); + } else { + return state; + } +}; + +const deletePendingStatus = (state, { in_reply_to_id }) => { + if (in_reply_to_id) { + return state.updateIn([in_reply_to_id, 'replies_count'], 0, count => Math.max(0, count - 1)); + } else { + return state; + } +}; + const initialState = ImmutableMap(); export default function statuses(state = initialState, action) { @@ -41,6 +59,10 @@ export default function statuses(state = initialState, action) { return importStatus(state, action.status); case STATUSES_IMPORT: return importStatuses(state, action.statuses); + case STATUS_CREATE_REQUEST: + return importPendingStatus(state, action.params); + case STATUS_CREATE_FAIL: + return deletePendingStatus(state, action.params); case FAVOURITE_REQUEST: return state.update(action.status.get('id'), status => status From 47a3ecc30e61f0f8522b5f3fe306d30ff963d330 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Fri, 12 Nov 2021 12:28:58 -0600 Subject: [PATCH 3/5] ComposeModal: conditional title when replying --- .../features/ui/components/compose_modal.js | 22 ++++++++++++++----- 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/app/soapbox/features/ui/components/compose_modal.js b/app/soapbox/features/ui/components/compose_modal.js index 9b24f9429..658398626 100644 --- a/app/soapbox/features/ui/components/compose_modal.js +++ b/app/soapbox/features/ui/components/compose_modal.js @@ -20,6 +20,7 @@ const mapStateToProps = state => { account: state.getIn(['accounts', me]), composeText: state.getIn(['compose', 'text']), privacy: state.getIn(['compose', 'privacy']), + inReplyTo: state.getIn(['compose', 'in_reply_to']), }; }; @@ -31,6 +32,7 @@ class ComposeModal extends ImmutablePureComponent { onClose: PropTypes.func.isRequired, composeText: PropTypes.string, privacy: PropTypes.string, + inReplyTo: PropTypes.string, dispatch: PropTypes.func.isRequired, }; @@ -49,18 +51,26 @@ class ComposeModal extends ImmutablePureComponent { } }; + renderTitle = () => { + const { privacy, inReplyTo } = this.props; + + if (privacy === 'direct') { + return ; + } else if (inReplyTo) { + return ; + } else { + return ; + } + } + render() { - const { intl, privacy } = this.props; + const { intl } = this.props; return (

- {privacy === 'direct' ? ( - - ) : ( - - )} + {this.renderTitle()}

Date: Fri, 12 Nov 2021 12:47:36 -0600 Subject: [PATCH 4/5] SubNavigation: increase Back button size, constrain message width --- app/styles/navigation.scss | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/app/styles/navigation.scss b/app/styles/navigation.scss index e53d1383b..035cc55f8 100644 --- a/app/styles/navigation.scss +++ b/app/styles/navigation.scss @@ -156,19 +156,24 @@ justify-content: center; color: var(--primary-text-color); opacity: 0.6; + font-size: 16px; .svg-icon { margin-right: 7px; - width: 22px; - height: 22px; + width: 26px; + height: 26px; } } &__message { position: absolute; + padding: 0 10px; align-self: center; justify-self: center; font-weight: bold; + overflow-x: hidden; + text-overflow: ellipsis; + max-width: calc(100vw - 200px); } &__cog { From 1e603b82552f82b56a8488acbea7f5a43b420cc1 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Fri, 12 Nov 2021 13:39:06 -0600 Subject: [PATCH 5/5] Interactions: don't reimport updated status with unfavourite and unreblog. Mastodon doesn't decrement the counter in the API response, and we actually don't want updated counters anyway. --- app/soapbox/actions/interactions.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/app/soapbox/actions/interactions.js b/app/soapbox/actions/interactions.js index 1e2d729f1..c292abaac 100644 --- a/app/soapbox/actions/interactions.js +++ b/app/soapbox/actions/interactions.js @@ -77,7 +77,6 @@ export function unreblog(status) { dispatch(unreblogRequest(status)); api(getState).post(`/api/v1/statuses/${status.get('id')}/unreblog`).then(response => { - dispatch(importFetchedStatus(response.data)); dispatch(unreblogSuccess(status)); }).catch(error => { dispatch(unreblogFail(status, error)); @@ -157,7 +156,6 @@ export function unfavourite(status) { dispatch(unfavouriteRequest(status)); api(getState).post(`/api/v1/statuses/${status.get('id')}/unfavourite`).then(response => { - dispatch(importFetchedStatus(response.data)); dispatch(unfavouriteSuccess(status)); }).catch(error => { dispatch(unfavouriteFail(status, error));