Page MenuHomePhabricator

D11553.id38779.diff
No OneTemporary

D11553.id38779.diff

diff --git a/lib/reducers/local-id-reducer.js b/lib/reducers/local-id-reducer.js
deleted file mode 100644
--- a/lib/reducers/local-id-reducer.js
+++ /dev/null
@@ -1,119 +0,0 @@
-// @flow
-
-import invariant from 'invariant';
-
-import { createLocalEntryActionType } from '../actions/entry-actions.js';
-import {
- sendTextMessageActionTypes,
- sendMultimediaMessageActionTypes,
- createLocalMessageActionType,
- processMessagesActionType,
- fetchMessagesBeforeCursorActionTypes,
- fetchMostRecentMessagesActionTypes,
- sendReactionMessageActionTypes,
-} from '../actions/message-actions.js';
-import { joinThreadActionTypes } from '../actions/thread-actions.js';
-import {
- numberFromLocalID,
- highestLocalIDSelector,
-} from '../selectors/local-id-selectors.js';
-import { updateSpecs } from '../shared/updates/update-specs.js';
-import type { RawMessageInfo } from '../types/message-types.js';
-import type { BaseAction } from '../types/redux-types.js';
-import { rehydrateActionType } from '../types/redux-types.js';
-import {
- fullStateSyncActionType,
- incrementalStateSyncActionType,
-} from '../types/socket-types.js';
-import {
- type ClientUpdateInfo,
- processUpdatesActionType,
-} from '../types/update-types.js';
-
-export default function reduceNextLocalID(
- state: number,
- action: BaseAction,
-): number {
- let newCandidate = null;
- if (action.type === rehydrateActionType) {
- newCandidate = highestLocalIDSelector(action.payload) + 1;
- if (
- action.payload &&
- action.payload.nextLocalID &&
- action.payload.nextLocalID > newCandidate
- ) {
- newCandidate = action.payload.nextLocalID;
- }
- } else if (
- action.type === sendTextMessageActionTypes.started ||
- action.type === sendMultimediaMessageActionTypes.started ||
- action.type === sendReactionMessageActionTypes.started ||
- action.type === createLocalEntryActionType ||
- action.type === createLocalMessageActionType
- ) {
- const { localID } = action.payload;
- invariant(localID, 'should be set');
- newCandidate = numberFromLocalID(localID) + 1;
- } else if (action.type === incrementalStateSyncActionType) {
- const messages = [
- ...action.payload.messagesResult.rawMessageInfos,
- ...getRawMessageInfosFromUpdates(action.payload.updatesResult.newUpdates),
- ];
- newCandidate = findHighestLocalID(messages) + 1;
- } else if (action.type === processUpdatesActionType) {
- const messages = getRawMessageInfosFromUpdates(
- action.payload.updatesResult.newUpdates,
- );
- newCandidate = findHighestLocalID(messages) + 1;
- } else if (
- action.type === fullStateSyncActionType ||
- action.type === processMessagesActionType
- ) {
- const messages = action.payload.messagesResult.rawMessageInfos;
- newCandidate = findHighestLocalID(messages) + 1;
- } else if (
- action.type === fetchMessagesBeforeCursorActionTypes.success ||
- action.type === fetchMostRecentMessagesActionTypes.success
- ) {
- const messages = action.payload.rawMessageInfos;
- newCandidate = findHighestLocalID(messages) + 1;
- } else if (action.type === joinThreadActionTypes.success) {
- const messages = [
- ...action.payload.rawMessageInfos,
- ...getRawMessageInfosFromUpdates(action.payload.updatesResult.newUpdates),
- ];
- newCandidate = findHighestLocalID(messages) + 1;
- }
- return newCandidate && newCandidate > state ? newCandidate : state;
-}
-
-function findHighestLocalID(
- rawMessageInfos: $ReadOnlyArray<RawMessageInfo>,
-): number {
- let oldestID = -1;
-
- for (const rawMessageInfo of rawMessageInfos) {
- if (!rawMessageInfo.localID) {
- continue;
- }
- const { localID } = rawMessageInfo;
- if (!localID) {
- continue;
- }
- const thisLocalID = numberFromLocalID(localID);
- if (thisLocalID > oldestID) {
- oldestID = thisLocalID;
- }
- }
-
- return oldestID;
-}
-
-function getRawMessageInfosFromUpdates(
- updates: $ReadOnlyArray<ClientUpdateInfo>,
-): RawMessageInfo[] {
- return updates
- .map(update => updateSpecs[update.type].getRawMessageInfos?.(update))
- .filter(Boolean)
- .flat();
-}
diff --git a/lib/reducers/master-reducer.js b/lib/reducers/master-reducer.js
--- a/lib/reducers/master-reducer.js
+++ b/lib/reducers/master-reducer.js
@@ -13,7 +13,6 @@
import reduceKeyserverStore from './keyserver-reducer.js';
import reduceLifecycleState from './lifecycle-state-reducer.js';
import { reduceLoadingStatuses } from './loading-reducer.js';
-import reduceNextLocalID from './local-id-reducer.js';
import { reduceMessageStore } from './message-reducer.js';
import reduceBaseNavInfo from './nav-reducer.js';
import { reduceNotifPermissionAlertInfo } from './notif-permission-alert-info-reducer.js';
@@ -199,7 +198,6 @@
lifecycleState: reduceLifecycleState(state.lifecycleState, action),
enabledApps: reduceEnabledApps(state.enabledApps, action),
reportStore,
- nextLocalID: reduceNextLocalID(state.nextLocalID, action),
dataLoaded: reduceDataLoaded(state.dataLoaded, action),
userPolicies: policiesReducer(state.userPolicies, action),
commServicesAccessToken: reduceServicesAccessToken(
diff --git a/lib/types/redux-types.js b/lib/types/redux-types.js
--- a/lib/types/redux-types.js
+++ b/lib/types/redux-types.js
@@ -151,7 +151,6 @@
+lifecycleState: LifecycleState,
+enabledApps: EnabledApps,
+reportStore: ReportStore,
- +nextLocalID: number,
+dataLoaded: boolean,
+userPolicies: UserPolicies,
+commServicesAccessToken: ?string,
diff --git a/lib/utils/reducers-utils.test.js b/lib/utils/reducers-utils.test.js
--- a/lib/utils/reducers-utils.test.js
+++ b/lib/utils/reducers-utils.test.js
@@ -58,7 +58,6 @@
},
queuedReports: [],
},
- nextLocalID: 0,
_persist: null,
userPolicies: {},
commServicesAccessToken: null,
@@ -99,7 +98,6 @@
systemTheme: null,
},
communityPickerStore: { chat: '256|1', calendar: '256|1' },
- nextLocalID: 9,
navInfo: {
activeChatThreadID: null,
startDate: '2023-02-02',
@@ -112,7 +110,6 @@
const nonUserSpecificFields = [
'globalThemeInfo',
'communityPickerStore',
- 'nextLocalID',
'navInfo',
];
diff --git a/native/redux/default-state.js b/native/redux/default-state.js
--- a/native/redux/default-state.js
+++ b/native/redux/default-state.js
@@ -55,7 +55,6 @@
},
queuedReports: [],
},
- nextLocalID: 0,
_persist: null,
dimensions: defaultDimensionsInfo,
connectivity: defaultConnectivityInfo,
diff --git a/native/redux/persist.js b/native/redux/persist.js
--- a/native/redux/persist.js
+++ b/native/redux/persist.js
@@ -1160,6 +1160,10 @@
}
return state;
},
+ [66]: (state: any) => {
+ const { nextLocalID, ...rest } = state;
+ return rest;
+ },
};
// After migration 31, we'll no longer want to persist `messageStore.messages`
@@ -1227,7 +1231,7 @@
storage: AsyncStorage,
blacklist: persistBlacklist,
debug: __DEV__,
- version: 65,
+ version: 66,
transforms: [
messageStoreMessagesBlocklistTransform,
reportStoreTransform,
diff --git a/native/redux/state-types.js b/native/redux/state-types.js
--- a/native/redux/state-types.js
+++ b/native/redux/state-types.js
@@ -35,7 +35,6 @@
'loadingStatuses',
'customServer',
'lifecycleState',
- 'nextLocalID',
'dimensions',
'connectivity',
'deviceCameraInfo',
@@ -63,7 +62,6 @@
+lifecycleState: LifecycleState,
+enabledApps: EnabledApps,
+reportStore: ReportStore,
- +nextLocalID: number,
+_persist: ?PersistState,
+dimensions: DimensionsInfo,
+connectivity: ConnectivityInfo,
diff --git a/web/redux/default-state.js b/web/redux/default-state.js
--- a/web/redux/default-state.js
+++ b/web/redux/default-state.js
@@ -56,7 +56,6 @@
},
queuedReports: [],
},
- nextLocalID: 0,
_persist: null,
userPolicies: {},
commServicesAccessToken: null,
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
@@ -81,7 +81,6 @@
'loadingStatuses',
'windowDimensions',
'lifecycleState',
- 'nextLocalID',
'windowActive',
'pushApiPublicKey',
'keyserverStore',
@@ -107,7 +106,6 @@
+lifecycleState: LifecycleState,
+enabledApps: EnabledApps,
+reportStore: ReportStore,
- +nextLocalID: number,
+dataLoaded: boolean,
+windowActive: boolean,
+userPolicies: UserPolicies,

File Metadata

Mime Type
text/plain
Expires
Mon, Nov 18, 2:22 AM (20 h, 26 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2532780
Default Alt Text
D11553.id38779.diff (8 KB)

Event Timeline