Rename the progress function to better reflect purpose
refactored registration code to remove the unneccesary lambda
This commit is contained in:
parent
55542a492e
commit
f54487c6cc
|
@ -586,7 +586,7 @@ void RealmClass<T>::wait_for_download_completion(ContextType ctx, FunctionType,
|
||||||
auto realm = realm::Realm::get_shared_realm(config);
|
auto realm = realm::Realm::get_shared_realm(config);
|
||||||
if (auto sync_config = config.sync_config)
|
if (auto sync_config = config.sync_config)
|
||||||
{
|
{
|
||||||
static const String progressFuncName = "_onProgress";
|
static const String progressFuncName = "_onDownloadProgress";
|
||||||
bool progressFuncDefined = false;
|
bool progressFuncDefined = false;
|
||||||
if (!Value::is_boolean(ctx, sync_config_value) && !Value::is_undefined(ctx, sync_config_value))
|
if (!Value::is_boolean(ctx, sync_config_value) && !Value::is_undefined(ctx, sync_config_value))
|
||||||
{
|
{
|
||||||
|
@ -615,12 +615,9 @@ void RealmClass<T>::wait_for_download_completion(ContextType ctx, FunctionType,
|
||||||
if (user && user->state() != SyncUser::State::Error) {
|
if (user && user->state() != SyncUser::State::Error) {
|
||||||
if (auto session = user->session_for_on_disk_path(config.path)) {
|
if (auto session = user->session_for_on_disk_path(config.path)) {
|
||||||
if (progressFuncDefined) {
|
if (progressFuncDefined) {
|
||||||
session->register_progress_notifier([=](uint64_t transferred_bytes, uint64_t transferrable_bytes) {
|
session->register_progress_notifier(std::move(progressFunc), SyncSession::NotifierType::download, false);
|
||||||
progressFunc(transferred_bytes, transferrable_bytes);
|
|
||||||
}, SyncSession::NotifierType::download, false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
session->wait_for_download_completion([=](std::error_code error_code) {
|
session->wait_for_download_completion([=](std::error_code error_code) {
|
||||||
realm->close(); //capture and keep realm instance for until here
|
realm->close(); //capture and keep realm instance for until here
|
||||||
waitFunc(error_code);
|
waitFunc(error_code);
|
||||||
|
|
|
@ -247,7 +247,7 @@ module.exports = {
|
||||||
sync: {
|
sync: {
|
||||||
user,
|
user,
|
||||||
url: `realm://localhost:9080/~/${realmName}`,
|
url: `realm://localhost:9080/~/${realmName}`,
|
||||||
_onProgress: (transferred, remaining) => {
|
_onDownloadProgress: (transferred, remaining) => {
|
||||||
progressNotificationCalled = true
|
progressNotificationCalled = true
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -279,7 +279,7 @@ module.exports = {
|
||||||
let progressNotificationCalled = false;
|
let progressNotificationCalled = false;
|
||||||
let config = {
|
let config = {
|
||||||
sync: { user, url: `realm://localhost:9080/~/${realmName}`,
|
sync: { user, url: `realm://localhost:9080/~/${realmName}`,
|
||||||
_onProgress: (transferred, remaining) => {
|
_onDownloadProgress: (transferred, remaining) => {
|
||||||
progressNotificationCalled = true
|
progressNotificationCalled = true
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue