From 39696024caee7d2b7220ae93249ee626e683126f Mon Sep 17 00:00:00 2001 From: Thibaut Girka Date: Wed, 12 Dec 2018 18:02:28 +0100 Subject: Minor cleanup in ScrollableList component --- app/javascript/flavours/glitch/components/scrollable_list.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app/javascript/flavours') diff --git a/app/javascript/flavours/glitch/components/scrollable_list.js b/app/javascript/flavours/glitch/components/scrollable_list.js index a05d49829..06d8ecd42 100644 --- a/app/javascript/flavours/glitch/components/scrollable_list.js +++ b/app/javascript/flavours/glitch/components/scrollable_list.js @@ -204,7 +204,7 @@ export default class ScrollableList extends PureComponent { ); } else { scrollableArea = ( -
+
{alwaysPrepend && prepend}
-- cgit From 73ee38f485b5a61c0d1adbf10315789e4abc67a4 Mon Sep 17 00:00:00 2001 From: Thibaut Girka Date: Wed, 12 Dec 2018 18:04:10 +0100 Subject: [Glitch] Do not display empty message when the list is known to have more elements --- app/javascript/flavours/glitch/components/scrollable_list.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'app/javascript/flavours') diff --git a/app/javascript/flavours/glitch/components/scrollable_list.js b/app/javascript/flavours/glitch/components/scrollable_list.js index 06d8ecd42..bd922462e 100644 --- a/app/javascript/flavours/glitch/components/scrollable_list.js +++ b/app/javascript/flavours/glitch/components/scrollable_list.js @@ -164,7 +164,7 @@ export default class ScrollableList extends PureComponent { const { fullscreen } = this.state; const childrenCount = React.Children.count(children); - const loadMore = (hasMore && childrenCount > 0 && onLoadMore) ? : null; + const loadMore = (hasMore && onLoadMore) ? : null; let scrollableArea = null; if (showLoading) { @@ -179,7 +179,7 @@ export default class ScrollableList extends PureComponent {
); - } else if (isLoading || childrenCount > 0 || !emptyMessage) { + } else if (isLoading || childrenCount > 0 || hasMore || !emptyMessage) { scrollableArea = (
-- cgit From 5f581d7c3c1a93cd8816e9f11cf8f7cef7c3478f Mon Sep 17 00:00:00 2001 From: Thibaut Girka Date: Tue, 11 Dec 2018 18:51:01 +0100 Subject: [Glitch] Fix LoadMore usage in account media gallery MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit (Even though that codepath is probably never actually used…) --- app/javascript/flavours/glitch/features/account_gallery/index.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'app/javascript/flavours') diff --git a/app/javascript/flavours/glitch/features/account_gallery/index.js b/app/javascript/flavours/glitch/features/account_gallery/index.js index 53b906d16..0405af2c3 100644 --- a/app/javascript/flavours/glitch/features/account_gallery/index.js +++ b/app/javascript/flavours/glitch/features/account_gallery/index.js @@ -35,7 +35,7 @@ class LoadMoreMedia extends ImmutablePureComponent { return ( ); } @@ -124,6 +124,7 @@ export default class AccountGallery extends ImmutablePureComponent { 0 ? medias.getIn(index - 1, 'id') : null} + onLoadMore={this.handleLoadMore} /> ) : ( Date: Wed, 12 Dec 2018 18:06:00 +0100 Subject: [Glitch] Make account media gallery more consistent with account timeline MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Display “load more” more consistently, add a loading indicator on first load. --- .../flavours/glitch/features/account_gallery/index.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'app/javascript/flavours') diff --git a/app/javascript/flavours/glitch/features/account_gallery/index.js b/app/javascript/flavours/glitch/features/account_gallery/index.js index 0405af2c3..a77db1c1b 100644 --- a/app/javascript/flavours/glitch/features/account_gallery/index.js +++ b/app/javascript/flavours/glitch/features/account_gallery/index.js @@ -107,8 +107,8 @@ export default class AccountGallery extends ImmutablePureComponent { ); } - if (!isLoading && medias.size > 0 && hasMore) { - loadOlder = ; + if (hasMore) { + loadOlder = ; } return ( @@ -116,10 +116,10 @@ export default class AccountGallery extends ImmutablePureComponent { -
+
-
+
{medias.map((media, index) => media === null ? ( + + {isLoading && medias.size === 0 && ( +
+ +
+ )}
-- cgit From 1e656c36322f4f941b8d432243454c16273d25b6 Mon Sep 17 00:00:00 2001 From: Thibaut Girka Date: Wed, 12 Dec 2018 17:00:31 +0100 Subject: [Glitch] Fix “load more” button when no data has been fetched MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/javascript/flavours/glitch/components/status_list.js | 2 +- app/javascript/flavours/glitch/features/account_gallery/index.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'app/javascript/flavours') diff --git a/app/javascript/flavours/glitch/components/status_list.js b/app/javascript/flavours/glitch/components/status_list.js index 68cd608b9..5249af76d 100644 --- a/app/javascript/flavours/glitch/components/status_list.js +++ b/app/javascript/flavours/glitch/components/status_list.js @@ -55,7 +55,7 @@ export default class StatusList extends ImmutablePureComponent { } handleLoadOlder = debounce(() => { - this.props.onLoadMore(this.props.statusIds.last()); + this.props.onLoadMore(this.props.statusIds.size > 0 ? this.props.statusIds.last() : undefined); }, 300, { leading: true }) _selectChild (index) { diff --git a/app/javascript/flavours/glitch/features/account_gallery/index.js b/app/javascript/flavours/glitch/features/account_gallery/index.js index a77db1c1b..3f61af0e8 100644 --- a/app/javascript/flavours/glitch/features/account_gallery/index.js +++ b/app/javascript/flavours/glitch/features/account_gallery/index.js @@ -67,7 +67,7 @@ export default class AccountGallery extends ImmutablePureComponent { handleScrollToBottom = () => { if (this.props.hasMore) { - this.handleLoadMore(this.props.medias.last().getIn(['status', 'id'])); + this.handleLoadMore(this.props.medias.size > 0 ? this.props.medias.last().getIn(['status', 'id']) : undefined); } } -- cgit From c20c6c202904afee1db514be55b4b943d78df315 Mon Sep 17 00:00:00 2001 From: Thibaut Girka Date: Thu, 13 Dec 2018 21:11:18 +0100 Subject: [Glitch] Fix hasMore in notifications --- app/javascript/flavours/glitch/reducers/notifications.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app/javascript/flavours') diff --git a/app/javascript/flavours/glitch/reducers/notifications.js b/app/javascript/flavours/glitch/reducers/notifications.js index 0b816e85e..b65c51f32 100644 --- a/app/javascript/flavours/glitch/reducers/notifications.js +++ b/app/javascript/flavours/glitch/reducers/notifications.js @@ -96,7 +96,7 @@ const expandNormalizedNotifications = (state, notifications, next) => { } if (!next) { - mutable.set('hasMore', true); + mutable.set('hasMore', false); } mutable.set('isLoading', false); -- cgit From 132dd281623d1d4a4651a60c9879e39070d5ecf3 Mon Sep 17 00:00:00 2001 From: Thibaut Girka Date: Thu, 13 Dec 2018 21:08:22 +0100 Subject: [Glitch] Fix timeline pagination in the WebUI The `hasMore` property of timelines in redux store was set whenever an API request returned only one page of results, *even* if the query only requested newer statuses (using `since_id`), causing `hasMore` to be incorrectly set to false whenever fetching new toots in a timeline, which happens each time an account's timeline or media gallery is visited. --- app/javascript/flavours/glitch/actions/timelines.js | 7 +++++-- app/javascript/flavours/glitch/reducers/timelines.js | 6 +++--- 2 files changed, 8 insertions(+), 5 deletions(-) (limited to 'app/javascript/flavours') diff --git a/app/javascript/flavours/glitch/actions/timelines.js b/app/javascript/flavours/glitch/actions/timelines.js index ffd259d5f..d13d66516 100644 --- a/app/javascript/flavours/glitch/actions/timelines.js +++ b/app/javascript/flavours/glitch/actions/timelines.js @@ -54,11 +54,13 @@ export function expandTimeline(timelineId, path, params = {}, done = noOp) { params.since_id = timeline.getIn(['items', 0]); } + const isLoadingRecent = !!params.since_id; + dispatch(expandTimelineRequest(timelineId, isLoadingMore)); api(getState).get(path, { params }).then(response => { const next = getLinks(response).refs.find(link => link.rel === 'next'); - dispatch(expandTimelineSuccess(timelineId, response.data, next ? next.uri : null, response.code === 206, isLoadingMore)); + dispatch(expandTimelineSuccess(timelineId, response.data, next ? next.uri : null, response.code === 206, isLoadingRecent, isLoadingMore)); done(); }).catch(error => { dispatch(expandTimelineFail(timelineId, error, isLoadingMore)); @@ -85,13 +87,14 @@ export function expandTimelineRequest(timeline, isLoadingMore) { }; }; -export function expandTimelineSuccess(timeline, statuses, next, partial, isLoadingMore) { +export function expandTimelineSuccess(timeline, statuses, next, partial, isLoadingRecent, isLoadingMore) { return { type: TIMELINE_EXPAND_SUCCESS, timeline, statuses, next, partial, + isLoadingRecent, skipLoading: !isLoadingMore, }; }; diff --git a/app/javascript/flavours/glitch/reducers/timelines.js b/app/javascript/flavours/glitch/reducers/timelines.js index 844a0580f..a9eaae26e 100644 --- a/app/javascript/flavours/glitch/reducers/timelines.js +++ b/app/javascript/flavours/glitch/reducers/timelines.js @@ -25,10 +25,10 @@ const initialTimeline = ImmutableMap({ items: ImmutableList(), }); -const expandNormalizedTimeline = (state, timeline, statuses, next, isPartial) => { +const expandNormalizedTimeline = (state, timeline, statuses, next, isPartial, isLoadingRecent) => { return state.update(timeline, initialTimeline, map => map.withMutations(mMap => { mMap.set('isLoading', false); - if (!next) mMap.set('hasMore', false); + if (!next && !isLoadingRecent) mMap.set('hasMore', false); if (!statuses.isEmpty()) { mMap.update('items', ImmutableList(), oldIds => { @@ -116,7 +116,7 @@ export default function timelines(state = initialState, action) { case TIMELINE_EXPAND_FAIL: return state.update(action.timeline, initialTimeline, map => map.set('isLoading', false)); case TIMELINE_EXPAND_SUCCESS: - return expandNormalizedTimeline(state, action.timeline, fromJS(action.statuses), action.next, action.partial); + return expandNormalizedTimeline(state, action.timeline, fromJS(action.statuses), action.next, action.partial, action.isLoadingRecent); case TIMELINE_UPDATE: return updateTimeline(state, action.timeline, fromJS(action.status)); case TIMELINE_DELETE: -- cgit From f0505a5b2e727da73c8aa651b804508a8187a3c4 Mon Sep 17 00:00:00 2001 From: Thibaut Girka Date: Thu, 13 Dec 2018 16:50:37 +0100 Subject: On mobile, go back in browser history upon posting, unless threaded mode is enabled --- app/javascript/flavours/glitch/actions/compose.js | 8 +++++++- .../flavours/glitch/features/composer/index.js | 16 ++++++++++------ 2 files changed, 17 insertions(+), 7 deletions(-) (limited to 'app/javascript/flavours') diff --git a/app/javascript/flavours/glitch/actions/compose.js b/app/javascript/flavours/glitch/actions/compose.js index 58f2b3786..d53d26924 100644 --- a/app/javascript/flavours/glitch/actions/compose.js +++ b/app/javascript/flavours/glitch/actions/compose.js @@ -116,7 +116,7 @@ export function directCompose(account, router) { }; }; -export function submitCompose() { +export function submitCompose(routerHistory) { return function (dispatch, getState) { let status = getState().getIn(['compose', 'text'], ''); let media = getState().getIn(['compose', 'media_attachments']); @@ -158,6 +158,12 @@ export function submitCompose() { } }; + if (routerHistory && routerHistory.location.pathname === '/statuses/new' + && window.history.state + && !getState().getIn(['compose', 'advanced_options', 'threaded_mode'])) { + routerHistory.goBack(); + } + insertIfOnline('home'); if (response.data.in_reply_to_id === null && response.data.visibility === 'public') { diff --git a/app/javascript/flavours/glitch/features/composer/index.js b/app/javascript/flavours/glitch/features/composer/index.js index 029b11a36..40eae1f53 100644 --- a/app/javascript/flavours/glitch/features/composer/index.js +++ b/app/javascript/flavours/glitch/features/composer/index.js @@ -159,15 +159,15 @@ const mapDispatchToProps = (dispatch, { intl }) => ({ onSelectSuggestion(position, token, suggestion) { dispatch(selectComposeSuggestion(position, token, suggestion)); }, - onMediaDescriptionConfirm() { + onMediaDescriptionConfirm(routerHistory) { dispatch(openModal('CONFIRM', { message: intl.formatMessage(messages.missingDescriptionMessage), confirm: intl.formatMessage(messages.missingDescriptionConfirm), - onConfirm: () => dispatch(submitCompose()), + onConfirm: () => dispatch(submitCompose(routerHistory)), })); }, - onSubmit() { - dispatch(submitCompose()); + onSubmit(routerHistory) { + dispatch(submitCompose(routerHistory)); }, onUndoUpload(id) { dispatch(undoUploadCompose(id)); @@ -256,9 +256,9 @@ const handlers = { inputs[firstWithoutDescription].focus(); } } - onMediaDescriptionConfirm(); + onMediaDescriptionConfirm(this.context.router ? this.context.router.history : null); } else if (onSubmit) { - onSubmit(); + onSubmit(this.context.router ? this.context.router.history : null); } }, @@ -563,6 +563,10 @@ Composer.propTypes = { onMediaDescriptionConfirm: PropTypes.func, }; +Composer.contextTypes = { + router: PropTypes.object, +}; + // Connecting and export. export { Composer as WrappedComponent }; export default wrap(Composer, mapStateToProps, mapDispatchToProps, true); -- cgit From 89e4ac67c87e919bf382c8ab57b5a92aa99b206c Mon Sep 17 00:00:00 2001 From: Thibaut Girka Date: Sun, 16 Dec 2018 13:34:01 +0100 Subject: [Glitch] Make animated header resoect `auto_play_gif` Port part of 7c48688d85d0ab64501cea6b8a516867a786bb4c to glitch-soc --- app/javascript/flavours/glitch/features/account/components/header.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'app/javascript/flavours') diff --git a/app/javascript/flavours/glitch/features/account/components/header.js b/app/javascript/flavours/glitch/features/account/components/header.js index f0d36947d..dc5b1447b 100644 --- a/app/javascript/flavours/glitch/features/account/components/header.js +++ b/app/javascript/flavours/glitch/features/account/components/header.js @@ -7,7 +7,7 @@ import ImmutablePureComponent from 'react-immutable-pure-component'; import Avatar from 'flavours/glitch/components/avatar'; import IconButton from 'flavours/glitch/components/icon_button'; -import { me } from 'flavours/glitch/util/initial_state'; +import { autoPlayGif, me } from 'flavours/glitch/util/initial_state'; import classNames from 'classnames'; const messages = defineMessages({ @@ -108,7 +108,7 @@ export default class Header extends ImmutablePureComponent { return (