Page MenuHomePhabricator

D12784.id42382.diff
No OneTemporary

D12784.id42382.diff

diff --git a/lib/push/send-hooks.react.js b/lib/push/send-hooks.react.js
--- a/lib/push/send-hooks.react.js
+++ b/lib/push/send-hooks.react.js
@@ -8,6 +8,7 @@
} from './send-utils.js';
import { ENSCacheContext } from '../components/ens-cache-provider.react.js';
import { NeynarClientContext } from '../components/neynar-client-provider.react.js';
+import { thickRawThreadInfosSelector } from '../selectors/thread-selectors.js';
import type { MessageData } from '../types/message-types.js';
import type {
EncryptedNotifUtilsAPI,
@@ -21,7 +22,7 @@
messageDatas: $ReadOnlyArray<MessageData>,
) => Promise<?PerUserTargetedNotifications> {
const rawMessageInfos = useSelector(state => state.messageStore.messages);
- const rawThreadInfos = useSelector(state => state.threadStore.threadInfos);
+ const thickRawThreadInfos = useSelector(thickRawThreadInfosSelector);
const auxUserInfos = useSelector(state => state.auxUserStore.auxUserInfos);
const userInfos = useSelector(state => state.userStore.userInfos);
@@ -38,7 +39,7 @@
encryptedNotifUtilsAPI,
senderDeviceDescriptor,
messageInfos: rawMessageInfos,
- rawThreadInfos,
+ thickRawThreadInfos,
auxUserInfos,
messageDatas,
userInfos,
@@ -48,7 +49,7 @@
},
[
rawMessageInfos,
- rawThreadInfos,
+ thickRawThreadInfos,
auxUserInfos,
userInfos,
getENSNames,
diff --git a/lib/push/send-utils.js b/lib/push/send-utils.js
--- a/lib/push/send-utils.js
+++ b/lib/push/send-utils.js
@@ -46,7 +46,7 @@
EncryptedNotifUtilsAPI,
} from '../types/notif-types.js';
import type { ThreadSubscription } from '../types/subscription-types.js';
-import type { RawThreadInfos } from '../types/thread-types.js';
+import type { ThickRawThreadInfos } from '../types/thread-types.js';
import type { UserInfos } from '../types/user-types.js';
import { type GetENSNames } from '../utils/ens-helpers.js';
import { type GetFCNames } from '../utils/farcaster-helpers.js';
@@ -86,7 +86,7 @@
async function getPushUserInfo(
messageInfos: { +[id: string]: RawMessageInfo },
- rawThreadInfos: RawThreadInfos,
+ thickRawThreadInfos: ThickRawThreadInfos,
auxUserInfos: AuxUserInfos,
messageDatas: $ReadOnlyArray<MessageData>,
): Promise<{
@@ -132,12 +132,11 @@
} = {};
for (const threadID of threadsToMessageIndices.keys()) {
- const threadInfo = rawThreadInfos[threadID];
+ const threadInfo = thickRawThreadInfos[threadID];
for (const memberInfo of threadInfo.members) {
if (
!isMemberActive(memberInfo) ||
- !hasPermission(memberInfo.permissions, 'visible') ||
- !memberInfo.subscription
+ !hasPermission(memberInfo.permissions, 'visible')
) {
continue;
}
@@ -569,7 +568,7 @@
+encryptedNotifUtilsAPI: EncryptedNotifUtilsAPI,
+senderDeviceDescriptor: SenderDeviceDescriptor,
+pushInfo: PushInfo,
- +rawThreadInfos: RawThreadInfos,
+ +thickRawThreadInfos: ThickRawThreadInfos,
+userInfos: UserInfos,
+getENSNames: ?GetENSNames,
+getFCNames: ?GetFCNames,
@@ -582,7 +581,7 @@
encryptedNotifUtilsAPI,
senderDeviceDescriptor,
pushInfo,
- rawThreadInfos,
+ thickRawThreadInfos,
userInfos,
getENSNames,
getFCNames,
@@ -612,7 +611,7 @@
[...threadIDs].map(threadID => [
threadID,
threadInfoFromRawThreadInfo(
- rawThreadInfos[threadID],
+ thickRawThreadInfos[threadID],
userID,
userInfos,
),
@@ -656,7 +655,7 @@
+encryptedNotifUtilsAPI: EncryptedNotifUtilsAPI,
+senderDeviceDescriptor: SenderDeviceDescriptor,
+messageInfos: { +[id: string]: RawMessageInfo },
- +rawThreadInfos: RawThreadInfos,
+ +thickRawThreadInfos: ThickRawThreadInfos,
+auxUserInfos: AuxUserInfos,
+messageDatas: $ReadOnlyArray<MessageData>,
+userInfos: UserInfos,
@@ -673,7 +672,7 @@
messageDatas,
messageInfos,
auxUserInfos,
- rawThreadInfos,
+ thickRawThreadInfos,
userInfos,
getENSNames,
getFCNames,
@@ -681,7 +680,7 @@
const { pushInfos } = await getPushUserInfo(
messageInfos,
- rawThreadInfos,
+ thickRawThreadInfos,
auxUserInfos,
messageDatas,
);
@@ -694,7 +693,7 @@
encryptedNotifUtilsAPI,
senderDeviceDescriptor,
pushInfo: pushInfos,
- rawThreadInfos,
+ thickRawThreadInfos,
userInfos,
getENSNames,
getFCNames,
diff --git a/lib/selectors/thread-selectors.js b/lib/selectors/thread-selectors.js
--- a/lib/selectors/thread-selectors.js
+++ b/lib/selectors/thread-selectors.js
@@ -41,6 +41,7 @@
RelativeMemberInfo,
ThreadInfo,
RawThreadInfo,
+ ThickRawThreadInfo,
} from '../types/minimally-encoded-thread-permissions-types.js';
import type { BaseAppState } from '../types/redux-types.js';
import {
@@ -51,6 +52,7 @@
import type {
MixedRawThreadInfos,
RawThreadInfos,
+ ThickRawThreadInfos,
} from '../types/thread-types.js';
import { dateString, dateFromString } from '../utils/date-utils.js';
import { values } from '../utils/objects.js';
@@ -217,6 +219,23 @@
},
);
+const thickRawThreadInfosSelector: (
+ state: BaseAppState<>,
+) => ThickRawThreadInfos = createSelector(
+ (state: BaseAppState<>) => state.threadStore.threadInfos,
+ (threadInfos: RawThreadInfos): ThickRawThreadInfos => {
+ const thickRawThreadInfos: { [id: string]: ThickRawThreadInfo } = {};
+ for (const id in threadInfos) {
+ const threadInfo = threadInfos[id];
+ if (!threadInfo.thick) {
+ continue;
+ }
+ thickRawThreadInfos[id] = threadInfo;
+ }
+ return thickRawThreadInfos;
+ },
+);
+
const unreadCount: (state: BaseAppState<>) => number = createSelector(
(state: BaseAppState<>) => state.threadStore.threadInfos,
(threadInfos: RawThreadInfos): number =>
@@ -519,4 +538,5 @@
pendingToRealizedThreadIDsSelector,
savedEmojiAvatarSelectorForThread,
threadInfosSelectorForThreadType,
+ thickRawThreadInfosSelector,
};
diff --git a/lib/types/thread-types.js b/lib/types/thread-types.js
--- a/lib/types/thread-types.js
+++ b/lib/types/thread-types.js
@@ -18,6 +18,7 @@
RawThreadInfo,
ResolvedThreadInfo,
ThreadInfo,
+ ThickRawThreadInfo,
} from './minimally-encoded-thread-permissions-types.js';
import {
type ThreadSubscription,
@@ -169,6 +170,9 @@
export type MixedRawThreadInfos = {
+[id: string]: LegacyRawThreadInfo | RawThreadInfo,
};
+export type ThickRawThreadInfos = {
+ +[id: string]: ThickRawThreadInfo,
+};
export type RawThreadInfos = {
+[id: string]: RawThreadInfo,
};

File Metadata

Mime Type
text/plain
Expires
Tue, Dec 3, 1:22 AM (21 h, 40 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2609632
Default Alt Text
D12784.id42382.diff (6 KB)

Event Timeline