-
Notifications
You must be signed in to change notification settings - Fork 292
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
Conversation
constructor(announce_service) { | ||
this.logger = new z.util.Logger('z.announce.AnnounceRepository', z.config.LOGGER.OPTIONS); | ||
this.announce_service = announce_service; | ||
return this; |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure
There was a problem hiding this comment.
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']); |
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
means touching it twice
There was a problem hiding this comment.
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)
.
There was a problem hiding this comment.
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..
There was a problem hiding this comment.
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!
There was a problem hiding this comment.
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...
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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);
}
done() | ||
.catch done.fail | ||
|
||
|
There was a problem hiding this comment.
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 :)
Type of change
Screenshot