From 838ea5f9cdac103a6f5cc9f63c35315f8985eeb1 Mon Sep 17 00:00:00 2001 From: Claire Date: Tue, 23 Jul 2024 08:20:17 +0200 Subject: [PATCH] [Glitch] Fix keyboard shortcuts and navigation in grouped notifications Port af06d74574745deb738e6f526f4d74c31760102d to glitch-soc Signed-off-by: Claire --- .../flavours/glitch/actions/accounts.js | 12 +++ .../flavours/glitch/actions/compose.js | 18 ++++ .../flavours/glitch/actions/statuses.js | 14 +++ .../flavours/glitch/components/status.jsx | 14 +-- .../components/notification_group.tsx | 21 +++- .../notification_group_with_status.tsx | 80 +++++++++------ .../components/notification_with_status.tsx | 98 +++++++++++++------ 7 files changed, 191 insertions(+), 66 deletions(-) diff --git a/app/javascript/flavours/glitch/actions/accounts.js b/app/javascript/flavours/glitch/actions/accounts.js index 7c31c16998..699b92dd09 100644 --- a/app/javascript/flavours/glitch/actions/accounts.js +++ b/app/javascript/flavours/glitch/actions/accounts.js @@ -1,3 +1,5 @@ +import { browserHistory } from 'flavours/glitch/components/router'; + import api, { getLinks } from '../api'; import { @@ -722,6 +724,16 @@ export const updateAccount = ({ displayName, note, avatar, header, discoverable, }); }; +export const navigateToProfile = (accountId) => { + return (_dispatch, getState) => { + const acct = getState().accounts.getIn([accountId, 'acct']); + + if (acct) { + browserHistory.push(`/@${acct}`); + } + }; +}; + export function fetchPinnedAccountsSuggestions(q) { return (dispatch) => { dispatch(fetchPinnedAccountsSuggestionsRequest()); diff --git a/app/javascript/flavours/glitch/actions/compose.js b/app/javascript/flavours/glitch/actions/compose.js index 2041278a1c..e850a83a85 100644 --- a/app/javascript/flavours/glitch/actions/compose.js +++ b/app/javascript/flavours/glitch/actions/compose.js @@ -131,6 +131,18 @@ export function replyCompose(status) { }; } +export function replyComposeById(statusId) { + return (dispatch, getState) => { + const state = getState(); + const status = state.statuses.get(statusId); + + if (status) { + const account = state.accounts.get(status.get('account')); + dispatch(replyCompose(status.set('account', account))); + } + }; +} + export function cancelReplyCompose() { return { type: COMPOSE_REPLY_CANCEL, @@ -163,6 +175,12 @@ export function mentionCompose(account) { }; } +export function mentionComposeById(accountId) { + return (dispatch, getState) => { + dispatch(mentionCompose(getState().accounts.get(accountId))); + }; +} + export function directCompose(account) { return (dispatch, getState) => { dispatch({ diff --git a/app/javascript/flavours/glitch/actions/statuses.js b/app/javascript/flavours/glitch/actions/statuses.js index 2ebe0bf96a..2d83ae9926 100644 --- a/app/javascript/flavours/glitch/actions/statuses.js +++ b/app/javascript/flavours/glitch/actions/statuses.js @@ -1,3 +1,5 @@ +import { browserHistory } from 'flavours/glitch/components/router'; + import api from '../api'; import { ensureComposeIsVisible, setComposeToStatus } from './compose'; @@ -364,3 +366,15 @@ export const undoStatusTranslation = (id, pollId) => ({ id, pollId, }); + +export const navigateToStatus = (statusId) => { + return (_dispatch, getState) => { + const state = getState(); + const accountId = state.statuses.getIn([statusId, 'account']); + const acct = state.accounts.getIn([accountId, 'acct']); + + if (acct) { + browserHistory.push(`/@${acct}/${statusId}`); + } + }; +}; diff --git a/app/javascript/flavours/glitch/components/status.jsx b/app/javascript/flavours/glitch/components/status.jsx index e002e4df8c..a037895b4e 100644 --- a/app/javascript/flavours/glitch/components/status.jsx +++ b/app/javascript/flavours/glitch/components/status.jsx @@ -520,7 +520,7 @@ class Status extends ImmutablePureComponent { } render () { - const { intl, hidden, featured, unread, pictureInPicture, previousId, nextInReplyToId, rootId, skipPrepend, avatarSize = 46 } = this.props; + const { intl, hidden, featured, unfocusable, unread, pictureInPicture, previousId, nextInReplyToId, rootId, skipPrepend, avatarSize = 46 } = this.props; const { parseClick, @@ -585,8 +585,8 @@ class Status extends ImmutablePureComponent { if (hidden) { return ( - -
+ +
{status.getIn(['account', 'display_name']) || status.getIn(['account', 'username'])} {status.get('content')}
@@ -606,8 +606,8 @@ class Status extends ImmutablePureComponent { }; return ( - -
+ +
: {matchedFilters.join(', ')}. {' '}