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 "announce" #899

Merged
merged 14 commits into from
Mar 15, 2017
Merged

ES6: Migrated "announce" #899

merged 14 commits into from
Mar 15, 2017

Conversation

bennycode
Copy link
Contributor

Type of change

Screenshot

constructor(announce_service) {
this.logger = new z.util.Logger('z.announce.AnnounceRepository', z.config.LOGGER.OPTIONS);
this.announce_service = announce_service;
return this;
Copy link
Contributor

Choose a reason for hiding this comment

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

think we dont need to return this or is it chained?

Copy link
Contributor

Choose a reason for hiding this comment

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

It is needed in TestAPI I believe

Copy link
Contributor

Choose a reason for hiding this comment

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

not sure

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 removed the this. It was there because otherwise CoffeeScript would return the last statement from the constructor (instead the instance of the class).

get_announcements() {
return new Promise((resolve, reject) => {
$.get(this.url).done((data) => {
resolve(data['result']);
Copy link
Contributor

@herrmannplatz herrmannplatz Mar 15, 2017

Choose a reason for hiding this comment

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

do we want to use fetch for this???

return fetch(this.url).then((response) => response.json()).then((json) => json.result)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

One thing at a time :D

Copy link
Contributor

Choose a reason for hiding this comment

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

means touching it twice

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Tests fail if I use return fetch(this.url).then((data) => data.result).

Copy link
Contributor

Choose a reason for hiding this comment

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

If there "easy" fixes we should do them in one go.. but of course if the tests fail and stuff then maybe have somewhere a list that we can track of the things that we spotted..

Copy link
Contributor

Choose a reason for hiding this comment

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

It's a good time to have a complete review of the codebase!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, I will see what I can do here...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

window.fetch returns a ReadableStream in data.body. So the code needs some adjustments.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Looks like it needs a reader: var reader = response.body.getReader(); (https://jakearchibald.com/2015/thats-so-fetch/)

Maybe we should use a wrapper which wraps the fetch API. Like: https://github.com/typicode/fetchival

Copy link
Contributor Author

@bennycode bennycode Mar 15, 2017

Choose a reason for hiding this comment

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

This seems to do the trick:

get_announcements() {
  return window.fetch(this.url).then((response) => response.json()).then((data) => data.result);
}

get_version() {
  return window.fetch('version/').then((response) => response.json()).then((data) => data.version);
}

@lipis lipis mentioned this pull request Mar 15, 2017
79 tasks
@bennycode bennycode merged commit 2e20f9d into dev Mar 15, 2017
@bennycode bennycode deleted the announce branch March 15, 2017 16:53
done()
.catch done.fail


Copy link
Contributor

@lipis lipis Mar 15, 2017

Choose a reason for hiding this comment

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

tsk tsk.. double empty line :)

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.

4 participants