Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F33307176
D9846.1768797055.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
D9846.1768797055.diff
View Options
diff --git a/lib/types/minimally-encoded-thread-permissions-types.js b/lib/types/minimally-encoded-thread-permissions-types.js
--- a/lib/types/minimally-encoded-thread-permissions-types.js
+++ b/lib/types/minimally-encoded-thread-permissions-types.js
@@ -9,6 +9,7 @@
rawThreadInfoValidator,
roleInfoValidator,
threadCurrentUserInfoValidator,
+ threadInfoValidator,
} from './thread-types.js';
import type {
MemberInfo,
@@ -16,6 +17,7 @@
RelativeMemberInfo,
RoleInfo,
ThreadCurrentUserInfo,
+ ThreadInfo,
} from './thread-types.js';
import {
decodeThreadRolePermissionsBitmaskArray,
@@ -202,6 +204,49 @@
};
};
+export type MinimallyEncodedThreadInfo = $ReadOnly<{
+ ...ThreadInfo,
+ +minimallyEncoded: true,
+ +members: $ReadOnlyArray<MinimallyEncodedRelativeMemberInfo>,
+ +roles: { +[id: string]: MinimallyEncodedRoleInfo },
+ +currentUser: MinimallyEncodedThreadCurrentUserInfo,
+}>;
+
+const minimallyEncodedThreadInfoValidator: TInterface<MinimallyEncodedThreadInfo> =
+ tShape<MinimallyEncodedThreadInfo>({
+ ...threadInfoValidator.meta.props,
+ minimallyEncoded: tBool(true),
+ members: t.list(minimallyEncodedRelativeMemberInfoValidator),
+ roles: t.dict(tID, minimallyEncodedRoleInfoValidator),
+ currentUser: minimallyEncodedThreadCurrentUserInfoValidator,
+ });
+
+const minimallyEncodeThreadInfo = (
+ threadInfo: ThreadInfo,
+): MinimallyEncodedThreadInfo => {
+ const { members, roles, currentUser, ...rest } = threadInfo;
+ return {
+ ...rest,
+ minimallyEncoded: true,
+ members: members.map(minimallyEncodeRelativeMemberInfo),
+ roles: _mapValues(minimallyEncodeRoleInfo)(roles),
+ currentUser: minimallyEncodeThreadCurrentUserInfo(currentUser),
+ };
+};
+
+const decodeMinimallyEncodedThreadInfo = (
+ minimallyEncodedThreadInfo: MinimallyEncodedThreadInfo,
+): ThreadInfo => {
+ const { minimallyEncoded, members, roles, currentUser, ...rest } =
+ minimallyEncodedThreadInfo;
+ return {
+ ...rest,
+ members: members.map(decodeMinimallyEncodedRelativeMemberInfo),
+ roles: _mapValues(decodeMinimallyEncodedRoleInfo)(roles),
+ currentUser: decodeMinimallyEncodedThreadCurrentUserInfo(currentUser),
+ };
+};
+
export {
minimallyEncodedRoleInfoValidator,
minimallyEncodeRoleInfo,
@@ -218,4 +263,7 @@
minimallyEncodedRelativeMemberInfoValidator,
minimallyEncodeRelativeMemberInfo,
decodeMinimallyEncodedRelativeMemberInfo,
+ minimallyEncodedThreadInfoValidator,
+ minimallyEncodeThreadInfo,
+ decodeMinimallyEncodedThreadInfo,
};
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Jan 19, 4:30 AM (17 h, 17 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5954346
Default Alt Text
D9846.1768797055.diff (2 KB)
Attached To
Mode
D9846: [lib] Introduce `MinimallyEncodedThreadInfo` type
Attached
Detach File
Event Timeline
Log In to Comment