Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F32186645
D14865.1765085670.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
5 KB
Referenced Files
None
Subscribers
None
D14865.1765085670.diff
View Options
diff --git a/lib/ops/create-replace-thread-operation.js b/lib/ops/create-replace-thread-operation.js
--- a/lib/ops/create-replace-thread-operation.js
+++ b/lib/ops/create-replace-thread-operation.js
@@ -1,7 +1,7 @@
// @flow
import type { ReplaceThreadOperation } from './thread-store-ops.js';
-import { threadSpecs } from '../shared/threads/thread-specs.js';
+import { getDataIsBackedUpByThread } from '../shared/threads/protocols/thread-protocols.js';
import type { RawThreadInfo } from '../types/minimally-encoded-thread-permissions-types.js';
function createReplaceThreadOperation(
@@ -13,7 +13,7 @@
payload: {
id,
threadInfo,
- isBackedUp: threadSpecs[threadInfo.type].protocol.dataIsBackedUp,
+ isBackedUp: getDataIsBackedUpByThread(id, threadInfo),
},
};
}
diff --git a/lib/ops/entries-store-ops.js b/lib/ops/entries-store-ops.js
--- a/lib/ops/entries-store-ops.js
+++ b/lib/ops/entries-store-ops.js
@@ -2,7 +2,7 @@
import type { BaseStoreOpsHandlers } from './base-ops.js';
import { daysToEntriesFromEntryInfos } from '../reducers/entry-reducer.js';
-import { threadSpecs } from '../shared/threads/thread-specs.js';
+import { getDataIsBackedUpByThread } from '../shared/threads/protocols/thread-protocols.js';
import type {
EntryStore,
RawEntryInfo,
@@ -141,18 +141,12 @@
threadInfos: RawThreadInfos,
): ReplaceEntryOperation {
const threadInfo = threadInfos[entry.threadID];
- if (!threadInfo) {
- return {
- type: 'replace_entry',
- payload: { id, entry, isBackedUp: true },
- };
- }
return {
type: 'replace_entry',
payload: {
id,
entry,
- isBackedUp: threadSpecs[threadInfo.type].protocol.dataIsBackedUp,
+ isBackedUp: getDataIsBackedUpByThread(entry.threadID, threadInfo),
},
};
}
diff --git a/lib/ops/message-store-ops.js b/lib/ops/message-store-ops.js
--- a/lib/ops/message-store-ops.js
+++ b/lib/ops/message-store-ops.js
@@ -1,7 +1,7 @@
// @flow
import { type BaseStoreOpsHandlers } from './base-ops.js';
-import { threadSpecs } from '../shared/threads/thread-specs.js';
+import { getDataIsBackedUpByThread } from '../shared/threads/protocols/thread-protocols.js';
import type {
ClientDBMessageInfo,
ClientDBThreadMessageInfo,
@@ -265,18 +265,12 @@
threadInfos: MixedRawThreadInfos,
): ReplaceMessageOperation {
const threadInfo = threadInfos[messageInfo.threadID];
- if (!threadInfo) {
- return {
- type: 'replace',
- payload: { id, messageInfo, isBackedUp: true },
- };
- }
return {
type: 'replace',
payload: {
id,
messageInfo,
- isBackedUp: threadSpecs[threadInfo.type].protocol.dataIsBackedUp,
+ isBackedUp: getDataIsBackedUpByThread(messageInfo.threadID, threadInfo),
},
};
}
@@ -289,7 +283,7 @@
let notBackedUpThreads: MessageStoreThreads = {};
for (const threadID in threads) {
const threadInfo = threadInfos[threadID];
- if (!threadInfo || threadSpecs[threadInfo.type].protocol.dataIsBackedUp) {
+ if (getDataIsBackedUpByThread(threadID, threadInfo)) {
backedUpThreads = {
...backedUpThreads,
[threadID]: threads[threadID],
diff --git a/lib/ops/thread-activity-store-ops.js b/lib/ops/thread-activity-store-ops.js
--- a/lib/ops/thread-activity-store-ops.js
+++ b/lib/ops/thread-activity-store-ops.js
@@ -1,7 +1,7 @@
// @flow
import { type BaseStoreOpsHandlers } from './base-ops.js';
-import { threadSpecs } from '../shared/threads/thread-specs.js';
+import { getDataIsBackedUpByThread } from '../shared/threads/protocols/thread-protocols.js';
import type {
ThreadActivityStore,
ThreadActivityStoreEntry,
@@ -144,18 +144,12 @@
threadInfos: RawThreadInfos,
): ReplaceThreadActivityEntryOperation {
const threadInfo = threadInfos[id];
- if (!threadInfo) {
- return {
- type: 'replace_thread_activity_entry',
- payload: { id, threadActivityStoreEntry, isBackedUp: true },
- };
- }
return {
type: 'replace_thread_activity_entry',
payload: {
id,
threadActivityStoreEntry,
- isBackedUp: threadSpecs[threadInfo.type].protocol.dataIsBackedUp,
+ isBackedUp: getDataIsBackedUpByThread(id, threadInfo),
},
};
}
diff --git a/lib/shared/threads/protocols/thread-protocols.js b/lib/shared/threads/protocols/thread-protocols.js
--- a/lib/shared/threads/protocols/thread-protocols.js
+++ b/lib/shared/threads/protocols/thread-protocols.js
@@ -2,7 +2,10 @@
import { dmThreadProtocol } from './dm-thread-protocol.js';
import { keyserverThreadProtocol } from './keyserver-thread-protocol.js';
-import type { ThreadProtocol } from '../thread-spec.js';
+import type { RawThreadInfo } from '../../../types/minimally-encoded-thread-permissions-types.js';
+import { type LegacyRawThreadInfo } from '../../../types/thread-types.js';
+import { type ThreadProtocol } from '../thread-spec.js';
+import { threadSpecs } from '../thread-specs.js';
const protocols = (): $ReadOnlyArray<ThreadProtocol<any>> => [
dmThreadProtocol,
@@ -13,4 +16,14 @@
return protocols().find(p => p.threadIDMatchesProtocol(threadID));
}
-export { protocols, getProtocolByThreadID };
+function getDataIsBackedUpByThread(
+ threadID: string,
+ threadInfo: ?(LegacyRawThreadInfo | RawThreadInfo),
+): boolean {
+ if (threadInfo) {
+ return threadSpecs[threadInfo.type].protocol.dataIsBackedUp;
+ }
+ return !!getProtocolByThreadID(threadID)?.dataIsBackedUp;
+}
+
+export { protocols, getProtocolByThreadID, getDataIsBackedUpByThread };
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Dec 7, 5:34 AM (15 h, 38 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5842618
Default Alt Text
D14865.1765085670.diff (5 KB)
Attached To
Mode
D14865: [lib][web][native] extract code to check if `dataIsBackedUp`
Attached
Detach File
Event Timeline
Log In to Comment