Skip to content

Commit

Permalink
[lib] RawThreadInfo -> LegacyRawThreadInfo
Browse files Browse the repository at this point in the history
Summary:
Same as D10066 and D10071 and D10073, but for `RawThreadInfo`.

---

Depends on D10074

Test Plan: `flow`/CI/etc

Reviewers: ashoat, ginsu, tomek, rohan

Reviewed By: ashoat

Differential Revision: https://phab.comm.dev/D10077
  • Loading branch information
atulsmadhugiri committed Nov 29, 2023
1 parent 585efac commit 819fb9e
Show file tree
Hide file tree
Showing 65 changed files with 308 additions and 256 deletions.
4 changes: 2 additions & 2 deletions keyserver/src/creators/update-creator.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import {
redisMessageTypes,
type NewUpdatesRedisMessage,
} from 'lib/types/redis-types.js';
import type { RawThreadInfos } from 'lib/types/thread-types';
import type { LegacyRawThreadInfos } from 'lib/types/thread-types';
import {
type ServerUpdateInfo,
type UpdateData,
Expand Down Expand Up @@ -92,7 +92,7 @@ export type ViewerInfo =
viewer: Viewer,
calendarQuery: ?CalendarQuery,
updatesForCurrentSession?: UpdatesForCurrentSession,
threadInfos: RawThreadInfos,
threadInfos: LegacyRawThreadInfos,
};
const defaultUpdateCreationResult = { viewerUpdates: [], userInfos: {} };
const sortFunction = (
Expand Down
8 changes: 4 additions & 4 deletions keyserver/src/fetchers/thread-fetchers.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ import type { AvatarDBContent, ClientAvatar } from 'lib/types/avatar-types.js';
import type { RawMessageInfo, MessageInfo } from 'lib/types/message-types.js';
import { threadTypes, type ThreadType } from 'lib/types/thread-types-enum.js';
import {
type RawThreadInfos,
type LegacyRawThreadInfos,
type ServerThreadInfo,
type RawThreadInfo,
type LegacyRawThreadInfo,
} from 'lib/types/thread-types.js';
import { ServerError } from 'lib/utils/errors.js';

Expand Down Expand Up @@ -245,7 +245,7 @@ async function fetchServerThreadInfos(
}

export type FetchThreadInfosResult = {
+threadInfos: RawThreadInfos,
+threadInfos: LegacyRawThreadInfos,
};

async function fetchThreadInfos(
Expand Down Expand Up @@ -278,7 +278,7 @@ function rawThreadInfosFromServerThreadInfos(
native: 285,
});

const threadInfos: { [string]: RawThreadInfo } = {};
const threadInfos: { [string]: LegacyRawThreadInfo } = {};
for (const threadID in serverResult.threadInfos) {
const serverThreadInfo = serverResult.threadInfos[threadID];
const threadInfo = rawThreadInfoFromServerThreadInfo(
Expand Down
6 changes: 3 additions & 3 deletions keyserver/src/responders/thread-responders.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import {
type RoleModificationResult,
type RoleDeletionRequest,
type RoleDeletionResult,
rawThreadInfoValidator,
legacyRawThreadInfoValidator,
} from 'lib/types/thread-types.js';
import { serverUpdateInfoValidator } from 'lib/types/update-types.js';
import { userInfosValidator } from 'lib/types/user-types.js';
Expand Down Expand Up @@ -289,7 +289,7 @@ export const roleModificationRequestInputValidator: TUnion<RoleModificationReque

export const roleModificationResultValidator: TInterface<RoleModificationResult> =
tShape<RoleModificationResult>({
threadInfo: t.maybe(rawThreadInfoValidator),
threadInfo: t.maybe(legacyRawThreadInfoValidator),
updatesResult: tShape({
newUpdates: t.list(serverUpdateInfoValidator),
}),
Expand All @@ -310,7 +310,7 @@ export const roleDeletionRequestInputValidator: TInterface<RoleDeletionRequest>

export const roleDeletionResultValidator: TInterface<RoleDeletionResult> =
tShape<RoleDeletionResult>({
threadInfo: t.maybe(rawThreadInfoValidator),
threadInfo: t.maybe(legacyRawThreadInfoValidator),
updatesResult: tShape({
newUpdates: t.list(serverUpdateInfoValidator),
}),
Expand Down
6 changes: 3 additions & 3 deletions keyserver/src/responders/user-responders.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ import {
type SubscriptionUpdateResponse,
threadSubscriptionValidator,
} from 'lib/types/subscription-types.js';
import { rawThreadInfoValidator } from 'lib/types/thread-types.js';
import { legacyRawThreadInfoValidator } from 'lib/types/thread-types.js';
import { createUpdatesResultValidator } from 'lib/types/update-types.js';
import {
type PasswordUpdate,
Expand Down Expand Up @@ -253,7 +253,7 @@ export const registerResponseValidator: TInterface<RegisterResponse> =
rawMessageInfos: t.list(rawMessageInfoValidator),
currentUserInfo: loggedInUserInfoValidator,
cookieChange: tShape({
threadInfos: t.dict(tID, rawThreadInfoValidator),
threadInfos: t.dict(tID, legacyRawThreadInfoValidator),
userInfos: t.list(userInfoValidator),
}),
});
Expand Down Expand Up @@ -437,7 +437,7 @@ export const logInResponseValidator: TInterface<LogInResponse> =
rawEntryInfos: t.maybe(t.list(rawEntryInfoValidator)),
serverTime: t.Number,
cookieChange: tShape({
threadInfos: t.dict(tID, rawThreadInfoValidator),
threadInfos: t.dict(tID, legacyRawThreadInfoValidator),
userInfos: t.list(userInfoValidator),
}),
notAcknowledgedPolicies: t.maybe(t.list<TEnums>(policyTypeValidator)),
Expand Down
4 changes: 2 additions & 2 deletions keyserver/src/scripts/generate-converter-from-validator.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
mediaValidator,
} from 'lib/types/media-types.js';
import { threadPermissionInfoValidator } from 'lib/types/thread-permission-types.js';
import { rawThreadInfoValidator } from 'lib/types/thread-types.js';
import { legacyRawThreadInfoValidator } from 'lib/types/thread-types.js';
import { ashoatKeyserverID, tID } from 'lib/utils/validation-utils.js';

import { main } from './utils.js';
Expand Down Expand Up @@ -213,7 +213,7 @@ function generateConverterFromValidator<T, C>(
}
// Input arguments:
const validator = rawThreadInfoValidator;
const validator = legacyRawThreadInfoValidator;
const typeName = 'RawThreadInfo';
const validatorToBeConverted = tID;
const conversionExpressionString = (inputName: string) =>
Expand Down
18 changes: 9 additions & 9 deletions keyserver/src/shared/state-sync/threads-state-sync-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
import { threadsStateSyncSpec as libSpec } from 'lib/shared/state-sync/threads-state-sync-spec.js';
import type { ClientThreadInconsistencyReportCreationRequest } from 'lib/types/report-types.js';
import {
type RawThreadInfos,
type RawThreadInfo,
rawThreadInfoValidator,
type LegacyRawThreadInfos,
type LegacyRawThreadInfo,
legacyRawThreadInfoValidator,
} from 'lib/types/thread-types.js';
import { hash, combineUnorderedHashes, values } from 'lib/utils/objects.js';

Expand All @@ -15,9 +15,9 @@ import type { Viewer } from '../../session/viewer.js';
import { validateOutput } from '../../utils/validation-utils.js';

export const threadsStateSyncSpec: ServerStateSyncSpec<
RawThreadInfos,
RawThreadInfos,
RawThreadInfo,
LegacyRawThreadInfos,
LegacyRawThreadInfos,
LegacyRawThreadInfo,
$ReadOnlyArray<ClientThreadInconsistencyReportCreationRequest>,
> = Object.freeze({
fetch,
Expand All @@ -40,10 +40,10 @@ async function fetch(viewer: Viewer, ids?: $ReadOnlySet<string>) {
return result.threadInfos;
}

function getServerInfosHash(infos: RawThreadInfos) {
function getServerInfosHash(infos: LegacyRawThreadInfos) {
return combineUnorderedHashes(values(infos).map(getServerInfoHash));
}

function getServerInfoHash(info: RawThreadInfo) {
return hash(validateOutput(null, rawThreadInfoValidator, info));
function getServerInfoHash(info: LegacyRawThreadInfo) {
return hash(validateOutput(null, legacyRawThreadInfoValidator, info));
}
4 changes: 2 additions & 2 deletions keyserver/src/socket/socket.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ import {
serverSocketMessageTypes,
serverServerSocketMessageValidator,
} from 'lib/types/socket-types.js';
import type { RawThreadInfos } from 'lib/types/thread-types.js';
import type { LegacyRawThreadInfos } from 'lib/types/thread-types.js';
import type { UserInfo, CurrentUserInfo } from 'lib/types/user-types.js';
import { ServerError } from 'lib/utils/errors.js';
import { values } from 'lib/utils/objects.js';
Expand Down Expand Up @@ -515,7 +515,7 @@ class Socket {
);
// We have a type error here because Flow doesn't know spec.hashKey
const castPromises: {
+threadInfos: Promise<RawThreadInfos>,
+threadInfos: Promise<LegacyRawThreadInfos>,
+currentUserInfo: Promise<CurrentUserInfo>,
+entryInfos: Promise<$ReadOnlyArray<RawEntryInfo>>,
+userInfos: Promise<$ReadOnlyArray<UserInfo>>,
Expand Down
4 changes: 2 additions & 2 deletions lib/actions/user-actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ import type {
SubscriptionUpdateRequest,
SubscriptionUpdateResult,
} from '../types/subscription-types.js';
import type { RawThreadInfos } from '../types/thread-types';
import type { LegacyRawThreadInfos } from '../types/thread-types';
import type {
UserInfo,
PasswordUpdate,
Expand Down Expand Up @@ -264,7 +264,7 @@ const logIn =

const userInfosArrays = [];

let threadInfos: RawThreadInfos = {};
let threadInfos: LegacyRawThreadInfos = {};
const calendarResult: WritableCalendarResult = {
calendarQuery: logInInfo.calendarQuery,
rawEntryInfos: [],
Expand Down
4 changes: 2 additions & 2 deletions lib/hooks/child-threads.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import type {
MinimallyEncodedThreadInfo,
MinimallyEncodedRawThreadInfo,
} from '../types/minimally-encoded-thread-permissions-types.js';
import type { ThreadInfo, RawThreadInfo } from '../types/thread-types.js';
import type { ThreadInfo, LegacyRawThreadInfo } from '../types/thread-types.js';
import { useDispatchActionPromise } from '../utils/action-utils.js';
import { useSelector } from '../utils/redux-utils.js';

Expand Down Expand Up @@ -47,7 +47,7 @@ function useFilteredChildThreads(
(
thread: ?(
| ThreadInfo
| RawThreadInfo
| LegacyRawThreadInfo
| MinimallyEncodedThreadInfo
| MinimallyEncodedRawThreadInfo
),
Expand Down
4 changes: 2 additions & 2 deletions lib/hooks/search-threads.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import type {
import type {
SidebarInfo,
ThreadInfo,
RawThreadInfo,
LegacyRawThreadInfo,
} from '../types/thread-types.js';
import { useSelector } from '../utils/redux-utils.js';

Expand Down Expand Up @@ -110,7 +110,7 @@ function useSearchSubchannels(
(
thread: ?(
| ThreadInfo
| RawThreadInfo
| LegacyRawThreadInfo
| MinimallyEncodedThreadInfo
| MinimallyEncodedRawThreadInfo
),
Expand Down
10 changes: 5 additions & 5 deletions lib/ops/thread-store-ops.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import { type BaseStoreOpsHandlers } from './base-ops.js';
import type {
ClientDBThreadInfo,
RawThreadInfo,
RawThreadInfos,
LegacyRawThreadInfo,
LegacyRawThreadInfos,
ThreadStore,
} from '../types/thread-types.js';
import {
Expand All @@ -23,7 +23,7 @@ export type RemoveAllThreadsOperation = {

export type ReplaceThreadOperation = {
+type: 'replace',
+payload: { +id: string, +threadInfo: RawThreadInfo },
+payload: { +id: string, +threadInfo: LegacyRawThreadInfo },
};

export type ThreadStoreOperation =
Expand All @@ -45,7 +45,7 @@ export const threadStoreOpsHandlers: BaseStoreOpsHandlers<
ThreadStore,
ThreadStoreOperation,
ClientDBThreadStoreOperation,
RawThreadInfos,
LegacyRawThreadInfos,
ClientDBThreadInfo,
> = {
processStoreOperations(
Expand Down Expand Up @@ -87,7 +87,7 @@ export const threadStoreOpsHandlers: BaseStoreOpsHandlers<
},

translateClientDBData(data: $ReadOnlyArray<ClientDBThreadInfo>): {
+[id: string]: RawThreadInfo,
+[id: string]: LegacyRawThreadInfo,
} {
return Object.fromEntries(
data.map((dbThreadInfo: ClientDBThreadInfo) => [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

import type { MinimallyEncodedRawThreadInfo } from '../types/minimally-encoded-thread-permissions-types.js';
import { threadTypes } from '../types/thread-types-enum.js';
import type { RawThreadInfo } from '../types/thread-types.js';
import type { LegacyRawThreadInfo } from '../types/thread-types.js';

const exampleRawThreadInfoA: RawThreadInfo = {
const exampleRawThreadInfoA: LegacyRawThreadInfo = {
id: '85171',
type: threadTypes.PERSONAL,
name: '',
Expand Down Expand Up @@ -370,7 +370,7 @@ const exampleMinimallyEncodedRawThreadInfoA: MinimallyEncodedRawThreadInfo = {
pinnedCount: 0,
};

const expectedDecodedExampleRawThreadInfoA: RawThreadInfo = {
const expectedDecodedExampleRawThreadInfoA: LegacyRawThreadInfo = {
id: '85171',
type: threadTypes.PERSONAL,
name: '',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import type {
} from '../types/minimally-encoded-thread-permissions-types.js';
import {
legacyMemberInfoValidator,
rawThreadInfoValidator,
legacyRawThreadInfoValidator,
legacyRoleInfoValidator,
threadCurrentUserInfoValidator,
threadInfoValidator,
Expand Down Expand Up @@ -68,7 +68,7 @@ const minimallyEncodedResolvedThreadInfoValidator: TInterface<MinimallyEncodedRe

const minimallyEncodedRawThreadInfoValidator: TInterface<MinimallyEncodedRawThreadInfo> =
tShape<MinimallyEncodedRawThreadInfo>({
...rawThreadInfoValidator.meta.props,
...legacyRawThreadInfoValidator.meta.props,
minimallyEncoded: tBool(true),
members: t.list(minimallyEncodedMemberInfoValidator),
roles: t.dict(tID, minimallyEncodedRoleInfoValidator),
Expand Down
7 changes: 5 additions & 2 deletions lib/reducers/calendar-filters-reducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@ import {
fullStateSyncActionType,
incrementalStateSyncActionType,
} from '../types/socket-types.js';
import type { RawThreadInfos, ThreadStore } from '../types/thread-types.js';
import type {
LegacyRawThreadInfos,
ThreadStore,
} from '../types/thread-types.js';
import {
type ClientUpdateInfo,
processUpdatesActionType,
Expand Down Expand Up @@ -158,7 +161,7 @@ function updateFilterListFromUpdateInfos(

function removeDeletedThreadIDsFromFilterList(
state: $ReadOnlyArray<CalendarFilter>,
threadInfos: RawThreadInfos,
threadInfos: LegacyRawThreadInfos,
): $ReadOnlyArray<CalendarFilter> {
const currentlyFilteredIDs = filteredThreadIDs(state);
if (!currentlyFilteredIDs) {
Expand Down
6 changes: 3 additions & 3 deletions lib/reducers/entry-reducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ import {
fullStateSyncActionType,
incrementalStateSyncActionType,
} from '../types/socket-types.js';
import { type RawThreadInfos } from '../types/thread-types.js';
import { type LegacyRawThreadInfos } from '../types/thread-types.js';
import {
type ClientUpdateInfo,
processUpdatesActionType,
Expand Down Expand Up @@ -90,7 +90,7 @@ function mergeNewEntryInfos(
currentEntryInfos: { +[id: string]: RawEntryInfo },
currentDaysToEntries: ?{ +[day: string]: string[] },
newEntryInfos: $ReadOnlyArray<RawEntryInfo>,
threadInfos: RawThreadInfos,
threadInfos: LegacyRawThreadInfos,
) {
const mergedEntryInfos: { [string]: RawEntryInfo } = {};
let someEntryUpdated = false;
Expand Down Expand Up @@ -163,7 +163,7 @@ function mergeNewEntryInfos(
function reduceEntryInfos(
entryStore: EntryStore,
action: BaseAction,
newThreadInfos: RawThreadInfos,
newThreadInfos: LegacyRawThreadInfos,
): [EntryStore, $ReadOnlyArray<ClientEntryInconsistencyReportCreationRequest>] {
const { entryInfos, daysToEntries, lastUserInteractionCalendar } = entryStore;
if (
Expand Down
4 changes: 2 additions & 2 deletions lib/reducers/integrity-reducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ import type { ThreadStoreOperation } from '../ops/thread-store-ops';
import type { IntegrityStore } from '../types/integrity-types';
import type { BaseAction } from '../types/redux-types.js';
import { fullStateSyncActionType } from '../types/socket-types.js';
import type { RawThreadInfo } from '../types/thread-types.js';
import type { LegacyRawThreadInfo } from '../types/thread-types.js';
import { hash } from '../utils/objects.js';

function reduceIntegrityStore(
state: IntegrityStore,
action: BaseAction,
threadInfos: { +[string]: RawThreadInfo },
threadInfos: { +[string]: LegacyRawThreadInfo },
threadStoreOperations: $ReadOnlyArray<ThreadStoreOperation>,
): IntegrityStore {
if (
Expand Down
Loading

0 comments on commit 819fb9e

Please sign in to comment.