From bae0b81779ccf798a7876f460c9841fb40540126 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Wed, 21 Aug 2024 09:08:58 +0200 Subject: [PATCH] [Glitch] Change hints for missing remote content in web UI Port b06c7b6b5ae28cb81e5ba8ba632ebc629d1fed57 to glitch-soc Signed-off-by: Claire --- .../glitch/components/timeline_hint.tsx | 27 ++++++++----------- .../features/account_timeline/index.jsx | 21 +++++++++++---- .../glitch/features/followers/index.jsx | 21 +++++++++++---- .../glitch/features/following/index.jsx | 21 +++++++++++---- .../flavours/glitch/features/status/index.jsx | 9 ++++++- .../flavours/glitch/styles/components.scss | 13 ++++----- 6 files changed, 74 insertions(+), 38 deletions(-) diff --git a/app/javascript/flavours/glitch/components/timeline_hint.tsx b/app/javascript/flavours/glitch/components/timeline_hint.tsx index 6faad2fbb8..9e0d3676ec 100644 --- a/app/javascript/flavours/glitch/components/timeline_hint.tsx +++ b/app/javascript/flavours/glitch/components/timeline_hint.tsx @@ -1,28 +1,23 @@ -import { FormattedMessage } from 'react-intl'; - import classNames from 'classnames'; interface Props { - resource: JSX.Element; + message: React.ReactNode; + label: React.ReactNode; url: string; className?: string; } -export const TimelineHint: React.FC = ({ className, resource, url }) => ( +export const TimelineHint: React.FC = ({ + className, + message, + label, + url, +}) => (
- - - -
+

{message}

+ - + {label}
); diff --git a/app/javascript/flavours/glitch/features/account_timeline/index.jsx b/app/javascript/flavours/glitch/features/account_timeline/index.jsx index cf99a1f569..813e0c7a31 100644 --- a/app/javascript/flavours/glitch/features/account_timeline/index.jsx +++ b/app/javascript/flavours/glitch/features/account_timeline/index.jsx @@ -12,6 +12,7 @@ import ProfileColumnHeader from 'flavours/glitch/features/account/components/pro import BundleColumnError from 'flavours/glitch/features/ui/components/bundle_column_error'; import { normalizeForLookup } from 'flavours/glitch/reducers/accounts_map'; import { getAccountHidden } from 'flavours/glitch/selectors'; +import { useAppSelector } from 'flavours/glitch/store'; import { lookupAccount, fetchAccount } from '../../actions/accounts'; import { fetchFeaturedTags } from '../../actions/featured_tags'; @@ -57,12 +58,22 @@ const mapStateToProps = (state, { params: { acct, id, tagged }, withReplies = fa }; }; -const RemoteHint = ({ url }) => ( - } /> -); +const RemoteHint = ({ accountId, url }) => { + const acct = useAppSelector(state => state.accounts.get(accountId)?.acct); + const domain = acct ? acct.split('@')[1] : undefined; + + return ( + } + label={{domain} }} />} + /> + ); +}; RemoteHint.propTypes = { url: PropTypes.string.isRequired, + accountId: PropTypes.string.isRequired, }; class AccountTimeline extends ImmutablePureComponent { @@ -176,12 +187,12 @@ class AccountTimeline extends ImmutablePureComponent { } else if (hidden) { emptyMessage = ; } else if (remote && statusIds.isEmpty()) { - emptyMessage = ; + emptyMessage = ; } else { emptyMessage = ; } - const remoteMessage = remote ? : null; + const remoteMessage = remote ? : null; return ( diff --git a/app/javascript/flavours/glitch/features/followers/index.jsx b/app/javascript/flavours/glitch/features/followers/index.jsx index 2ea3574a90..7b662963d2 100644 --- a/app/javascript/flavours/glitch/features/followers/index.jsx +++ b/app/javascript/flavours/glitch/features/followers/index.jsx @@ -12,6 +12,7 @@ import { TimelineHint } from 'flavours/glitch/components/timeline_hint'; import BundleColumnError from 'flavours/glitch/features/ui/components/bundle_column_error'; import { normalizeForLookup } from 'flavours/glitch/reducers/accounts_map'; import { getAccountHidden } from 'flavours/glitch/selectors'; +import { useAppSelector } from 'flavours/glitch/store'; import { lookupAccount, @@ -50,12 +51,22 @@ const mapStateToProps = (state, { params: { acct, id } }) => { }; }; -const RemoteHint = ({ url }) => ( - } /> -); +const RemoteHint = ({ accountId, url }) => { + const acct = useAppSelector(state => state.accounts.get(accountId)?.acct); + const domain = acct ? acct.split('@')[1] : undefined; + + return ( + } + label={{domain} }} />} + /> + ); +}; RemoteHint.propTypes = { url: PropTypes.string.isRequired, + accountId: PropTypes.string.isRequired, }; class Followers extends ImmutablePureComponent { @@ -145,12 +156,12 @@ class Followers extends ImmutablePureComponent { } else if (hideCollections && accountIds.isEmpty()) { emptyMessage = ; } else if (remote && accountIds.isEmpty()) { - emptyMessage = ; + emptyMessage = ; } else { emptyMessage = ; } - const remoteMessage = remote ? : null; + const remoteMessage = remote ? : null; return ( diff --git a/app/javascript/flavours/glitch/features/following/index.jsx b/app/javascript/flavours/glitch/features/following/index.jsx index 0d18e76ec4..c3f00cc894 100644 --- a/app/javascript/flavours/glitch/features/following/index.jsx +++ b/app/javascript/flavours/glitch/features/following/index.jsx @@ -12,6 +12,7 @@ import { TimelineHint } from 'flavours/glitch/components/timeline_hint'; import BundleColumnError from 'flavours/glitch/features/ui/components/bundle_column_error'; import { normalizeForLookup } from 'flavours/glitch/reducers/accounts_map'; import { getAccountHidden } from 'flavours/glitch/selectors'; +import { useAppSelector } from 'flavours/glitch/store'; import { lookupAccount, @@ -50,12 +51,22 @@ const mapStateToProps = (state, { params: { acct, id } }) => { }; }; -const RemoteHint = ({ url }) => ( - } /> -); +const RemoteHint = ({ accountId, url }) => { + const acct = useAppSelector(state => state.accounts.get(accountId)?.acct); + const domain = acct ? acct.split('@')[1] : undefined; + + return ( + } + label={{domain} }} />} + /> + ); +}; RemoteHint.propTypes = { url: PropTypes.string.isRequired, + accountId: PropTypes.string.isRequired, }; class Following extends ImmutablePureComponent { @@ -145,12 +156,12 @@ class Following extends ImmutablePureComponent { } else if (hideCollections && accountIds.isEmpty()) { emptyMessage = ; } else if (remote && accountIds.isEmpty()) { - emptyMessage = ; + emptyMessage = ; } else { emptyMessage = ; } - const remoteMessage = remote ? : null; + const remoteMessage = remote ? : null; return ( diff --git a/app/javascript/flavours/glitch/features/status/index.jsx b/app/javascript/flavours/glitch/features/status/index.jsx index 382f0ae037..279d90b998 100644 --- a/app/javascript/flavours/glitch/features/status/index.jsx +++ b/app/javascript/flavours/glitch/features/status/index.jsx @@ -655,7 +655,14 @@ class Status extends ImmutablePureComponent { const isIndexable = !status.getIn(['account', 'noindex']); if (!isLocal) { - remoteHint = } />; + remoteHint = ( + } + label={{status.getIn(['account', 'acct']).split('@')[1]} }} />} + /> + ); } const handlers = { diff --git a/app/javascript/flavours/glitch/styles/components.scss b/app/javascript/flavours/glitch/styles/components.scss index e1c6f658f3..06ac1ae4cd 100644 --- a/app/javascript/flavours/glitch/styles/components.scss +++ b/app/javascript/flavours/glitch/styles/components.scss @@ -4422,11 +4422,12 @@ a.status-card { .timeline-hint { text-align: center; - color: $darker-text-color; - padding: 15px; + color: $dark-text-color; + padding: 16px; box-sizing: border-box; width: 100%; - cursor: default; + font-size: 14px; + line-height: 21px; strong { font-weight: 500; @@ -4443,10 +4444,10 @@ a.status-card { color: lighten($highlight-text-color, 4%); } } -} -.timeline-hint--with-descendants { - border-top: 1px solid var(--background-border-color); + &--with-descendants { + border-top: 1px solid var(--background-border-color); + } } .regeneration-indicator {