Skip to content

Commit

Permalink
[keyserver][lib][native][web] Remove connection field from redux
Browse files Browse the repository at this point in the history
Summary:
issue: https://linear.app/comm/issue/ENG-4460/refactor-connection-field
Last step is to remove now not used `connection` filed from top level of redux

Test Plan: ran `yarn flow-all`. checked that the migration was succesful.

Reviewers: michal, kamil

Reviewed By: michal

Subscribers: ashoat, tomek

Differential Revision: https://phab.comm.dev/D8932
  • Loading branch information
InkaAlicja committed Aug 25, 2023
1 parent e8fe68b commit 0012034
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 33 deletions.
18 changes: 0 additions & 18 deletions keyserver/src/responders/website-responders.js
Original file line number Diff line number Diff line change
Expand Up @@ -202,23 +202,6 @@ const initialReduxStateValidator = tShape({
'default notifPermissionAlertInfo',
_isEqual(defaultNotifPermissionAlertInfo),
),
connection: tShape({
status: tString('connecting'),
queuedActivityUpdates: t.irreducible(
'default queuedActivityUpdates',
_isEqual([]),
),
actualizedCalendarQuery: tShape({
startDate: t.String,
endDate: t.String,
filters: t.irreducible(
'default filters',
_isEqual(defaultCalendarFilters),
),
}),
lateResponses: t.irreducible('default lateResponses', _isEqual([])),
showDisconnectedBar: tBool(false),
}),
watchedThreadIDs: t.irreducible('default watchedThreadIDs', _isEqual([])),
lifecycleState: tString('active'),
enabledApps: t.irreducible(
Expand Down Expand Up @@ -602,7 +585,6 @@ async function websiteResponder(
communityPickerStore: { chat: null, calendar: null },
windowDimensions: { width: 0, height: 0 },
notifPermissionAlertInfo: defaultNotifPermissionAlertInfo,
connection: connectionPromise,
watchedThreadIDs: [],
lifecycleState: 'active',
enabledApps: defaultWebEnabledApps,
Expand Down
4 changes: 0 additions & 4 deletions lib/reducers/master-reducer.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// @flow

import reduceCalendarFilters from './calendar-filters-reducer.js';
import reduceConnectionInfo from './connection-reducer.js';
import reduceDataLoaded from './data-loaded-reducer.js';
import { reduceDeviceToken } from './device-token-reducer.js';
import { reduceDraftStore } from './draft-reducer.js';
Expand Down Expand Up @@ -59,8 +58,6 @@ export default function baseReducer<N: BaseNavInfo, T: BaseAppState<N>>(
reduceMessageStore(state.messageStore, action, threadInfos);
let messageStore = reducedMessageStore;

const connection = reduceConnectionInfo(state.connection, action);

let keyserverStore = reduceKeyserverStore(state.keyserverStore, action);

if (
Expand Down Expand Up @@ -131,7 +128,6 @@ export default function baseReducer<N: BaseNavInfo, T: BaseAppState<N>>(
state.notifPermissionAlertInfo,
action,
),
connection,
lifecycleState: reduceLifecycleState(state.lifecycleState, action),
enabledApps: reduceEnabledApps(state.enabledApps, action),
reportStore,
Expand Down
2 changes: 0 additions & 2 deletions lib/types/redux-types.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ import type {
} from './search-types.js';
import type { SetSessionPayload } from './session-types.js';
import type {
ConnectionInfo,
StateSyncFullActionPayload,
StateSyncIncrementalActionPayload,
UpdateConnectionStatusPayload,
Expand Down Expand Up @@ -127,7 +126,6 @@ export type BaseAppState<NavInfo: BaseNavInfo = BaseNavInfo> = {
+loadingStatuses: { [key: string]: { [idx: number]: LoadingStatus } },
+calendarFilters: $ReadOnlyArray<CalendarFilter>,
+notifPermissionAlertInfo: NotifPermissionAlertInfo,
+connection: ConnectionInfo,
+watchedThreadIDs: $ReadOnlyArray<string>,
+lifecycleState: LifecycleState,
+enabledApps: EnabledApps,
Expand Down
25 changes: 21 additions & 4 deletions native/redux/persist.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,14 +148,14 @@ const migrations = {
actualizedCalendarQuery: undefined,
},
}),
[9]: (state: AppState) => ({
[9]: state => ({
...state,
connection: {
...state.connection,
lateResponses: [],
},
}),
[10]: (state: AppState) => ({
[10]: state => ({
...state,
nextLocalID: highestLocalIDSelector(state) + 1,
connection: {
Expand Down Expand Up @@ -594,7 +594,7 @@ const migrations = {
}
return state;
},
[43]: async (state: AppState) => {
[43]: async state => {
const { messages, drafts, threads, messageStoreThreads } =
await commCoreModule.getClientDBStore();

Expand Down Expand Up @@ -699,6 +699,23 @@ const migrations = {
},
};
},
[48]: async state => {
const { connection, keyserverStore, ...rest } = state;

return {
...rest,
keyserverStore: {
...keyserverStore,
keyserverInfos: {
...keyserverStore.keyserverInfos,
[ashoatKeyserverID]: {
...keyserverStore.keyserverInfos[ashoatKeyserverID],
connection,
},
},
},
};
},
};

// After migration 31, we'll no longer want to persist `messageStore.messages`
Expand Down Expand Up @@ -793,7 +810,7 @@ const persistConfig = {
'storeLoaded',
],
debug: __DEV__,
version: 47,
version: 48,
transforms: [messageStoreMessagesBlocklistTransform, reportStoreTransform],
migrate: (createAsyncMigrate(migrations, { debug: __DEV__ }): any),
timeout: ((__DEV__ ? 0 : undefined): number | void),
Expand Down
1 change: 0 additions & 1 deletion native/redux/redux-setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ const defaultState = ({
dataLoaded: false,
customServer: natNodeServer,
notifPermissionAlertInfo: defaultNotifPermissionAlertInfo,
connection: defaultConnectionInfo(Platform.OS),
watchedThreadIDs: [],
lifecycleState: 'active',
enabledApps: defaultEnabledApps,
Expand Down
2 changes: 0 additions & 2 deletions native/redux/state-types.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import type { LoadingStatus } from 'lib/types/loading-types.js';
import type { MessageStore } from 'lib/types/message-types.js';
import type { UserPolicies } from 'lib/types/policy-types.js';
import type { ReportStore } from 'lib/types/report-types.js';
import type { ConnectionInfo } from 'lib/types/socket-types.js';
import type { ThreadStore } from 'lib/types/thread-types.js';
import type { CurrentUserInfo, UserStore } from 'lib/types/user-types.js';
import type { NotifPermissionAlertInfo } from 'lib/utils/push-alerts.js';
Expand All @@ -41,7 +40,6 @@ export type AppState = {
+dataLoaded: boolean,
+customServer: ?string,
+notifPermissionAlertInfo: NotifPermissionAlertInfo,
+connection: ConnectionInfo,
+watchedThreadIDs: $ReadOnlyArray<string>,
+lifecycleState: LifecycleState,
+enabledApps: EnabledApps,
Expand Down
2 changes: 0 additions & 2 deletions web/redux/redux-setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ import type { MessageStore } from 'lib/types/message-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';
import type { ConnectionInfo } from 'lib/types/socket-types.js';
import type { ThreadStore } from 'lib/types/thread-types.js';
import type { CurrentUserInfo, UserStore } from 'lib/types/user-types.js';
import { setNewSessionActionType } from 'lib/utils/action-utils.js';
Expand Down Expand Up @@ -82,7 +81,6 @@ export type AppState = {
+windowDimensions: WindowDimensions,
+deviceToken: ?string,
+notifPermissionAlertInfo: NotifPermissionAlertInfo,
+connection: ConnectionInfo,
+watchedThreadIDs: $ReadOnlyArray<string>,
+lifecycleState: LifecycleState,
+enabledApps: EnabledApps,
Expand Down

0 comments on commit 0012034

Please sign in to comment.