From 1b3112de1b7f728c43b2a695f240e310158bce1d Mon Sep 17 00:00:00 2001 From: Lim Chee Aun Date: Fri, 25 Aug 2023 15:41:03 +0800 Subject: [PATCH 01/12] Don't apply max-height to statuses in carousel --- src/components/status.css | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/components/status.css b/src/components/status.css index f96762b7..ae002867 100644 --- a/src/components/status.css +++ b/src/components/status.css @@ -121,11 +121,14 @@ .status-card > * { pointer-events: none; } -.status-card :is(.content, .poll, .media-container) { +.status-card:not(.status-carousel .status) + :is(.content, .poll, .media-container) { max-height: 160px !important; overflow: hidden; } -.status.small .status-card :is(.content, .poll, .media-container) { +.status.small:not(.status-carousel .status) + .status-card + :is(.content, .poll, .media-container) { max-height: 80px !important; } .status-card :is(.content, .poll) { From 1fae2f3208a11e7b950ef1dfd4fbf28218be03ff Mon Sep 17 00:00:00 2001 From: Lim Chee Aun Date: Sun, 27 Aug 2023 13:06:26 +0800 Subject: [PATCH 02/12] 2nd pass grouping of 1-account-many-statuses fav/boost --- src/components/notification.jsx | 35 +++++++++++++++++++++++++++---- src/pages/notifications.css | 35 +++++++++++++++++++++++++++++++ src/utils/group-notifications.jsx | 35 ++++++++++++++++++++++++++++++- 3 files changed, 100 insertions(+), 5 deletions(-) diff --git a/src/components/notification.jsx b/src/components/notification.jsx index 20a101ab..ec5e69a3 100644 --- a/src/components/notification.jsx +++ b/src/components/notification.jsx @@ -39,16 +39,20 @@ const contentText = { mention: 'mentioned you in their post.', status: 'published a post.', reblog: 'boosted your post.', + 'reblog+account': (count) => `boosted ${count} of your posts.`, reblog_reply: 'boosted your reply.', follow: 'followed you.', follow_request: 'requested to follow you.', favourite: 'favourited your post.', + 'favourite+account': (count) => `favourited ${count} of your posts.`, favourite_reply: 'favourited your reply.', poll: 'A poll you have voted in or created has ended.', 'poll-self': 'A poll you have created has ended.', 'poll-voted': 'A poll you have voted in has ended.', update: 'A post you interacted with has been edited.', 'favourite+reblog': 'boosted & favourited your post.', + 'favourite+reblog+account': (count) => + `boosted & favourited ${count} of your posts.`, 'favourite+reblog_reply': 'boosted & favourited your reply.', }; @@ -90,12 +94,19 @@ function Notification({ notification, instance, reload }) { type === 'favourite' || type === 'favourite+reblog' ) { - text = - contentText[isReplyToOthers ? `${type}_reply` : type] || - contentText[type]; + if (_statuses?.length > 1) { + text = contentText[`${type}+account`]; + } else if (isReplyToOthers) { + text = contentText[`${type}_reply`]; + } else { + text = contentText[type]; + } } else { text = contentText[type]; } + if (typeof text === 'function') { + text = text(_statuses?.length || _accounts?.length); + } if (type === 'mention' && !status) { // Could be deleted @@ -206,7 +217,23 @@ function Notification({ notification, instance, reload }) { ))}

)} - {status && ( + {_statuses?.length > 1 && ( + + )} + {status && (!_statuses?.length || _statuses?.length <= 1) && ( .status { + font-size: calc(var(--text-size) * 0.9); max-height: 160px; overflow: hidden; /* fade out mask gradient bottom */ @@ -134,6 +135,40 @@ margin-bottom: 8px; } +.notification-group-statuses { + margin: 0; + padding: 0; + list-style: none; +} +.notification-group-statuses > li { + margin: 0; + padding: 0; + list-style: none; + position: relative; + counter-increment: index; +} +.notification-group-statuses > li:before { + content: counter(index); + position: absolute; + left: 0; + font-size: 10px; + padding: 8px; + color: var(--text-insignificant-color); +} +.notification-group-statuses > li + li { + margin-top: 8px; +} +.notification .notification-group-statuses .status-link { + max-height: 80px; +} +.notification .notification-group-statuses .status-link .status { + mask-image: linear-gradient( + rgba(0, 0, 0, 1) 50px, + rgba(0, 0, 0, 0.5) 70px, + transparent 79px + ); +} + #mentions-option { float: right; margin-top: 0.5em; diff --git a/src/utils/group-notifications.jsx b/src/utils/group-notifications.jsx index eff19181..cbc80b48 100644 --- a/src/utils/group-notifications.jsx +++ b/src/utils/group-notifications.jsx @@ -37,7 +37,40 @@ function groupNotifications(notifications) { cleanNotifications[j++] = n; } } - return cleanNotifications; + + // 2nd pass to group "favourite+reblog"-type notifications by account if _accounts.length <= 1 + // This means one acount has favourited and reblogged the multiple statuses + // The grouped notification + // - type: "favourite+reblog+account" + // - _statuses: [status, status, ...] + const notificationsMap2 = {}; + const cleanNotifications2 = []; + for (let i = 0, j = 0; i < cleanNotifications.length; i++) { + const notification = cleanNotifications[i]; + const { account, _accounts, type, createdAt } = notification; + const date = new Date(createdAt).toLocaleDateString(); + if (type === 'favourite+reblog' && account && _accounts.length === 1) { + const key = `${account?.id}-${type}-${date}`; + const mappedNotification = notificationsMap2[key]; + if (mappedNotification) { + mappedNotification._statuses.push(notification.status); + } else { + let n = (notificationsMap2[key] = { + ...notification, + type, + _statuses: [notification.status], + }); + cleanNotifications2[j++] = n; + } + } else { + cleanNotifications2[j++] = notification; + } + } + + console.log({ notifications, cleanNotifications, cleanNotifications2 }); + + // return cleanNotifications; + return cleanNotifications2; } export default groupNotifications; From 12b8651d181cdcef91bc24d161962801dd8032b7 Mon Sep 17 00:00:00 2001 From: Lim Chee Aun Date: Sun, 27 Aug 2023 13:07:06 +0800 Subject: [PATCH 03/12] Use 1px instead of hairline The more visible border width is needed for the buttons overlaying on top of media --- src/app.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app.css b/src/app.css index 8361df31..4adcee34 100644 --- a/src/app.css +++ b/src/app.css @@ -1099,7 +1099,7 @@ button.carousel-dot { font-weight: bold; color: var(--text-color); background-color: var(--bg-faded-blur-color); - border: var(--hairline-width) solid var(--outline-color); + border: 1px solid var(--outline-color); box-shadow: 0 4px 32px var(--drop-shadow-color); transition: all 0.2s ease-out; } From aae74aa4765fe75e4ae8ad5f91f196d7f21f401f Mon Sep 17 00:00:00 2001 From: Lim Chee Aun Date: Mon, 28 Aug 2023 00:21:49 +0800 Subject: [PATCH 04/12] Experiment show avatars instead Add a bit of tooltips too --- src/pages/status.jsx | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/src/pages/status.jsx b/src/pages/status.jsx index 8afa7050..44babe8e 100644 --- a/src/pages/status.jsx +++ b/src/pages/status.jsx @@ -336,6 +336,7 @@ function StatusThread({ id, closeLink = '/', instance: propInstance }) { ancestor: true, isThread: ancestorsIsThread, accountID: s.account.id, + account: s.account, repliesCount: s.repliesCount, weight: calcStatusWeight(s), })), @@ -705,6 +706,7 @@ function StatusThread({ id, closeLink = '/', instance: propInstance }) { block: 'start', }); }} + title="Go to main post" >