Files
mattermost-mobile/patches/@nozbe+watermelondb+0.24.0.patch
Daniel Espino García 684d9421a7 Add sample test for local actions (#5945)
* Add sample test for local actions

* Fix the tests and add all missing tests

* Address feedback

* Sort imports

Co-authored-by: Elias Nahum <nahumhbl@gmail.com>
2022-03-02 09:36:10 -03:00

158 lines
6.8 KiB
Diff

diff --git a/node_modules/@nozbe/watermelondb/Database/index.js b/node_modules/@nozbe/watermelondb/Database/index.js
index 8d71c6f..9ad75d6 100644
--- a/node_modules/@nozbe/watermelondb/Database/index.js
+++ b/node_modules/@nozbe/watermelondb/Database/index.js
@@ -126,6 +126,10 @@ var Database = /*#__PURE__*/function () {
// subsequent changes to the record don't trip up the invariant
// TODO: What if this fails?
record._preparedState = null;
+
+ if ('update' === preparedState) {
+ record.__original = null;
+ }
}
if (!changeNotifications[table]) {
diff --git a/node_modules/@nozbe/watermelondb/Model/index.d.ts b/node_modules/@nozbe/watermelondb/Model/index.d.ts
index 1a7c99e..0cb7b87 100644
--- a/node_modules/@nozbe/watermelondb/Model/index.d.ts
+++ b/node_modules/@nozbe/watermelondb/Model/index.d.ts
@@ -44,6 +44,8 @@ declare module '@nozbe/watermelondb/Model' {
public update(recordUpdater?: (record: this) => void): Promise<this>
+ public cancelPrepareUpdate(): void;
+
public prepareUpdate(recordUpdater?: (record: this) => void): this
public markAsDeleted(): Promise<void>
diff --git a/node_modules/@nozbe/watermelondb/Model/index.js b/node_modules/@nozbe/watermelondb/Model/index.js
index 075a047..5af3995 100644
--- a/node_modules/@nozbe/watermelondb/Model/index.js
+++ b/node_modules/@nozbe/watermelondb/Model/index.js
@@ -78,6 +78,18 @@ var Model = /*#__PURE__*/function () {
// database.batch()
;
+ _proto.cancelPrepareUpdate = function cancelPrepareUpdate() {
+ if ('test' !== process.env.NODE_ENV && 'undefined' !== typeof process && process) {
+ (0, _invariant.default)('update' !== _this._preparedState, "Cannot cancel an update on a model that has not been prepared");
+ }
+ this.__changes = null;
+ this._preparedState = null;
+ if (this.__original) {
+ this._raw = this.__original;
+ }
+ this.__original = undefined;
+ }
+
_proto.prepareUpdate = function prepareUpdate(recordUpdater = _noop.default) {
var _this = this;
@@ -92,6 +104,7 @@ var Model = /*#__PURE__*/function () {
} // Perform updates
+ this.__original = Object.assign({}, this._raw);
(0, _ensureSync.default)(recordUpdater(this));
this._isEditing = false;
this._preparedState = 'update'; // TODO: `process.nextTick` doesn't work on React Native
diff --git a/node_modules/@nozbe/watermelondb/WatermelonDB.podspec b/node_modules/@nozbe/watermelondb/WatermelonDB.podspec
index 1f3af50..e9fea58 100644
--- a/node_modules/@nozbe/watermelondb/WatermelonDB.podspec
+++ b/node_modules/@nozbe/watermelondb/WatermelonDB.podspec
@@ -13,7 +13,10 @@ Pod::Spec.new do |s|
s.platforms = { :ios => "9.0", :tvos => "9.0" }
s.source = { :git => "https://github.com/Nozbe/WatermelonDB.git", :tag => "v#{s.version}" }
s.source_files = "native/ios/**/*.{h,m,mm,swift,c,cpp}", "native/shared/**/*.{h,c,cpp}"
- s.public_header_files = 'native/ios/WatermelonDB/SupportingFiles/Bridging.h'
+ s.public_header_files = [
+ 'native/ios/WatermelonDB/SupportingFiles/Bridging.h',
+ 'native/ios/WatermelonDB/JSIInstaller.h',
+ ]
s.requires_arc = true
# simdjson is annoyingly slow without compiler optimization, disable for debugging
s.compiler_flags = '-Os'
diff --git a/node_modules/@nozbe/watermelondb/native/android/src/main/java/com/nozbe/watermelondb/Database.kt b/node_modules/@nozbe/watermelondb/native/android/src/main/java/com/nozbe/watermelondb/Database.kt
index ca31e20..b45c753 100644
--- a/node_modules/@nozbe/watermelondb/native/android/src/main/java/com/nozbe/watermelondb/Database.kt
+++ b/node_modules/@nozbe/watermelondb/native/android/src/main/java/com/nozbe/watermelondb/Database.kt
@@ -22,6 +22,21 @@ class Database(
if (name == ":memory:" || name.contains("mode=memory")) {
context.cacheDir.delete()
File(context.cacheDir, name).path
+ } else if (name.contains("/") || name.contains("file")) {
+ // Extracts the database name from the path
+ val dbName = name.substringAfterLast("/")
+
+ // Extracts the real path where the *.db file will be created
+ val truePath = name.substringAfterLast("file://").substringBeforeLast("/")
+
+ // Creates the directory
+ if (!truePath.contains("databases")) {
+ val fileObj = File(truePath, "databases")
+ fileObj.mkdir()
+ File("${truePath}/databases", dbName).path
+ } else {
+ File(truePath, dbName).path
+ }
} else {
// On some systems there is some kind of lock on `/databases` folder ¯\_(ツ)_/¯
context.getDatabasePath("$name.db").path.replace("/databases", "")
diff --git a/node_modules/@nozbe/watermelondb/native/ios/WatermelonDB/SupportingFiles/Bridging.h b/node_modules/@nozbe/watermelondb/native/ios/WatermelonDB/SupportingFiles/Bridging.h
index 135118d..8324550 100644
--- a/node_modules/@nozbe/watermelondb/native/ios/WatermelonDB/SupportingFiles/Bridging.h
+++ b/node_modules/@nozbe/watermelondb/native/ios/WatermelonDB/SupportingFiles/Bridging.h
@@ -6,12 +6,6 @@
#import <React/RCTBridgeModule.h>
-#if __has_include("JSIInstaller.h")
-#import "JSIInstaller.h"
-#else
-#import "../JSIInstaller.h"
-#endif
-
#if __has_include("DatabaseDeleteHelper.h")
#import "DatabaseDeleteHelper.h"
#else
diff --git a/node_modules/@nozbe/watermelondb/native/shared/Database.cpp b/node_modules/@nozbe/watermelondb/native/shared/Database.cpp
index a2bd410..44e1a58 100644
--- a/node_modules/@nozbe/watermelondb/native/shared/Database.cpp
+++ b/node_modules/@nozbe/watermelondb/native/shared/Database.cpp
@@ -54,6 +54,7 @@ void Database::destroy() {
const std::lock_guard<std::mutex> lock(mutex_);
if (isDestroyed_) {
+ db_->markAsDestroyed();
return;
}
isDestroyed_ = true;
diff --git a/node_modules/@nozbe/watermelondb/native/shared/Sqlite.cpp b/node_modules/@nozbe/watermelondb/native/shared/Sqlite.cpp
index 4108e6c..0fa554c 100644
--- a/node_modules/@nozbe/watermelondb/native/shared/Sqlite.cpp
+++ b/node_modules/@nozbe/watermelondb/native/shared/Sqlite.cpp
@@ -69,6 +69,10 @@ void SqliteDb::destroy() {
}
}
+void SqliteDb::markAsDestroyed() {
+ isDestroyed_ = true;
+}
+
SqliteDb::~SqliteDb() {
destroy();
}
diff --git a/node_modules/@nozbe/watermelondb/native/shared/Sqlite.h b/node_modules/@nozbe/watermelondb/native/shared/Sqlite.h
index 22cffa7..4b74a7f 100644
--- a/node_modules/@nozbe/watermelondb/native/shared/Sqlite.h
+++ b/node_modules/@nozbe/watermelondb/native/shared/Sqlite.h
@@ -11,6 +11,7 @@ public:
SqliteDb(std::string path);
~SqliteDb();
void destroy();
+ void markAsDestroyed();
sqlite3 *sqlite;