Closed
Bug 1448143
Opened 7 years ago
Closed 7 years ago
Factor out a size getter from DownloadsViewUI.jsm so other consumers can access it
Categories
(Firefox :: New Tab Page, enhancement, P1)
Tracking
()
| Tracking | Status | |
|---|---|---|
| firefox61 | --- | fixed |
People
(Reporter: ursula, Assigned: ursula)
References
Details
Attachments
(1 file)
This will make it easier for Activity stream's downloaded items in highlights to get the "description" of the download. Or else I'd have to re-implement this function to get the size
| Assignee | ||
Updated•7 years ago
|
Severity: normal → enhancement
Iteration: --- → 61.1 - Mar 26
Priority: -- → P1
| Comment hidden (mozreview-request) |
Comment 2•7 years ago
|
||
| mozreview-review | ||
Comment on attachment 8961528 [details]
Bug 1448143 - Factor out a size getter from DownloadsViewUI.jsm so other consumers can access it
https://reviewboard.mozilla.org/r/230318/#review235898
::: browser/components/downloads/DownloadsViewUI.jsm:272
(Diff revision 1)
> stateLabel = s.fileMovedOrMissing;
> hoverStatus = stateLabel;
> } else if (this.download.succeeded) {
> - // For completed downloads, show the file size (e.g. "1.5 MB").
> - if (this.download.target.size !== undefined) {
> - let [size, unit] =
> + // For completed downloads, show the file size
> + stateLabel = this.size.stateLabel;
> + status = this.size.status;
This is going to cause the `size` getter to run twice. You could avoid it with:
({stateLabel, status} = this.size);
Or if you want to avoid the ()s, have .size return a pair/array similar to how `convertByteUnits` returns an array, then `[stateLabel, status] = this.size`;
Comment 3•7 years ago
|
||
Or just save it locally first
let size = this.size;
Although looking closer, perhaps the getter should be named sizeStrings? Or something else? Odd that there's status for a "size"
| Comment hidden (mozreview-request) |
| Assignee | ||
Comment 5•7 years ago
|
||
Yeah `sizeStrings` is a better name. Changed the name, and saved it to a variables locally first.
Comment 6•7 years ago
|
||
| mozreview-review | ||
Comment on attachment 8961528 [details]
Bug 1448143 - Factor out a size getter from DownloadsViewUI.jsm so other consumers can access it
https://reviewboard.mozilla.org/r/230318/#review236190
::: browser/components/downloads/DownloadsViewUI.jsm:122
(Diff revision 2)
> + */
> + get sizeStrings() {
> + let s = DownloadsCommon.strings;
> + let sizeStrings = {};
> +
> + if (this.download.target.size) {
I believe the !== undefined is to guard against a 0 size, which is a valid size
Attachment #8961528 -
Flags: review?(edilee) → review+
| Comment hidden (mozreview-request) |
Pushed by usarracini@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/15b7991887bc
Factor out a size getter from DownloadsViewUI.jsm so other consumers can access it r=Mardak
Comment 9•7 years ago
|
||
| bugherder | ||
Status: NEW → RESOLVED
Closed: 7 years ago
status-firefox61:
--- → fixed
Resolution: --- → FIXED
Target Milestone: --- → Firefox 61
Updated•6 years ago
|
Component: Activity Streams: Newtab → New Tab Page
You need to log in
before you can comment on or make changes to this bug.
Description
•