Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ES6: migrated "connect" #1030

Merged
merged 2 commits into from
Apr 7, 2017
Merged

ES6: migrated "connect" #1030

merged 2 commits into from
Apr 7, 2017

Conversation

gregor
Copy link
Contributor

@gregor gregor commented Apr 7, 2017

No description provided.

}).catch((error) => {
return this.logger.error(`Failed to import contacts from Google: ${error.message}`, error);
});
}
Copy link
Contributor

Choose a reason for hiding this comment

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

get_contacts() {
 return this._init_library()
  .then(() => this._get_access_token())
  .then((access_token) => this._get_contacts(access_token))
  .catch((error) => {
   return this.logger.error(`Failed to import contacts from Google: ${error.message}`, error);
 });
}


this.logger.info('Lazy loading Google Auth API');
let script_node = document.createElement('script');
script_node.src = 'https://apis.google.com/js/auth.js?onload=gapi_loaded';
Copy link
Contributor

Choose a reason for hiding this comment

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

const

return new Promise((resolve, reject) => {
this.logger.info('Fetching address book from Google');
let api_endpoint = 'https://www.google.com/m8/feeds/contacts/default/full';
return $.get(`${api_endpoint}?access_token=${access_token}&alt=json&max-results=15000&v=3.0`)
Copy link
Contributor

Choose a reason for hiding this comment

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

const

Copy link
Contributor

Choose a reason for hiding this comment

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

we should use fetch for this at some point

return new Promise((resolve, reject) => {
if (window.gapi.auth) {
let auth_token = window.gapi.auth.getToken();
if (auth_token) {
Copy link
Contributor

Choose a reason for hiding this comment

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

const

}
return this._load_library();
}

Copy link
Contributor

Choose a reason for hiding this comment

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

return window.gapi ? Promise().resolve() : this._load_library()

maybe

this.logger.info('Google Contacts SDK error', error);
throw new z.connect.ConnectError(z.connect.ConnectError.prototype.TYPE.GOOGLE_DOWNLOAD);
}).then((response) => {
amplify.publish(z.event.WebApp.SEARCH.SHOW);
Copy link
Contributor

Choose a reason for hiding this comment

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

then on a new line

this.logger.warn('No contacts found for upload');
throw new z.connect.ConnectError(z.connect.ConnectError.prototype.TYPE.NO_CONTACTS);
} else {
this.logger.info(`Uploading hashes of '${phone_book.cards.length}' contacts for matching`, phone_book);
Copy link
Contributor

Choose a reason for hiding this comment

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

now else

return resolve(undefined);
}
let address_book = window.wAddressBook;
let phone_book = new z.connect.PhoneBook(this.properties_repository.self());
Copy link
Contributor

Choose a reason for hiding this comment

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

const

@gregor gregor force-pushed the decaffeinate-connect branch 9 times, most recently from f6e4e5f to bdfe2fa Compare April 7, 2017 14:13
@gregor gregor force-pushed the decaffeinate-connect branch from bdfe2fa to aff38e2 Compare April 7, 2017 14:24
@gregor gregor merged commit 89f2cef into dev Apr 7, 2017
@gregor gregor deleted the decaffeinate-connect branch April 7, 2017 15:39
@lipis lipis mentioned this pull request Apr 7, 2017
79 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants