Skip to content

Commit 0d4da31

Browse files
committed
Group mention+quote notification
1 parent 8d61bab commit 0d4da31

File tree

4 files changed

+69
-9
lines changed

4 files changed

+69
-9
lines changed

src/components/notification.jsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -502,6 +502,11 @@ function Notification({
502502
<Icon icon="rocket" size="xl" alt={type} class="reblog-icon" />
503503
<Icon icon="heart" size="xl" alt={type} class="favourite-icon" />
504504
</>
505+
) : type === 'mention+quote' ? (
506+
<>
507+
<Icon icon="comment" size="xl" alt={type} class="mention-icon" />
508+
<Icon icon="quote" size="xl" alt={type} class="quote-icon" />
509+
</>
505510
) : (
506511
<Icon
507512
icon={NOTIFICATION_ICONS[type] || 'notification'}
@@ -526,7 +531,7 @@ function Notification({
526531
</mark>
527532
</>
528533
)} */}
529-
{type !== 'mention' && type !== 'quote' && (
534+
{type !== 'mention' && type !== 'quote' && type !== 'mention+quote' && (
530535
<>
531536
<p>{text}</p>
532537
{type === 'follow_request' && (

src/locales/en.po

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/pages/notifications.css

Lines changed: 41 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,11 @@
5151
cursor: pointer;
5252
}
5353
}
54-
.notification-type:is(.notification-mention, .notification-quote) {
54+
.notification-type:is(
55+
.notification-mention,
56+
.notification-quote,
57+
.notification-mention\+quote
58+
) {
5559
padding-top: 16px;
5660
}
5761
.only-mentions .notification:not(.notification-mention),
@@ -91,6 +95,12 @@
9195
.notification .favourite-icon {
9296
color: var(--favourite-color);
9397
}
98+
.notification .mention-icon {
99+
color: var(--reply-to-color);
100+
}
101+
.notification .quote-icon {
102+
color: var(--quote-color);
103+
}
94104

95105
.notification .account-avatar-stack {
96106
position: relative;
@@ -142,12 +152,20 @@
142152
filter: saturate(0.25);
143153
}
144154
.notification
145-
.status-link:not(.status-type-mention, .status-type-quote)
155+
.status-link:not(
156+
.status-type-mention,
157+
.status-type-quote,
158+
.status-type-mention\+quote
159+
)
146160
> .status {
147161
font-size: calc(var(--text-size) * 0.9);
148162
}
149163
.notification
150-
.status-link.truncated:not(.status-type-mention, .status-type-quote)
164+
.status-link.truncated:not(
165+
.status-type-mention,
166+
.status-type-quote,
167+
.status-type-mention\+quote
168+
)
151169
> .status {
152170
/* fade out mask gradient bottom */
153171
mask-image: linear-gradient(
@@ -200,6 +218,20 @@
200218
border-color: var(--quote-color);
201219
box-shadow: 0 0 0 3px var(--quote-faded-color);
202220
}
221+
.notification .status-link.status-type-mention\+quote {
222+
max-height: 320px;
223+
filter: none;
224+
background-color: var(--bg-color);
225+
border-color: transparent;
226+
background-image:
227+
linear-gradient(var(--bg-color), var(--bg-color)),
228+
linear-gradient(135deg in oklch, var(--reply-to-color), var(--quote-color));
229+
background-origin: border-box;
230+
background-clip: padding-box, border-box;
231+
box-shadow:
232+
1.5px 1.5px 0 1.5px var(--quote-faded-color),
233+
-1.5px -1.5px 0 1.5px var(--reply-to-faded-color);
234+
}
203235
.notification:focus-visible .status-link,
204236
.notification .status-link:is(:hover, :focus) {
205237
background-color: var(--bg-blur-color);
@@ -214,6 +246,12 @@
214246
border-color: var(--quote-color);
215247
box-shadow: 0 0 5px var(--quote-color);
216248
}
249+
.notification .status-link.status-type-mention\+quote:is(:hover, :focus) {
250+
border-color: transparent;
251+
box-shadow:
252+
2.5px 2.5px 5px -2.5px var(--quote-color),
253+
-2.5px -2.5px 5px -2.5px var(--reply-to-color);
254+
}
217255
.notification .status-link:active {
218256
filter: brightness(0.95);
219257
}

src/utils/group-notifications.js

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,23 @@ export function groupNotifications2(groupNotifications) {
106106
const key = `${status?.id}-${virtualType}-${date}`;
107107
const mappedNotification = notificationsMap[key];
108108
if (!groupable(type)) {
109+
// Merge mention and quote if same status
110+
// NOTES:
111+
// - status.id is definitely the same
112+
// - account is definitely the same too and will only be one
113+
if ((type === 'mention' || type === 'quote') && status?.id) {
114+
const otherGN = newGroupNotifications1.find(
115+
(o) =>
116+
((type === 'quote' && o.type === 'mention') ||
117+
(type === 'mention' && o.type === 'quote')) &&
118+
o.status?.id === status.id,
119+
);
120+
if (otherGN) {
121+
otherGN.type = 'mention+quote';
122+
continue; // Skip below logic
123+
}
124+
}
125+
109126
newGroupNotifications1.push(gn);
110127
} else if (mappedNotification) {
111128
// Merge sampleAccounts + merge _types
@@ -132,7 +149,7 @@ export function groupNotifications2(groupNotifications) {
132149
mappedNotification._notificationsCount.push(notificationsCount);
133150
mappedNotification._sampleAccountsCount.push(sampleAccounts?.length);
134151
mappedNotification._accounts = mappedNotification.sampleAccounts;
135-
mappedNotification._groupKeys.push(groupKey);
152+
if (groupKey) mappedNotification._groupKeys.push(groupKey);
136153
} else {
137154
const accounts = sampleAccounts.map((a) => ({
138155
...a,

0 commit comments

Comments
 (0)