Skip to content
This repository has been archived by the owner on Sep 16, 2020. It is now read-only.

Synchronize function does not works everytime. #67

Open
stripathix opened this issue Aug 6, 2018 · 1 comment
Open

Synchronize function does not works everytime. #67

stripathix opened this issue Aug 6, 2018 · 1 comment

Comments

@stripathix
Copy link

Test Case:

Step 1) In chrome, I update the record of dataset then do synchronize() which gives Success
Step 2) Go to firefox and synchronize() there also Success is called.

Now in firefox I have the latest record that was updated in step (1).

On repeating the above steps multiple time, step(2) stops getting latest record updated in step (1) even when onSuccess is still called for firefox step(2).

Note: To resolve conflict I use deviceLastModifiedDate. Whichever is latest I use that.

`
bnUserPreferencesDataset.synchronize({onSuccess: function () {

                contents.fillDatasetMap();
            }, onConflict: function (dataset, conflicts, callback) {
                var resolved = [];
                var i = 0;
                while (i < conflicts.length) {
                    if (conflicts[i].localRecord.deviceLastModifiedDate > conflicts[i].remoteRecord.deviceLastModifiedDate) {
                        resolved.push(conflicts[i].resolveWithLocalRecord());
                    } else {
                        resolved.push(conflicts[i].resolveWithRemoteRecord());
                    }
                    i += 1;
                }
                if (resolved.length) {
                    dataset.resolve(resolved, function (err) {
                        if (err) {
                            return callback(false);
                        }
                        return callback(true);
                    });
                }
            }, onFailure: function (err) {
                console.log(err);
            }});`
@stripathix
Copy link
Author

stripathix commented Aug 6, 2018

I have a record name favoriteView and I believe if I change the value of this record in chrome then on doing synchronize() in firefox I should get conflict because value of favoriteView in Firefox is different. But this does not happen always. Sometimes it works but after 3-4 attempts sync always calls onSuccess and keeps getting old records.

I have to refresh to get the latest records.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant