Show annual report notification sticky to top

Might as well go all in
This commit is contained in:
Lim Chee Aun 2024-12-06 13:36:19 +08:00
parent 507999cc5f
commit 4e1572f89c
5 changed files with 128 additions and 78 deletions

View file

@ -174,4 +174,5 @@ export const ICONS = {
'heart-break': () => import('@iconify-icons/mingcute/heart-crack-line'),
'user-x': () => import('@iconify-icons/mingcute/user-x-line'),
minimize: () => import('@iconify-icons/mingcute/arrows-down-line'),
celebrate: () => import('@iconify-icons/mingcute/celebrate-line'),
};

View file

@ -33,6 +33,7 @@ const NOTIFICATION_ICONS = {
moderation_warning: 'alert',
emoji_reaction: 'emoji2',
'pleroma:emoji_reaction': 'emoji2',
annual_report: 'celebrate',
};
/*

View file

@ -5,5 +5,6 @@
"@mastodon/filtered-notifications": "~4.3 || >=4.3",
"@mastodon/fetch-multiple-statuses": "~4.3 || >=4.3",
"@mastodon/trending-link-posts": "~4.3 || >=4.3",
"@mastodon/grouped-notifications": "~4.3 || >=4.3"
"@mastodon/grouped-notifications": "~4.3 || >=4.3",
"@mastodon/annual-report": "~4.4 || >=4.4"
}

154
src/locales/en.po generated
View file

@ -423,8 +423,8 @@ msgstr ""
#: src/pages/catchup.jsx:1581
#: src/pages/filters.jsx:224
#: src/pages/list.jsx:274
#: src/pages/notifications.jsx:868
#: src/pages/notifications.jsx:1082
#: src/pages/notifications.jsx:915
#: src/pages/notifications.jsx:1129
#: src/pages/settings.jsx:77
#: src/pages/status.jsx:1299
msgid "Close"
@ -503,7 +503,7 @@ msgstr ""
#: src/components/list-add-edit.jsx:149
#: src/components/shortcuts-settings.jsx:715
#: src/pages/filters.jsx:554
#: src/pages/notifications.jsx:934
#: src/pages/notifications.jsx:981
msgid "Save"
msgstr ""
@ -531,7 +531,7 @@ msgstr ""
#: src/pages/filters.jsx:89
#: src/pages/followed-hashtags.jsx:40
#: src/pages/home.jsx:53
#: src/pages/notifications.jsx:520
#: src/pages/notifications.jsx:560
msgid "Home"
msgstr ""
@ -941,7 +941,7 @@ msgid "Open in new window"
msgstr ""
#: src/components/follow-request-buttons.jsx:42
#: src/pages/notifications.jsx:918
#: src/pages/notifications.jsx:965
msgid "Accept"
msgstr ""
@ -950,7 +950,7 @@ msgid "Reject"
msgstr ""
#: src/components/follow-request-buttons.jsx:75
#: src/pages/notifications.jsx:1201
#: src/pages/notifications.jsx:1248
msgid "Accepted"
msgstr ""
@ -963,7 +963,7 @@ msgid "Nothing to show"
msgstr ""
#: src/components/generic-accounts.jsx:145
#: src/components/notification.jsx:444
#: src/components/notification.jsx:445
#: src/pages/accounts.jsx:41
#: src/pages/search.jsx:317
#: src/pages/search.jsx:350
@ -973,7 +973,7 @@ msgstr ""
#: src/components/generic-accounts.jsx:205
#: src/components/timeline.jsx:519
#: src/pages/list.jsx:293
#: src/pages/notifications.jsx:848
#: src/pages/notifications.jsx:895
#: src/pages/search.jsx:544
#: src/pages/status.jsx:1332
msgid "Show more…"
@ -1290,8 +1290,8 @@ msgstr ""
#: src/pages/filters.jsx:24
#: src/pages/home.jsx:84
#: src/pages/home.jsx:184
#: src/pages/notifications.jsx:112
#: src/pages/notifications.jsx:524
#: src/pages/notifications.jsx:113
#: src/pages/notifications.jsx:564
msgid "Notifications"
msgstr ""
@ -1412,142 +1412,142 @@ msgstr ""
msgid "View all notifications"
msgstr ""
#: src/components/notification.jsx:70
#: src/components/notification.jsx:71
msgid "{account} reacted to your post with {emojiObject}"
msgstr ""
#: src/components/notification.jsx:77
#: src/components/notification.jsx:78
msgid "{account} published a post."
msgstr ""
#: src/components/notification.jsx:85
#: src/components/notification.jsx:86
msgid "{count, plural, =1 {{postsCount, plural, =1 {{postType, select, reply {{account} boosted your reply.} other {{account} boosted your post.}}} other {{account} boosted {postsCount} of your posts.}}} other {{postType, select, reply {<0><1>{0}</1> people</0> boosted your reply.} other {<2><3>{1}</3> people</2> boosted your post.}}}}"
msgstr ""
#: src/components/notification.jsx:128
#: src/components/notification.jsx:129
msgid "{count, plural, =1 {{account} followed you.} other {<0><1>{0}</1> people</0> followed you.}}"
msgstr ""
#: src/components/notification.jsx:142
#: src/components/notification.jsx:143
msgid "{account} requested to follow you."
msgstr ""
#: src/components/notification.jsx:151
#: src/components/notification.jsx:152
msgid "{count, plural, =1 {{postsCount, plural, =1 {{postType, select, reply {{account} liked your reply.} other {{account} liked your post.}}} other {{account} liked {postsCount} of your posts.}}} other {{postType, select, reply {<0><1>{0}</1> people</0> liked your reply.} other {<2><3>{1}</3> people</2> liked your post.}}}}"
msgstr ""
#: src/components/notification.jsx:193
#: src/components/notification.jsx:194
msgid "A poll you have voted in or created has ended."
msgstr ""
#: src/components/notification.jsx:194
#: src/components/notification.jsx:195
msgid "A poll you have created has ended."
msgstr ""
#: src/components/notification.jsx:195
#: src/components/notification.jsx:196
msgid "A poll you have voted in has ended."
msgstr ""
#: src/components/notification.jsx:196
#: src/components/notification.jsx:197
msgid "A post you interacted with has been edited."
msgstr ""
#: src/components/notification.jsx:204
#: src/components/notification.jsx:205
msgid "{count, plural, =1 {{postsCount, plural, =1 {{postType, select, reply {{account} boosted & liked your reply.} other {{account} boosted & liked your post.}}} other {{account} boosted & liked {postsCount} of your posts.}}} other {{postType, select, reply {<0><1>{0}</1> people</0> boosted & liked your reply.} other {<2><3>{1}</3> people</2> boosted & liked your post.}}}}"
msgstr ""
#: src/components/notification.jsx:246
#: src/components/notification.jsx:247
msgid "{account} signed up."
msgstr ""
#: src/components/notification.jsx:248
#: src/components/notification.jsx:249
msgid "{account} reported {targetAccount}"
msgstr ""
#: src/components/notification.jsx:253
#: src/components/notification.jsx:254
msgid "Lost connections with <0>{name}</0>."
msgstr ""
#: src/components/notification.jsx:259
#: src/components/notification.jsx:260
msgid "Moderation warning"
msgstr ""
#: src/components/notification.jsx:264
#: src/components/notification.jsx:265
msgid "Your {year} #Wrapstodon is here!"
msgstr "Your {year} #Wrapstodon is here!"
#: src/components/notification.jsx:270
#: src/components/notification.jsx:271
msgid "An admin from <0>{from}</0> has suspended <1>{targetName}</1>, which means you can no longer receive updates from them or interact with them."
msgstr ""
#: src/components/notification.jsx:276
#: src/components/notification.jsx:277
msgid "An admin from <0>{from}</0> has blocked <1>{targetName}</1>. Affected followers: {followersCount}, followings: {followingCount}."
msgstr ""
#: src/components/notification.jsx:282
#: src/components/notification.jsx:283
msgid "You have blocked <0>{targetName}</0>. Removed followers: {followersCount}, followings: {followingCount}."
msgstr ""
#: src/components/notification.jsx:290
#: src/components/notification.jsx:291
msgid "Your account has received a moderation warning."
msgstr ""
#: src/components/notification.jsx:291
#: src/components/notification.jsx:292
msgid "Your account has been disabled."
msgstr ""
#: src/components/notification.jsx:292
#: src/components/notification.jsx:293
msgid "Some of your posts have been marked as sensitive."
msgstr ""
#: src/components/notification.jsx:293
#: src/components/notification.jsx:294
msgid "Some of your posts have been deleted."
msgstr ""
#: src/components/notification.jsx:294
#: src/components/notification.jsx:295
msgid "Your posts will be marked as sensitive from now on."
msgstr ""
#: src/components/notification.jsx:295
#: src/components/notification.jsx:296
msgid "Your account has been limited."
msgstr ""
#: src/components/notification.jsx:296
#: src/components/notification.jsx:297
msgid "Your account has been suspended."
msgstr ""
#: src/components/notification.jsx:371
#: src/components/notification.jsx:372
msgid "[Unknown notification type: {type}]"
msgstr ""
#: src/components/notification.jsx:440
#: src/components/notification.jsx:441
#: src/components/status.jsx:1036
#: src/components/status.jsx:1046
msgid "Boosted/Liked by…"
msgstr ""
#: src/components/notification.jsx:441
#: src/components/notification.jsx:442
msgid "Liked by…"
msgstr ""
#: src/components/notification.jsx:442
#: src/components/notification.jsx:443
msgid "Boosted by…"
msgstr ""
#: src/components/notification.jsx:443
#: src/components/notification.jsx:444
msgid "Followed by…"
msgstr ""
#: src/components/notification.jsx:514
#: src/components/notification.jsx:530
#: src/components/notification.jsx:515
#: src/components/notification.jsx:531
msgid "Learn more <0/>"
msgstr ""
#: src/components/notification.jsx:539
#: src/components/notification.jsx:540
msgid "View #Wrapstodon"
msgstr "View #Wrapstodon"
#: src/components/notification.jsx:769
#: src/components/notification.jsx:770
#: src/components/status.jsx:267
msgid "Read more →"
msgstr ""
@ -2341,7 +2341,7 @@ msgstr ""
#: src/components/timeline.jsx:554
#: src/pages/home.jsx:213
#: src/pages/notifications.jsx:824
#: src/pages/notifications.jsx:871
#: src/pages/status.jsx:988
#: src/pages/status.jsx:1361
msgid "Try again"
@ -3154,125 +3154,125 @@ msgstr ""
msgid "Unable to load mentions."
msgstr ""
#: src/pages/notifications.jsx:103
#: src/pages/notifications.jsx:104
msgid "You don't follow"
msgstr ""
#: src/pages/notifications.jsx:104
#: src/pages/notifications.jsx:105
msgid "Who don't follow you"
msgstr ""
#: src/pages/notifications.jsx:105
#: src/pages/notifications.jsx:106
msgid "With a new account"
msgstr ""
#: src/pages/notifications.jsx:106
#: src/pages/notifications.jsx:107
msgid "Who unsolicitedly private mention you"
msgstr ""
#: src/pages/notifications.jsx:107
#: src/pages/notifications.jsx:108
msgid "Who are limited by server moderators"
msgstr ""
#: src/pages/notifications.jsx:538
#: src/pages/notifications.jsx:872
#: src/pages/notifications.jsx:578
#: src/pages/notifications.jsx:919
msgid "Notifications settings"
msgstr ""
#: src/pages/notifications.jsx:556
#: src/pages/notifications.jsx:596
msgid "New notifications"
msgstr ""
#: src/pages/notifications.jsx:567
#: src/pages/notifications.jsx:607
msgid "{0, plural, one {Announcement} other {Announcements}}"
msgstr ""
#: src/pages/notifications.jsx:614
#: src/pages/notifications.jsx:654
#: src/pages/settings.jsx:1161
msgid "Follow requests"
msgstr ""
#: src/pages/notifications.jsx:619
#: src/pages/notifications.jsx:659
msgid "{0, plural, one {# follow request} other {# follow requests}}"
msgstr ""
#: src/pages/notifications.jsx:674
#: src/pages/notifications.jsx:714
msgid "{0, plural, one {Filtered notifications from # person} other {Filtered notifications from # people}}"
msgstr ""
#: src/pages/notifications.jsx:740
#: src/pages/notifications.jsx:787
msgid "Only mentions"
msgstr ""
#: src/pages/notifications.jsx:744
#: src/pages/notifications.jsx:791
msgid "Today"
msgstr ""
#: src/pages/notifications.jsx:749
#: src/pages/notifications.jsx:796
msgid "You're all caught up."
msgstr ""
#: src/pages/notifications.jsx:772
#: src/pages/notifications.jsx:819
msgid "Yesterday"
msgstr ""
#: src/pages/notifications.jsx:820
#: src/pages/notifications.jsx:867
msgid "Unable to load notifications"
msgstr ""
#: src/pages/notifications.jsx:899
#: src/pages/notifications.jsx:946
msgid "Notifications settings updated"
msgstr ""
#: src/pages/notifications.jsx:907
#: src/pages/notifications.jsx:954
msgid "Filter out notifications from people:"
msgstr ""
#: src/pages/notifications.jsx:921
#: src/pages/notifications.jsx:968
msgid "Filter"
msgstr ""
#: src/pages/notifications.jsx:924
#: src/pages/notifications.jsx:971
msgid "Ignore"
msgstr ""
#: src/pages/notifications.jsx:997
#: src/pages/notifications.jsx:1044
msgid "Updated <0>{0}</0>"
msgstr ""
#: src/pages/notifications.jsx:1065
#: src/pages/notifications.jsx:1112
msgid "View notifications from <0>@{0}</0>"
msgstr ""
#: src/pages/notifications.jsx:1086
#: src/pages/notifications.jsx:1133
msgid "Notifications from <0>@{0}</0>"
msgstr ""
#: src/pages/notifications.jsx:1153
#: src/pages/notifications.jsx:1200
msgid "Notifications from @{0} will not be filtered from now on."
msgstr ""
#: src/pages/notifications.jsx:1158
#: src/pages/notifications.jsx:1205
msgid "Unable to accept notification request"
msgstr ""
#: src/pages/notifications.jsx:1163
#: src/pages/notifications.jsx:1210
msgid "Allow"
msgstr ""
#: src/pages/notifications.jsx:1183
#: src/pages/notifications.jsx:1230
msgid "Notifications from @{0} will not show up in Filtered notifications from now on."
msgstr ""
#: src/pages/notifications.jsx:1188
#: src/pages/notifications.jsx:1235
msgid "Unable to dismiss notification request"
msgstr ""
#: src/pages/notifications.jsx:1193
#: src/pages/notifications.jsx:1240
msgid "Dismiss"
msgstr ""
#: src/pages/notifications.jsx:1208
#: src/pages/notifications.jsx:1255
msgid "Dismissed"
msgstr ""

View file

@ -39,6 +39,7 @@ import { getRegistration } from '../utils/push-notifications';
import shortenNumber from '../utils/shorten-number';
import showToast from '../utils/show-toast';
import states, { saveStatus } from '../utils/states';
import store from '../utils/store';
import { getCurrentInstance } from '../utils/store-utils';
import supports from '../utils/supports';
import usePageVisibility from '../utils/usePageVisibility';
@ -409,6 +410,45 @@ function Notifications({ columnMode }) {
// }
// }, [uiState]);
const [annualReportNotification, setAnnualReportNotification] =
useState(null);
useEffect(async () => {
// Skip this if not in December
const date = new Date();
if (date.getMonth() !== 11) return;
// Skip if doesn't support annual report
if (!supports('@mastodon/annual-report')) return;
let annualReportNotification = store.account.get(
'annualReportNotification',
);
if (annualReportNotification) {
setAnnualReportNotification(annualReportNotification);
return;
}
const notificationIterator = mastoFetchNotifications({
types: ['annual_report'],
});
try {
const notification = await notificationIterator.next();
annualReportNotification = notification?.value?.notificationGroups?.[0];
const annualReportYear = annualReportNotification?.annualReport?.year;
// If same year, show the annual report
if (annualReportYear == date.getFullYear()) {
console.log(
'ANNUAL REPORT',
annualReportYear,
annualReportNotification,
);
setAnnualReportNotification(annualReportNotification);
store.account.set('annualReportNotification', annualReportNotification);
}
} catch (e) {
console.warn(e);
}
}, []);
const itemsSelector = '.notification';
const jRef = useHotkeys('j', () => {
const activeItem = document.activeElement.closest(itemsSelector);
@ -728,6 +768,13 @@ function Notifications({ columnMode }) {
</div>
</div>
)}
{annualReportNotification && (
<div class="shazam-container">
<div class="shazam-container-inner">
<Notification notification={annualReportNotification} />
</div>
</div>
)}
<div id="mentions-option">
<label>
<input