diff --git a/keyserver/src/responders/redux-state-responders.js b/keyserver/src/responders/redux-state-responders.js --- a/keyserver/src/responders/redux-state-responders.js +++ b/keyserver/src/responders/redux-state-responders.js @@ -27,6 +27,7 @@ messageStoreValidator, type MessageStore, } from 'lib/types/message-types.js'; +import { webNavInfoValidator } from 'lib/types/nav-types.js'; import { threadPermissions } from 'lib/types/thread-permission-types.js'; import { threadTypes } from 'lib/types/thread-types-enum.js'; import { type ThreadStore } from 'lib/types/thread-types.js'; @@ -40,7 +41,6 @@ import { promiseAll } from 'lib/utils/promises.js'; import { urlInfoValidator } from 'lib/utils/url-utils.js'; import { tShape, ashoatKeyserverID, tID } from 'lib/utils/validation-utils.js'; -import { webNavInfoValidator } from 'web/types/nav-types.js'; import type { InitialReduxStateResponse, InitialKeyserverInfo, diff --git a/lib/types/nav-types.js b/lib/types/nav-types.js --- a/lib/types/nav-types.js +++ b/lib/types/nav-types.js @@ -1,7 +1,13 @@ // @flow +import type { TEnums, TInterface } from 'tcomb'; import t from 'tcomb'; -import type { TEnums } from 'tcomb'; + +import type { ThreadInfo } from './minimally-encoded-thread-permissions-types.js'; +import type { AccountUserInfo } from './user-types.js'; +import { accountUserInfoValidator } from './user-types.js'; +import { threadInfoValidator } from '../permissions/minimally-encoded-thread-permissions-validators.js'; +import { tID, tShape } from '../utils/validation-utils.js'; export type BaseNavInfo = { +startDate: string, @@ -34,3 +40,28 @@ 'view', 'create', ]); +export type WebNavInfo = { + ...$Exact, + +tab: WebNavigationTab, + +activeChatThreadID: ?string, + +pendingThread?: ThreadInfo, + +settingsSection?: WebNavigationSettingsSection, + +selectedUserList?: $ReadOnlyArray, + +chatMode?: WebNavigationChatMode, + +inviteSecret?: ?string, + +loginMethod?: WebLoginMethod, +}; +export const webNavInfoValidator: TInterface = tShape< + $Exact, +>({ + startDate: t.String, + endDate: t.String, + tab: webNavigationTabValidator, + activeChatThreadID: t.maybe(tID), + pendingThread: t.maybe(threadInfoValidator), + settingsSection: t.maybe(webNavigationSettingsSectionValidator), + selectedUserList: t.maybe(t.list(accountUserInfoValidator)), + chatMode: t.maybe(webNavigationChatModeValidator), + inviteSecret: t.maybe(t.String), + loginMethod: t.maybe(webLoginMethodValidator), +}); diff --git a/web/app.react.js b/web/app.react.js --- a/web/app.react.js +++ b/web/app.react.js @@ -28,6 +28,7 @@ import { extractMajorDesktopVersion } from 'lib/shared/version-utils.js'; import { TunnelbrokerProvider } from 'lib/tunnelbroker/tunnelbroker-context.js'; import type { LoadingStatus } from 'lib/types/loading-types.js'; +import type { WebNavInfo } from 'lib/types/nav-types.js'; import type { Dispatch } from 'lib/types/redux-types.js'; import { getConfig, registerConfig } from 'lib/utils/config.js'; import { useDispatch } from 'lib/utils/redux-utils.js'; @@ -73,7 +74,6 @@ import './typography.css'; import css from './style.css'; import { TooltipProvider } from './tooltips/tooltip-provider.js'; -import { type WebNavInfo } from './types/nav-types.js'; import { canonicalURLFromReduxState, navInfoFromURL } from './url-utils.js'; void initOpaque(); diff --git a/web/calendar/calendar.react.js b/web/calendar/calendar.react.js --- a/web/calendar/calendar.react.js +++ b/web/calendar/calendar.react.js @@ -18,6 +18,7 @@ type CalendarQueryUpdateResult, type CalendarQueryUpdateStartingPayload, } from 'lib/types/entry-types.js'; +import type { WebNavInfo } from 'lib/types/nav-types.js'; import { getDate, dateString, @@ -38,7 +39,6 @@ monthAssertingSelector, webCalendarQuery, } from '../selectors/nav-selectors.js'; -import type { WebNavInfo } from '../types/nav-types.js'; import { canonicalURLFromReduxState } from '../url-utils.js'; type StartAndEndDates = { diff --git a/web/redux/nav-reducer.js b/web/redux/nav-reducer.js --- a/web/redux/nav-reducer.js +++ b/web/redux/nav-reducer.js @@ -2,11 +2,11 @@ import { pendingToRealizedThreadIDsSelector } from 'lib/selectors/thread-selectors.js'; import { threadIsPending } from 'lib/shared/thread-utils.js'; +import type { WebNavInfo } from 'lib/types/nav-types.js'; import type { RawThreadInfos } from 'lib/types/thread-types.js'; import { updateNavInfoActionType } from '../redux/action-types.js'; import type { Action } from '../redux/redux-setup.js'; -import { type WebNavInfo } from '../types/nav-types.js'; export default function reduceNavInfo( oldState: WebNavInfo, diff --git a/web/redux/redux-setup.js b/web/redux/redux-setup.js --- a/web/redux/redux-setup.js +++ b/web/redux/redux-setup.js @@ -29,6 +29,7 @@ import type { InviteLinksStore } from 'lib/types/link-types.js'; import type { LoadingStatus } from 'lib/types/loading-types.js'; import type { MessageStore } from 'lib/types/message-types.js'; +import type { WebNavInfo } from 'lib/types/nav-types.js'; import type { UserPolicies } from 'lib/types/policy-types.js'; import type { BaseAction } from 'lib/types/redux-types.js'; import type { ReportStore } from 'lib/types/report-types.js'; @@ -53,7 +54,6 @@ import { getVisibility } from './visibility.js'; import { processDBStoreOperations } from '../database/utils/store.js'; import { activeThreadSelector } from '../selectors/nav-selectors.js'; -import { type WebNavInfo } from '../types/nav-types.js'; import type { InitialReduxState } from '../types/redux-types.js'; export type WindowDimensions = { width: number, height: number }; diff --git a/web/types/nav-types.js b/web/types/nav-types.js deleted file mode 100644 --- a/web/types/nav-types.js +++ /dev/null @@ -1,50 +0,0 @@ -// @flow - -import type { TInterface } from 'tcomb'; -import t from 'tcomb'; - -import { threadInfoValidator } from 'lib/permissions/minimally-encoded-thread-permissions-validators.js'; -import type { ThreadInfo } from 'lib/types/minimally-encoded-thread-permissions-types.js'; -import { - type BaseNavInfo, - type WebLoginMethod, - type WebNavigationChatMode, - type WebNavigationSettingsSection, - type WebNavigationTab, - webLoginMethodValidator, - webNavigationChatModeValidator, - webNavigationSettingsSectionValidator, - webNavigationTabValidator, -} from 'lib/types/nav-types.js'; -import { - type AccountUserInfo, - accountUserInfoValidator, -} from 'lib/types/user-types.js'; -import { tID, tShape } from 'lib/utils/validation-utils.js'; - -export type WebNavInfo = { - ...$Exact, - +tab: WebNavigationTab, - +activeChatThreadID: ?string, - +pendingThread?: ThreadInfo, - +settingsSection?: WebNavigationSettingsSection, - +selectedUserList?: $ReadOnlyArray, - +chatMode?: WebNavigationChatMode, - +inviteSecret?: ?string, - +loginMethod?: WebLoginMethod, -}; - -export const webNavInfoValidator: TInterface = tShape< - $Exact, ->({ - startDate: t.String, - endDate: t.String, - tab: webNavigationTabValidator, - activeChatThreadID: t.maybe(tID), - pendingThread: t.maybe(threadInfoValidator), - settingsSection: t.maybe(webNavigationSettingsSectionValidator), - selectedUserList: t.maybe(t.list(accountUserInfoValidator)), - chatMode: t.maybe(webNavigationChatModeValidator), - inviteSecret: t.maybe(t.String), - loginMethod: t.maybe(webLoginMethodValidator), -}); diff --git a/web/types/redux-types.js b/web/types/redux-types.js --- a/web/types/redux-types.js +++ b/web/types/redux-types.js @@ -3,12 +3,11 @@ import type { EntryStore, CalendarQuery } from 'lib/types/entry-types.js'; import type { InviteLinksStore } from 'lib/types/link-types.js'; import type { MessageStore } from 'lib/types/message-types.js'; +import type { WebNavInfo } from 'lib/types/nav-types.js'; import type { LegacyThreadStore, ThreadStore } from 'lib/types/thread-types.js'; import type { CurrentUserInfo, UserInfos } from 'lib/types/user-types.js'; import type { URLInfo } from 'lib/utils/url-utils.js'; -import type { WebNavInfo } from '../types/nav-types.js'; - export type InitialReduxStateResponse = { +navInfo: WebNavInfo, +currentUserInfo: CurrentUserInfo, diff --git a/web/url-utils.js b/web/url-utils.js --- a/web/url-utils.js +++ b/web/url-utils.js @@ -3,6 +3,7 @@ import invariant from 'invariant'; import _keyBy from 'lodash/fp/keyBy.js'; +import type { WebNavInfo } from 'lib/types/nav-types.js'; import type { AccountUserInfo } from 'lib/types/user-types.js'; import { startDateForYearAndMonth, @@ -11,7 +12,6 @@ import { infoFromURL, type URLInfo } from 'lib/utils/url-utils.js'; import { yearExtractor, monthExtractor } from './selectors/nav-selectors.js'; -import type { WebNavInfo } from './types/nav-types.js'; function canonicalURLFromReduxState( navInfo: WebNavInfo,