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'), 'heart-break': () => import('@iconify-icons/mingcute/heart-crack-line'),
'user-x': () => import('@iconify-icons/mingcute/user-x-line'), 'user-x': () => import('@iconify-icons/mingcute/user-x-line'),
minimize: () => import('@iconify-icons/mingcute/arrows-down-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', moderation_warning: 'alert',
emoji_reaction: 'emoji2', emoji_reaction: 'emoji2',
'pleroma:emoji_reaction': 'emoji2', 'pleroma:emoji_reaction': 'emoji2',
annual_report: 'celebrate',
}; };
/* /*

View file

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

View file

@ -39,6 +39,7 @@ import { getRegistration } from '../utils/push-notifications';
import shortenNumber from '../utils/shorten-number'; import shortenNumber from '../utils/shorten-number';
import showToast from '../utils/show-toast'; import showToast from '../utils/show-toast';
import states, { saveStatus } from '../utils/states'; import states, { saveStatus } from '../utils/states';
import store from '../utils/store';
import { getCurrentInstance } from '../utils/store-utils'; import { getCurrentInstance } from '../utils/store-utils';
import supports from '../utils/supports'; import supports from '../utils/supports';
import usePageVisibility from '../utils/usePageVisibility'; import usePageVisibility from '../utils/usePageVisibility';
@ -409,6 +410,45 @@ function Notifications({ columnMode }) {
// } // }
// }, [uiState]); // }, [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 itemsSelector = '.notification';
const jRef = useHotkeys('j', () => { const jRef = useHotkeys('j', () => {
const activeItem = document.activeElement.closest(itemsSelector); const activeItem = document.activeElement.closest(itemsSelector);
@ -728,6 +768,13 @@ function Notifications({ columnMode }) {
</div> </div>
</div> </div>
)} )}
{annualReportNotification && (
<div class="shazam-container">
<div class="shazam-container-inner">
<Notification notification={annualReportNotification} />
</div>
</div>
)}
<div id="mentions-option"> <div id="mentions-option">
<label> <label>
<input <input