Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F32509557
D11680.1767108634.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
D11680.1767108634.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
Tue, Dec 30, 3:30 PM (18 h, 28 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5866808
Default Alt Text
D11680.1767108634.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