Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3358367
D11680.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
D11680.diff
View Options
diff --git a/web/redux/persist.js b/web/redux/persist.js
--- a/web/redux/persist.js
+++ b/web/redux/persist.js
@@ -10,6 +10,7 @@
keyserverStoreOpsHandlers,
type ReplaceKeyserverOperation,
} from 'lib/ops/keyserver-store-ops.js';
+import type { ClientDBMessageStoreOperation } from 'lib/ops/message-store-ops.js';
import {
createAsyncMigrate,
type StorageMigrationFunction,
@@ -19,6 +20,8 @@
import { defaultAlertInfos } from 'lib/types/alert-types.js';
import { defaultCalendarQuery } from 'lib/types/entry-types.js';
import type { KeyserverInfo } from 'lib/types/keyserver-types.js';
+import { messageTypes } from 'lib/types/message-types-enum.js';
+import type { ClientDBMessageInfo } from 'lib/types/message-types.js';
import { cookieTypes } from 'lib/types/session-types.js';
import { defaultConnectionInfo } from 'lib/types/socket-types.js';
import { defaultGlobalThemeInfo } from 'lib/types/theme-types.js';
@@ -384,6 +387,58 @@
return newState;
},
+ [16]: async (state: AppState) => {
+ // 1. Check if `databaseModule` is supported and early-exit if not.
+ const sharedWorker = await getCommSharedWorker();
+ const isDatabaseSupported = await sharedWorker.isSupported();
+
+ if (!isDatabaseSupported) {
+ return state;
+ }
+
+ // 2. Get existing `stores` from SQLite.
+ const stores = await sharedWorker.schedule({
+ type: workerRequestMessageTypes.GET_CLIENT_STORE,
+ });
+
+ const messages: ?$ReadOnlyArray<ClientDBMessageInfo> =
+ stores?.store?.messages;
+
+ if (messages === null || messages === undefined || messages.length === 0) {
+ return state;
+ }
+
+ // 3. Filter out `UNSUPPORTED.UPDATE_RELATIONSHIP` `ClientDBMessageInfo`s.
+ const unsupportedMessageIDsToRemove = messages
+ .filter((message: ClientDBMessageInfo) => {
+ if (parseInt(message.type) !== messageTypes.UPDATE_RELATIONSHIP) {
+ return false;
+ }
+ if (message.content === null || message.content === undefined) {
+ return false;
+ }
+ const { operation } = JSON.parse(message.content);
+ return operation === 'farcaster_mutual';
+ })
+ .map(message => message.id);
+
+ // 4. Construct `ClientDBMessageStoreOperation`s
+ const messageStoreOperations: $ReadOnlyArray<ClientDBMessageStoreOperation> =
+ [
+ {
+ type: 'remove',
+ payload: { ids: unsupportedMessageIDsToRemove },
+ },
+ ];
+
+ // 5. Process the constructed `messageStoreOperations`.
+ await sharedWorker.schedule({
+ type: workerRequestMessageTypes.PROCESS_STORE_OPERATIONS,
+ storeOperations: { messageStoreOperations },
+ });
+
+ return state;
+ },
};
const migrateStorageToSQLite: StorageMigrationFunction = async debug => {
@@ -429,7 +484,7 @@
{ debug: isDev },
migrateStorageToSQLite,
): any),
- version: 15,
+ version: 16,
transforms: [messageStoreMessagesBlocklistTransform, keyserverStoreTransform],
};
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Nov 25, 4:26 AM (21 h, 25 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2578338
Default Alt Text
D11680.diff (2 KB)
Attached To
Mode
D11680: [web] Redux migration to clear `UNSUPPORTED<UPDATE_RELATIONSHIP>` messages
Attached
Detach File
Event Timeline
Log In to Comment