Skip to content
This repository was archived by the owner on Jan 6, 2023. It is now read-only.

Introduce kinto #241

Merged
merged 133 commits into from
Oct 12, 2017
Merged

Introduce kinto #241

merged 133 commits into from
Oct 12, 2017

Conversation

glasserc
Copy link
Contributor

By popular request, an attempt to introduce kinto.js offline-first syncing to try to simplify conflict handling. This just uses the bog standard IndexedDB "storage adapter", which works fine in web extensions, and happens to have a cleaner implementation than browser.storage.local anyhow.

This PR is a bit of a mess since I just plopped a bunch of code into place, but some additional information is in the commit messages. I tried to at least mark the dangerous places with FIXMEs.

@vladikoff
Copy link
Contributor

awwww yessss

@@ -12,7 +12,7 @@ const timeouts = {};

// Kinto sync and encryption

const client = new KintoClient(KINTO_SERVER);
const client = new Kinto({remote: KINTO_SERVER, bucket: "default"});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should the bucket name be configurable?

Copy link
Contributor

@pdehaan pdehaan Sep 19, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, I think we need to convert from double quotes to single quotes and declare Kinto as a global to appease the ESLint gods:

/home/travis/build/mozilla/notes/src/background.js
  15:20  error    'Kinto' is not defined        no-undef
  15:57  error    Strings must use singlequote  quotes

UPDATE: You can fix the undefined Kinto global variable by adding it to ./eslintrc.yml (possibly replacing the KintoClient entry):

notes/.eslintrc.yml

Lines 9 to 14 in dca2e9c

globals:
KintoClient: false
Quill: false
Jose: false
JoseJWE: false
TestPilotGA: false

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think the bucket should be configurable. The default bucket is "API sugar" to allow each user to get their own bucket while still referring to them in a uniform way. It's the only one which behaves like this.

this.key = key;
}

async encode(record) {
Copy link
Contributor

@pdehaan pdehaan Sep 19, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think ESLint is choking here and failing to parse the entire file... Should this be async function encode(record) {?

/home/travis/build/mozilla/notes/src/sync.js
  63:9  error  Parsing error: Unexpected token encode

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, is it maybe the case that you guys stick to ES2015 on this project? Or which standard do you support? Per http://kangax.github.io/compat-table/es2016plus/#test-async_functions_async_methods,_classes, this syntax is supported in FF 52 ESR and greater, which is why it's used in the storage.sync implementation, which is why I copied and pasted it here 😊

return encryptedResult;
}

async decode(record) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here.. should this be async decode(record) {} or async function decode(record) {}?

src/sync.js Outdated
const notesIdSchema = {
// FIXME: Maybe this should generate IDs?
generate() {
throw new Error("cannot generate IDs");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Once the encode/decode issues are resolved below, I believe ESLint will start complaining about use of double quotes instead of single quotes here. Sorry.

src/sync.js Outdated
// headers (If-Match, If-None-Match) correctly.
// DON'T copy over "deleted" status, because then we'd leak
// plaintext deletes.
const status = record._status && (record._status == "deleted" ? "updated" : record._status);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: should use === instead.

src/sync.js Outdated
return syncResult;
})
.catch(error => {
if (error.response && error.response.status == 401) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: use === here.

@vladikoff
Copy link
Contributor

@glasserc @Natim Getting result is not defined on an existing account:

Will try a new account now

@vladikoff
Copy link
Contributor

Seems to be working for a new account!!!!

@vladikoff
Copy link
Contributor

@Natim Seems to working well, i think the biggest thing we need is handling merge conflicts.

There is some minor stuff such as the last sync time not updating:

I synced at :44 on the hour, but still said :41:

But that's small fish

@vladikoff
Copy link
Contributor

@Natim seems like after I close 2 profiles that I tested sync on and opened a 3rd profile I didn't get my notes back (got invalid date):

image

image

cedricium and others added 12 commits September 21, 2017 11:01
Menu implementation for fixing #208. This commit adds the
material-design-lite component library used for creating the menu and it's
menu items.
@Natim
Copy link
Collaborator

Natim commented Oct 10, 2017

First alpha version of the branch: addon-2.0.0a1.zip

@Natim
Copy link
Collaborator

Natim commented Oct 10, 2017

New version with QuillJS 1.3.3 addon-2.0.0a2.zip

@Natim Natim mentioned this pull request Oct 10, 2017
1 task
src/sync.js Outdated
@@ -91,6 +91,9 @@ class JWETransformer {
throw new Error('No ciphertext: nothing to decrypt?');
}

// FIXME: this is hack to work around a bug with FxA keys, which
// seem to have timestamps embedded in them that are affected by
// TZ offsets. Take out the substr calls once vladikoff says we can.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Rémy HUBSCHER and others added 5 commits October 10, 2017 16:41
Revert "Use mocha spec reporter.", moving from the karma spec reporter
back to the karma mocha reporter, just because it seems better
supported and is part of the example-webextension standard we're
trying to follow. Try to achieve the same effect using the built-in Karma
option reportSlowerThan -- set it to a generous 40ms.

This reverts commit 54299d2.
@@ -6,7 +6,7 @@ const TRACKING_ID = 'UA-35433268-79';
const KINTO_SERVER = 'https://kinto.dev.mozaws.net/v1';
// XXX: Read this from Kinto fxa-params
const FXA_CLIENT_ID = 'c6d74070a481bc10';
const FXA_OAUTH_SERVER = 'https://oauth-scoped-keys.dev.lcip.org/v1';
const FXA_OAUTH_SERVER = 'https://oauth-scoped-keys-oct10.dev.lcip.org/v1';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Natim @glasserc please update the kinto dev server to use this now. If this server is not working for you while I'm on PTO please rollback this commit :)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has the fixes to the kid and other stuff

@Natim
Copy link
Collaborator

Natim commented Oct 12, 2017

Since this PR is against sync-v4, I am going to land it and then we can keep improving sync-v4 branch until it is ready.

@Natim Natim merged commit 38f26b9 into mozilla:sync-v4 Oct 12, 2017
@glasserc glasserc deleted the introduce-kinto branch October 12, 2017 15:51
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.