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

Sync profile and apps #105

Open
wants to merge 143 commits into
base: master
Choose a base branch
from
Open

Sync profile and apps #105

wants to merge 143 commits into from

Conversation

G-Ray
Copy link
Contributor

@G-Ray G-Ray commented May 28, 2019

No description provided.

@G-Ray G-Ray force-pushed the sync-profile branch 4 times, most recently from f636a03 to 0085be8 Compare July 11, 2019 14:39
src/lib/masq.js Outdated Show resolved Hide resolved
const { dbExists } = common.utils
const { genAESKey, exportKey } = common.crypto

const waitForSync = async (db1, db2) => {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

A function similar to this one could help us detect if a DB is synced with another one. We will move this to another file


// register current device if it does not exist
const device = await this.getDevice()
if (!device) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

TODO: move this to a function. This should add the device once and for all, for each new device


await new Promise((resolve) => { setTimeout(resolve, 5000) })

expect(masq.appsDBs['app2' + '-copy']._authorized).to.have.lengthOf(2)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this copy things need to be refactored

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 it's that bad as it's only in the context of the tests. We absolutely need to replicate data between two different Indexeddb databases

src/lib/masq.js Outdated Show resolved Hide resolved
src/lib/masq.js Outdated Show resolved Hide resolved
src/lib/masq.js Outdated Show resolved Hide resolved
src/lib/masq.js Outdated Show resolved Hide resolved
src/lib/sync-profile.js Outdated Show resolved Hide resolved
src/lib/sync-profile.js Outdated Show resolved Hide resolved

data = await waitForDataFromPeer(this.peer)
const { msg, id, key, publicProfile } = await decryptJSON(data, this.key)
debug('pullProfile received', msg, id, key)
Copy link
Collaborator

Choose a reason for hiding this comment

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

isn't it 'pullProfile' that is received ?

Copy link
Contributor Author

@G-Ray G-Ray Aug 6, 2019

Choose a reason for hiding this comment

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

I meant "pullProfile received" like "pullProfile (the function's name) received: [the message]"

const { msg: msg2, key } = await decryptJSON(data, this.key)
debug('pushProfile received', msg2, key)

if (!key || msg2 !== 'requestWriteAccess') throw new Error('msg not expected' + msg2)
Copy link
Collaborator

Choose a reason for hiding this comment

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

more specific error should be used

Copy link
Contributor Author

Choose a reason for hiding this comment

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

what would you prefer ?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Specify the context e.g. function and message expected

src/lib/sync-profile.js Outdated Show resolved Hide resolved
src/lib/sync-profile.js Outdated Show resolved Hide resolved
test/masq.test.js Outdated Show resolved Hide resolved
test/masq.test.js Show resolved Hide resolved
test/sync-profile.test.js Outdated Show resolved Hide resolved
test/sync-profile.test.js Show resolved Hide resolved
@G-Ray G-Ray force-pushed the sync-profile branch 8 times, most recently from c8108d4 to fa1c71b Compare August 7, 2019 15:28
@G-Ray G-Ray changed the title Sync profile Sync profile and apps Aug 12, 2019
@G-Ray G-Ray force-pushed the sync-profile branch 2 times, most recently from 5997c0e to 715d502 Compare August 14, 2019 15:03
@G-Ray G-Ray force-pushed the sync-profile branch 5 times, most recently from 1958e83 to 8030338 Compare August 23, 2019 12:58
@G-Ray G-Ray marked this pull request as ready for review August 26, 2019 15:29
G-Ray and others added 30 commits October 10, 2019 17:49
* add promise timeout method

* Close sw if user click on close modal or click outside modal

* Add getter for this.sw

* Update call to joinSecureChannel with timeout + custom error message

* Increase timeout delay

* Remove setstate, message will eventually be updated with the default case

* Remove getSW, not needed

* Update translations

* Transform QRCOdeModal into class component

* Small refactor
* Improve modals responsiveness

* Handle scanner error with an error msg

* Add translations

* Sync: remove extra spaces

* Modal: Different padding on mobile and desktop

* Card: remove width

* Update fr.json
* Add migration from version alpha to 0.16

    In the old version of masq alpha, the device entry in the profile
    db did not contain the apps info after an activation with maps.
    We therefore add :
    - _checkversion during openProfile
    - _addVersion for addProfile
    - _migration in case we need it

* update .env

* fix missing await for _addVersion

* update device entry with apps in a generic way

* rm old code before refactor

* Move migration to a specific file + according changes

* Fix import

* Rm check getDevice (already done in openProfile)
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.

None yet

3 participants