-
Notifications
You must be signed in to change notification settings - Fork 25
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
Update labels without refresh #165
Update labels without refresh #165
Conversation
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.
LGTM
export type simplifiedLabel = { | ||
name: string; | ||
color: string; | ||
}; | ||
|
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.
For another issue/PR: This would be good to resolve why we need Label vs SimplifiedLabel, it seems redundant to have both. #82
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.
Some initial review
this.simplifiedLabels = this.labels.map((label) => { | ||
return { | ||
name: label.getFormattedName(), | ||
color: label.color | ||
}; | ||
}); | ||
this.labelsSubject.next(this.simplifiedLabels); |
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 think at this point it is probably more efficient to just store getFormattedName()'s result as a property of Label instead of cloning the entire label.
We can still keep simplifiedLabel but make Label implement the type simplified label so this conversion will no longer be needed.
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 if I implemented the change requested here in the manner that was intended, but I made an attempt to do so, please let me know if I should make further changes
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.
See above (sorry accidentally commented instead of request change)
src/app/core/models/label.model.ts
Outdated
@@ -4,26 +4,27 @@ | |||
export class Label { |
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 meant by
export class Label { | |
export class Label implements SimplifiedLabel { |
This way Label is also a simplified label. So in service there is no need to convert the label array into simplified label array as label array is already a simplified label array.
Although we do need to rename the references to SimplifiedLabel from name to formattedName.
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.
Let's rename SimplifiedLabel -> SimpleLabel
So it makes sense for Label to implement SimpleLabel as a more complex label
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 see, that's a much better way of implementing SimplifiedLabel. I've made the changes as suggested in the most recent commits, and also renamed SimplifiedLabel -> SimpleLabel as mentioned.
I've also made some changes to accommodate #183 , as this PR modifies parts of the original label-filter-bar.component.ts
used in that PR.
I was looking through some of the other issues, and came across #117 , which brings up a good point, that WATcher users can afford to view non-updated data. As this PR already has the sync button also update the labels, which aligns with the suggestion in #117 (comment), should I change it so that the periodic polling of labels is removed, and the fetching of labels is restricted to just the sync button as mentioned in an earlier comment? While I think having periodic polling would be good to have, in my opinion, setting it to a long enough interval to prevent too many calls to fetch data would cause it to provide little benefit to the user, as they are unlikely to run into a situation where the refresh would be timely enough to update the data as they need it, and they could just use the sync button to refresh data. Also, since the issue concerning periodic label polling is similar to the issue brought up in #117 , should the same changes decided on here be applied to the issue polling? I think the sync button also fetches issues at the moment, so it would just be a matter of removing the polling at 5 second intervals, though the change should definitely be done in a separate PR addressing #117 directly. |
Perhaps we can make the polling an optional toggle somewhere on the page. |
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.
LGTM!
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.
LGTM
Update labels without needing to refresh Labels are only fetched on initialization, requiring users to refresh in order for labels to update. Let's change it so labels are updated periodically, and when the Sync button is clicked.
Summary:
Attempt to resolve #13
Labels are only fetched on initialization, which requires users to refresh the page in order for labels to update. Having labels update without requiring users to refresh would be ideal. The changes in this PR make it so that labels are polled and updated periodically, and also causes the Sync button to also update labels.
Currently polls label data at intervals of 5 seconds (the same
POLL_INTERVAL
as issues), however, as updates to labels are unlikely to occur as frequently as updates to issues, increasing the interval is probably a good idea to avoid excessive requests, as users can still use the Sync button if necessary.Type of change:
Changes Made:
-
label.service.ts
: added periodic polling and updating of label data-
label-filter-bar.component.ts
: use updatedlabel.service.ts
to support updating of label data, movedsimplifiedLabel
intolabel.service.ts
-
header-component.ts
: changedreload()
to also fetch label data-Handle setup/cleanup of
LabelService
where appropriateScreenshots:
Periodic polling:
Sync button (polling interval adjusted to 30 seconds for demonstration purposes):
Proposed Commit Message:
Checklist: