Skip to content

Commit

Permalink
inAppNotifications: lazy load useRoleIcon
Browse files Browse the repository at this point in the history
  • Loading branch information
Cynosphere committed Jan 25, 2025
1 parent 6f0ca77 commit 2aa2c17
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/inAppNotifications/manifest.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
{
"$schema": "https://moonlight-mod.github.io/manifest.schema.json",
"id": "inAppNotifications",
"version": "1.0.1",
"version": "1.0.2",
"meta": {
"name": "In App Notifications",
"tagline": "In app notifications akin to mobile",
"authors": ["Cynosphere"],
"tags": ["qol", "chat"],
"source": "https://github.com/Cynosphere/moonlight-extensions",
"donate": "https://ko-fi.com/Cynosphere"
"donate": "https://ko-fi.com/Cynosphere",
"changelog": "Lazy load `useRoleIcon` to fix not loading on first load sometimes"
},
"dependencies": ["spacepack", "common"],
"settings": {
Expand Down
8 changes: 7 additions & 1 deletion src/inAppNotifications/webpackModules/notification.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ const isMessageNewerThanImprovedMarkdownEpoch = Object.values(

const createMessageHeader = spacepack.findByCode(".isInteractionPlaceholder(),")[0].exports.ZP;
const getMessageAuthor = spacepack.findByCode('"Result cannot be null because the message is not null"')[0].exports.ZP;
const useRoleIcon = spacepack.findFunctionByStrings(spacepack.findByCode(',"roleIcon",')[0].exports, ',"roleIcon",');

const isSystemMessage = spacepack.findByCode(".USER_MESSAGE.has")[0].exports.Z;

Expand All @@ -61,9 +60,11 @@ type _MemoizeReferencedMessage = (
referencedMessage: any,
compat: boolean
) => React.ComponentType<any>;
type UseRoleIcon = (props: { guildId?: string; roleId: string }, subscription?: string) => React.ReactElement;

let makeTextChatNotification: MakeTextChatNotification,
shouldNotify: ShouldNotify,
useRoleIcon: UseRoleIcon,
MemoizeReferencedMessage: _MemoizeReferencedMessage,
SystemMessage: React.ComponentType<any>,
EmbedClasses: Record<string, string>;
Expand All @@ -80,6 +81,11 @@ function lazyLoad() {
".SUPPRESS_NOTIFICATIONS))return!1"
) as ShouldNotify;

useRoleIcon = spacepack.findFunctionByStrings(
spacepack.findByCode(',"roleIcon",')[0].exports,
',"roleIcon",'
) as UseRoleIcon;

MemoizeReferencedMessage = spacepack.findByCode("isReplyAuthorBlocked:", ".REPLY||null==")[0].exports.Z;

SystemMessage = spacepack.findByCode('("SystemMessage")')[0].exports.Z;
Expand Down

0 comments on commit 2aa2c17

Please sign in to comment.