Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3339877
D13133.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
19 KB
Referenced Files
None
Subscribers
None
D13133.diff
View Options
diff --git a/native/cpp/CommonCpp/DatabaseManagers/DatabaseQueryExecutor.h b/native/cpp/CommonCpp/DatabaseManagers/DatabaseQueryExecutor.h
--- a/native/cpp/CommonCpp/DatabaseManagers/DatabaseQueryExecutor.h
+++ b/native/cpp/CommonCpp/DatabaseManagers/DatabaseQueryExecutor.h
@@ -41,7 +41,7 @@
virtual void removeAllDrafts() const = 0;
virtual void removeDrafts(const std::vector<std::string> &ids) const = 0;
virtual void removeAllMessages() const = 0;
- virtual std::vector<MessageEntity> getAllMessages() const = 0;
+ virtual std::vector<MessageEntity> getInitialMessages() const = 0;
virtual void removeMessages(const std::vector<std::string> &ids) const = 0;
virtual void
removeMessagesForThreads(const std::vector<std::string> &threadIDs) const = 0;
@@ -189,7 +189,7 @@
#ifdef EMSCRIPTEN
virtual std::vector<WebThread> getAllThreadsWeb() const = 0;
virtual void replaceThreadWeb(const WebThread &thread) const = 0;
- virtual std::vector<MessageWithMedias> getAllMessagesWeb() const = 0;
+ virtual std::vector<MessageWithMedias> getInitialMessagesWeb() const = 0;
virtual void replaceMessageWeb(const WebMessage &message) const = 0;
virtual NullableString getOlmPersistAccountDataWeb(int accountID) const = 0;
virtual std::vector<MessageWithMedias>
diff --git a/native/cpp/CommonCpp/DatabaseManagers/SQLiteQueryExecutor.h b/native/cpp/CommonCpp/DatabaseManagers/SQLiteQueryExecutor.h
--- a/native/cpp/CommonCpp/DatabaseManagers/SQLiteQueryExecutor.h
+++ b/native/cpp/CommonCpp/DatabaseManagers/SQLiteQueryExecutor.h
@@ -63,7 +63,7 @@
void removeAllDrafts() const override;
void removeDrafts(const std::vector<std::string> &ids) const override;
void removeAllMessages() const override;
- std::vector<MessageEntity> getAllMessages() const override;
+ std::vector<MessageEntity> getInitialMessages() const override;
void removeMessages(const std::vector<std::string> &ids) const override;
void removeMessagesForThreads(
const std::vector<std::string> &threadIDs) const override;
@@ -203,7 +203,7 @@
#ifdef EMSCRIPTEN
std::vector<WebThread> getAllThreadsWeb() const override;
void replaceThreadWeb(const WebThread &thread) const override;
- std::vector<MessageWithMedias> getAllMessagesWeb() const override;
+ std::vector<MessageWithMedias> getInitialMessagesWeb() const override;
void replaceMessageWeb(const WebMessage &message) const override;
NullableString getOlmPersistAccountDataWeb(int accountID) const override;
std::vector<MessageWithMedias>
diff --git a/native/cpp/CommonCpp/DatabaseManagers/SQLiteQueryExecutor.cpp b/native/cpp/CommonCpp/DatabaseManagers/SQLiteQueryExecutor.cpp
--- a/native/cpp/CommonCpp/DatabaseManagers/SQLiteQueryExecutor.cpp
+++ b/native/cpp/CommonCpp/DatabaseManagers/SQLiteQueryExecutor.cpp
@@ -1491,8 +1491,8 @@
removeAllEntities(SQLiteQueryExecutor::getConnection(), removeAllMessagesSQL);
}
-std::vector<MessageEntity> SQLiteQueryExecutor::getAllMessages() const {
- static std::string getAllMessagesSQL =
+std::vector<MessageEntity> SQLiteQueryExecutor::getInitialMessages() const {
+ static std::string getInitialMessagesSQL =
"SELECT * "
"FROM messages "
"LEFT JOIN media "
@@ -1500,31 +1500,31 @@
"ORDER BY messages.id;";
SQLiteStatementWrapper preparedSQL(
SQLiteQueryExecutor::getConnection(),
- getAllMessagesSQL,
- "Failed to retrieve all messages.");
+ getInitialMessagesSQL,
+ "Failed to retrieve initial messages.");
return this->processMessagesResults(preparedSQL);
}
std::vector<MessageEntity> SQLiteQueryExecutor::processMessagesResults(
SQLiteStatementWrapper &preparedSQL) const {
std::string prevMsgIdx{};
- std::vector<MessageEntity> allMessages;
+ std::vector<MessageEntity> messages;
for (int stepResult = sqlite3_step(preparedSQL); stepResult == SQLITE_ROW;
stepResult = sqlite3_step(preparedSQL)) {
Message message = Message::fromSQLResult(preparedSQL, 0);
if (message.id == prevMsgIdx) {
- allMessages.back().second.push_back(Media::fromSQLResult(preparedSQL, 9));
+ messages.back().second.push_back(Media::fromSQLResult(preparedSQL, 9));
} else {
prevMsgIdx = message.id;
std::vector<Media> mediaForMsg;
if (sqlite3_column_type(preparedSQL, 9) != SQLITE_NULL) {
mediaForMsg.push_back(Media::fromSQLResult(preparedSQL, 9));
}
- allMessages.push_back(std::make_pair(std::move(message), mediaForMsg));
+ messages.push_back(std::make_pair(std::move(message), mediaForMsg));
}
}
- return allMessages;
+ return messages;
}
void SQLiteQueryExecutor::removeMessages(
@@ -2797,16 +2797,17 @@
this->replaceThread(thread.toThread());
};
-std::vector<MessageWithMedias> SQLiteQueryExecutor::getAllMessagesWeb() const {
- auto allMessages = this->getAllMessages();
+std::vector<MessageWithMedias>
+SQLiteQueryExecutor::getInitialMessagesWeb() const {
+ auto messages = this->getInitialMessages();
- std::vector<MessageWithMedias> allMessageWithMedias;
- for (auto &messageWithMedia : allMessages) {
- allMessageWithMedias.push_back(
+ std::vector<MessageWithMedias> messageWithMedias;
+ for (auto &messageWithMedia : messages) {
+ messageWithMedias.push_back(
{std::move(messageWithMedia.first), messageWithMedia.second});
}
- return allMessageWithMedias;
+ return messageWithMedias;
}
void SQLiteQueryExecutor::replaceMessageWeb(const WebMessage &message) const {
diff --git a/native/cpp/CommonCpp/NativeModules/CommCoreModule.h b/native/cpp/CommonCpp/NativeModules/CommCoreModule.h
--- a/native/cpp/CommonCpp/NativeModules/CommCoreModule.h
+++ b/native/cpp/CommonCpp/NativeModules/CommCoreModule.h
@@ -73,7 +73,7 @@
moveDraft(jsi::Runtime &rt, jsi::String oldKey, jsi::String newKey) override;
virtual jsi::Value getClientDBStore(jsi::Runtime &rt) override;
virtual jsi::Value removeAllDrafts(jsi::Runtime &rt) override;
- virtual jsi::Array getAllMessagesSync(jsi::Runtime &rt) override;
+ virtual jsi::Array getInitialMessagesSync(jsi::Runtime &rt) override;
virtual void processReportStoreOperationsSync(
jsi::Runtime &rt,
jsi::Array operations) override;
diff --git a/native/cpp/CommonCpp/NativeModules/CommCoreModule.cpp b/native/cpp/CommonCpp/NativeModules/CommCoreModule.cpp
--- a/native/cpp/CommonCpp/NativeModules/CommCoreModule.cpp
+++ b/native/cpp/CommonCpp/NativeModules/CommCoreModule.cpp
@@ -129,7 +129,7 @@
try {
draftsVector = DatabaseManager::getQueryExecutor().getAllDrafts();
messagesVector =
- DatabaseManager::getQueryExecutor().getAllMessages();
+ DatabaseManager::getQueryExecutor().getInitialMessages();
threadsVector = DatabaseManager::getQueryExecutor().getAllThreads();
messageStoreThreadsVector =
DatabaseManager::getQueryExecutor().getAllMessageStoreThreads();
@@ -317,11 +317,11 @@
});
}
-jsi::Array CommCoreModule::getAllMessagesSync(jsi::Runtime &rt) {
+jsi::Array CommCoreModule::getInitialMessagesSync(jsi::Runtime &rt) {
auto messagesVector =
NativeModuleUtils::runSyncOrThrowJSError<std::vector<MessageEntity>>(
rt, []() {
- return DatabaseManager::getQueryExecutor().getAllMessages();
+ return DatabaseManager::getQueryExecutor().getInitialMessages();
});
auto messagesVectorPtr =
std::make_shared<std::vector<MessageEntity>>(std::move(messagesVector));
diff --git a/native/cpp/CommonCpp/_generated/commJSI-generated.cpp b/native/cpp/CommonCpp/_generated/commJSI-generated.cpp
--- a/native/cpp/CommonCpp/_generated/commJSI-generated.cpp
+++ b/native/cpp/CommonCpp/_generated/commJSI-generated.cpp
@@ -27,8 +27,8 @@
static jsi::Value __hostFunction_CommCoreModuleSchemaCxxSpecJSI_removeAllDrafts(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
return static_cast<CommCoreModuleSchemaCxxSpecJSI *>(&turboModule)->removeAllDrafts(rt);
}
-static jsi::Value __hostFunction_CommCoreModuleSchemaCxxSpecJSI_getAllMessagesSync(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
- return static_cast<CommCoreModuleSchemaCxxSpecJSI *>(&turboModule)->getAllMessagesSync(rt);
+static jsi::Value __hostFunction_CommCoreModuleSchemaCxxSpecJSI_getInitialMessagesSync(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
+ return static_cast<CommCoreModuleSchemaCxxSpecJSI *>(&turboModule)->getInitialMessagesSync(rt);
}
static jsi::Value __hostFunction_CommCoreModuleSchemaCxxSpecJSI_processMessageStoreOperationsSync(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
static_cast<CommCoreModuleSchemaCxxSpecJSI *>(&turboModule)->processMessageStoreOperationsSync(rt, args[0].asObject(rt).asArray(rt));
@@ -243,7 +243,7 @@
methodMap_["moveDraft"] = MethodMetadata {2, __hostFunction_CommCoreModuleSchemaCxxSpecJSI_moveDraft};
methodMap_["getClientDBStore"] = MethodMetadata {0, __hostFunction_CommCoreModuleSchemaCxxSpecJSI_getClientDBStore};
methodMap_["removeAllDrafts"] = MethodMetadata {0, __hostFunction_CommCoreModuleSchemaCxxSpecJSI_removeAllDrafts};
- methodMap_["getAllMessagesSync"] = MethodMetadata {0, __hostFunction_CommCoreModuleSchemaCxxSpecJSI_getAllMessagesSync};
+ methodMap_["getInitialMessagesSync"] = MethodMetadata {0, __hostFunction_CommCoreModuleSchemaCxxSpecJSI_getInitialMessagesSync};
methodMap_["processMessageStoreOperationsSync"] = MethodMetadata {1, __hostFunction_CommCoreModuleSchemaCxxSpecJSI_processMessageStoreOperationsSync};
methodMap_["getAllThreadsSync"] = MethodMetadata {0, __hostFunction_CommCoreModuleSchemaCxxSpecJSI_getAllThreadsSync};
methodMap_["processReportStoreOperationsSync"] = MethodMetadata {1, __hostFunction_CommCoreModuleSchemaCxxSpecJSI_processReportStoreOperationsSync};
diff --git a/native/cpp/CommonCpp/_generated/commJSI.h b/native/cpp/CommonCpp/_generated/commJSI.h
--- a/native/cpp/CommonCpp/_generated/commJSI.h
+++ b/native/cpp/CommonCpp/_generated/commJSI.h
@@ -25,7 +25,7 @@
virtual jsi::Value moveDraft(jsi::Runtime &rt, jsi::String oldKey, jsi::String newKey) = 0;
virtual jsi::Value getClientDBStore(jsi::Runtime &rt) = 0;
virtual jsi::Value removeAllDrafts(jsi::Runtime &rt) = 0;
- virtual jsi::Array getAllMessagesSync(jsi::Runtime &rt) = 0;
+ virtual jsi::Array getInitialMessagesSync(jsi::Runtime &rt) = 0;
virtual void processMessageStoreOperationsSync(jsi::Runtime &rt, jsi::Array operations) = 0;
virtual jsi::Array getAllThreadsSync(jsi::Runtime &rt) = 0;
virtual void processReportStoreOperationsSync(jsi::Runtime &rt, jsi::Array operations) = 0;
@@ -153,13 +153,13 @@
return bridging::callFromJs<jsi::Value>(
rt, &T::removeAllDrafts, jsInvoker_, instance_);
}
- jsi::Array getAllMessagesSync(jsi::Runtime &rt) override {
+ jsi::Array getInitialMessagesSync(jsi::Runtime &rt) override {
static_assert(
- bridging::getParameterCount(&T::getAllMessagesSync) == 1,
- "Expected getAllMessagesSync(...) to have 1 parameters");
+ bridging::getParameterCount(&T::getInitialMessagesSync) == 1,
+ "Expected getInitialMessagesSync(...) to have 1 parameters");
return bridging::callFromJs<jsi::Array>(
- rt, &T::getAllMessagesSync, jsInvoker_, instance_);
+ rt, &T::getInitialMessagesSync, jsInvoker_, instance_);
}
void processMessageStoreOperationsSync(jsi::Runtime &rt, jsi::Array operations) override {
static_assert(
diff --git a/native/redux/persist.js b/native/redux/persist.js
--- a/native/redux/persist.js
+++ b/native/redux/persist.js
@@ -520,7 +520,7 @@
[36]: (state: AppState) => {
// 1. Get threads and messages from SQLite `threads` and `messages` tables.
const clientDBThreadInfos = commCoreModule.getAllThreadsSync();
- const clientDBMessageInfos = commCoreModule.getAllMessagesSync();
+ const clientDBMessageInfos = commCoreModule.getInitialMessagesSync();
// 2. Translate `ClientDBThreadInfo`s to `RawThreadInfo`s and
// `ClientDBMessageInfo`s to `RawMessageInfo`s.
@@ -1225,7 +1225,7 @@
return newState;
},
[70]: (state: any) => {
- const clientDBMessageInfos = commCoreModule.getAllMessagesSync();
+ const clientDBMessageInfos = commCoreModule.getInitialMessagesSync();
const unsupportedMessageIDsToRemove = clientDBMessageInfos
.filter(
message =>
diff --git a/native/redux/unshim-utils.js b/native/redux/unshim-utils.js
--- a/native/redux/unshim-utils.js
+++ b/native/redux/unshim-utils.js
@@ -24,7 +24,7 @@
handleMigrationFailure?: AppState => AppState,
): AppState {
// 1. Get messages from SQLite `messages` table.
- const clientDBMessageInfos = commCoreModule.getAllMessagesSync();
+ const clientDBMessageInfos = commCoreModule.getInitialMessagesSync();
// 2. Translate `ClientDBMessageInfo`s to `RawMessageInfo`s.
const rawMessageInfos = clientDBMessageInfos.map(
diff --git a/native/schema/CommCoreModuleSchema.js b/native/schema/CommCoreModuleSchema.js
--- a/native/schema/CommCoreModuleSchema.js
+++ b/native/schema/CommCoreModuleSchema.js
@@ -39,7 +39,7 @@
+moveDraft: (oldKey: string, newKey: string) => Promise<boolean>;
+getClientDBStore: () => Promise<ClientDBStore>;
+removeAllDrafts: () => Promise<void>;
- +getAllMessagesSync: () => $ReadOnlyArray<ClientDBMessageInfo>;
+ +getInitialMessagesSync: () => $ReadOnlyArray<ClientDBMessageInfo>;
+processMessageStoreOperationsSync: (
operations: $ReadOnlyArray<ClientDBMessageStoreOperation>,
) => void;
diff --git a/web/cpp/SQLiteQueryExecutorBindings.cpp b/web/cpp/SQLiteQueryExecutorBindings.cpp
--- a/web/cpp/SQLiteQueryExecutorBindings.cpp
+++ b/web/cpp/SQLiteQueryExecutorBindings.cpp
@@ -145,7 +145,7 @@
.function("getAllDrafts", &SQLiteQueryExecutor::getAllDrafts)
.function("removeAllDrafts", &SQLiteQueryExecutor::removeAllDrafts)
.function("removeDrafts", &SQLiteQueryExecutor::removeDrafts)
- .function("getAllMessagesWeb", &SQLiteQueryExecutor::getAllMessagesWeb)
+ .function("getInitialMessagesWeb", &SQLiteQueryExecutor::getInitialMessagesWeb)
.function("removeAllMessages", &SQLiteQueryExecutor::removeAllMessages)
.function("removeMessages", &SQLiteQueryExecutor::removeMessages)
.function(
diff --git a/web/shared-worker/_generated/comm_query_executor.wasm b/web/shared-worker/_generated/comm_query_executor.wasm
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000
GIT binary patch
literal 0
Hc$@<O00001
literal 0
Hc$@<O00001
diff --git a/web/shared-worker/queries/messages-and-media-queries.test.js b/web/shared-worker/queries/messages-and-media-queries.test.js
--- a/web/shared-worker/queries/messages-and-media-queries.test.js
+++ b/web/shared-worker/queries/messages-and-media-queries.test.js
@@ -90,7 +90,7 @@
});
it('should return all messages with media', () => {
- const allMessages = queryExecutor.getAllMessagesWeb();
+ const allMessages = queryExecutor.getInitialMessagesWeb();
expect(allMessages.length).toBe(3);
expect(allMessages[0].medias.length).toBe(2);
expect(allMessages[1].medias.length).toBe(0);
@@ -99,13 +99,13 @@
it('should remove all messages', () => {
queryExecutor.removeAllMessages();
- const allMessages = queryExecutor.getAllMessagesWeb();
+ const allMessages = queryExecutor.getInitialMessagesWeb();
expect(allMessages.length).toBe(0);
});
it('should remove all media', () => {
queryExecutor.removeAllMedia();
- const allMessages = queryExecutor.getAllMessagesWeb();
+ const allMessages = queryExecutor.getInitialMessagesWeb();
expect(allMessages[0].medias.length).toBe(0);
expect(allMessages[1].medias.length).toBe(0);
expect(allMessages[2].medias.length).toBe(0);
@@ -113,19 +113,19 @@
it('should remove all messages for threads', () => {
queryExecutor.removeMessagesForThreads(['1']);
- const allMessages = queryExecutor.getAllMessagesWeb();
+ const allMessages = queryExecutor.getInitialMessagesWeb();
expect(allMessages.length).toBe(1);
});
it('should remove all messages with ids', () => {
queryExecutor.removeMessages(['1']);
- const allMessages = queryExecutor.getAllMessagesWeb();
+ const allMessages = queryExecutor.getInitialMessagesWeb();
expect(allMessages.length).toBe(2);
});
it('should remove all media for message', () => {
queryExecutor.removeMediaForMessage('1');
- const allMessages = queryExecutor.getAllMessagesWeb();
+ const allMessages = queryExecutor.getInitialMessagesWeb();
expect(allMessages[0].medias.length).toBe(0);
expect(allMessages[1].medias.length).toBe(0);
expect(allMessages[2].medias.length).toBe(2);
@@ -133,7 +133,7 @@
it('should remove all media for messages', () => {
queryExecutor.removeMediaForMessages(['3']);
- const allMessages = queryExecutor.getAllMessagesWeb();
+ const allMessages = queryExecutor.getInitialMessagesWeb();
expect(allMessages[0].medias.length).toBe(2);
expect(allMessages[1].medias.length).toBe(0);
expect(allMessages[2].medias.length).toBe(0);
@@ -141,7 +141,7 @@
it('should remove all media for threads', () => {
queryExecutor.removeMediaForThreads(['2']);
- const allMessages = queryExecutor.getAllMessagesWeb();
+ const allMessages = queryExecutor.getInitialMessagesWeb();
expect(allMessages[0].medias.length).toBe(2);
expect(allMessages[1].medias.length).toBe(0);
expect(allMessages[2].medias.length).toBe(0);
@@ -149,7 +149,7 @@
it('should rekey media containers', () => {
queryExecutor.rekeyMediaContainers('1', '3');
- const allMessages = queryExecutor.getAllMessagesWeb();
+ const allMessages = queryExecutor.getInitialMessagesWeb();
expect(allMessages[0].medias.length).toBe(0);
expect(allMessages[1].medias.length).toBe(0);
expect(allMessages[2].medias.length).toBe(4);
@@ -157,7 +157,7 @@
it('should rekey message', () => {
queryExecutor.rekeyMessage('3', '2');
- const allMessages = queryExecutor.getAllMessagesWeb();
+ const allMessages = queryExecutor.getInitialMessagesWeb();
expect(allMessages.length).toBe(2);
const rekeyedMessage = allMessages.find(
messageWithMedia => messageWithMedia.message.id === '2',
@@ -166,7 +166,7 @@
});
it('should correctly handle nullable integer', () => {
- const allMessages = queryExecutor.getAllMessagesWeb();
+ const allMessages = queryExecutor.getInitialMessagesWeb();
const messageWithNullFutureType = allMessages.find(
messageWithMedia => messageWithMedia.message.id === '1',
);
diff --git a/web/shared-worker/types/sqlite-query-executor.js b/web/shared-worker/types/sqlite-query-executor.js
--- a/web/shared-worker/types/sqlite-query-executor.js
+++ b/web/shared-worker/types/sqlite-query-executor.js
@@ -62,7 +62,7 @@
removeAllDrafts(): void;
removeDrafts(ids: $ReadOnlyArray<string>): void;
- getAllMessagesWeb(): $ReadOnlyArray<MessageEntity>;
+ getInitialMessagesWeb(): $ReadOnlyArray<MessageEntity>;
removeAllMessages(): void;
removeMessages(ids: $ReadOnlyArray<string>): void;
removeMessagesForThreads(threadIDs: $ReadOnlyArray<string>): void;
diff --git a/web/shared-worker/worker/process-operations.js b/web/shared-worker/worker/process-operations.js
--- a/web/shared-worker/worker/process-operations.js
+++ b/web/shared-worker/worker/process-operations.js
@@ -623,7 +623,7 @@
return {
drafts: sqliteQueryExecutor.getAllDrafts(),
messages: sqliteQueryExecutor
- .getAllMessagesWeb()
+ .getInitialMessagesWeb()
.map(webMessageToClientDBMessageInfo),
threads: sqliteQueryExecutor
.getAllThreadsWeb()
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Nov 22, 9:01 PM (17 h, 26 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2564879
Default Alt Text
D13133.diff (19 KB)
Attached To
Mode
D13133: [native] Rename `getAllMessages` method
Attached
Detach File
Event Timeline
Log In to Comment