Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3515293
D7938.id27298.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
3 KB
Referenced Files
None
Subscribers
None
D7938.id27298.diff
View Options
diff --git a/lib/ops/report-store-ops.js b/lib/ops/report-store-ops.js
--- a/lib/ops/report-store-ops.js
+++ b/lib/ops/report-store-ops.js
@@ -96,9 +96,16 @@
});
}
+function convertClientDBReportToClientReportCreationRequest(
+ reports: $ReadOnlyArray<ClientDBReport>,
+): $ReadOnlyArray<ClientReportCreationRequest> {
+ return reports.map(reportRecord => JSON.parse(reportRecord.report));
+}
+
export {
processReportStoreOperations,
convertReportsToReplaceReportOps,
convertReportsToRemoveReportsOperation,
convertReportStoreOperationToClientDBReportStoreOperation,
+ convertClientDBReportToClientReportCreationRequest,
};
diff --git a/lib/reducers/message-reducer.test.js b/lib/reducers/message-reducer.test.js
--- a/lib/reducers/message-reducer.test.js
+++ b/lib/reducers/message-reducer.test.js
@@ -292,6 +292,7 @@
},
messageStoreThreads: [],
messages: clientDBMessages,
+ reports: [],
},
},
{
diff --git a/lib/reducers/report-store-reducer.js b/lib/reducers/report-store-reducer.js
--- a/lib/reducers/report-store-reducer.js
+++ b/lib/reducers/report-store-reducer.js
@@ -1,5 +1,6 @@
// @flow
+import { setClientDBStoreActionType } from '../actions/client-db-store-actions.js';
import {
sendReportActionTypes,
sendReportsActionTypes,
@@ -143,6 +144,30 @@
},
reportStoreOperations,
};
+ } else if (action.type === setClientDBStoreActionType) {
+ const { reports } = action.payload;
+ if (!reports) {
+ return {
+ reportStore: state,
+ reportStoreOperations: [],
+ };
+ }
+ const reportStoreOperations: $ReadOnlyArray<ReportStoreOperation> = [
+ {
+ type: 'remove_all_reports',
+ },
+ ...convertReportsToReplaceReportOps(reports),
+ ];
+
+ const queuedReports = processReportStoreOperations(
+ state.queuedReports,
+ reportStoreOperations,
+ );
+
+ return {
+ reportStore: { ...state, queuedReports },
+ reportStoreOperations: [],
+ };
}
if (newReports) {
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
@@ -76,6 +76,7 @@
ClearDeliveredReportsPayload,
QueueReportsPayload,
ReportStore,
+ ClientReportCreationRequest,
} from './report-types.js';
import type {
ProcessServerRequestsPayload,
@@ -632,6 +633,7 @@
+messages: ?$ReadOnlyArray<ClientDBMessageInfo>,
+threadStore: ?ThreadStore,
+messageStoreThreads: ?$ReadOnlyArray<ClientDBThreadMessageInfo>,
+ +reports: ?$ReadOnlyArray<ClientReportCreationRequest>,
},
}
| {
diff --git a/native/data/sqlite-data-handler.js b/native/data/sqlite-data-handler.js
--- a/native/data/sqlite-data-handler.js
+++ b/native/data/sqlite-data-handler.js
@@ -6,6 +6,7 @@
import { setClientDBStoreActionType } from 'lib/actions/client-db-store-actions.js';
import { MediaCacheContext } from 'lib/components/media-cache-provider.react.js';
+import { convertClientDBReportToClientReportCreationRequest } from 'lib/ops/report-store-ops.js';
import { isLoggedIn } from 'lib/selectors/user-selectors.js';
import {
logInActionSources,
@@ -157,10 +158,13 @@
mediaCacheContext?.evictCache(),
]);
try {
- const { threads, messages, drafts, messageStoreThreads } =
+ const { threads, messages, drafts, messageStoreThreads, reports } =
await commCoreModule.getClientDBStore();
const threadInfosFromDB =
convertClientDBThreadInfosToRawThreadInfos(threads);
+ const reportsFromDb =
+ convertClientDBReportToClientReportCreationRequest(reports);
+
dispatch({
type: setClientDBStoreActionType,
payload: {
@@ -169,6 +173,7 @@
threadStore: { threadInfos: threadInfosFromDB },
currentUserID: currentLoggedInUserID,
messageStoreThreads,
+ reports: reportsFromDb,
},
});
} catch (setStoreException) {
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Dec 23, 8:21 AM (18 h, 26 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2694118
Default Alt Text
D7938.id27298.diff (3 KB)
Attached To
Mode
D7938: [native] fetch reports from SQLite and dispatch to store
Attached
Detach File
Event Timeline
Log In to Comment