Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
The Tor Project
Applications
android-components
Commits
91bc4f13
Commit
91bc4f13
authored
Oct 16, 2019
by
Christian Sadilek
Browse files
Closes #2923: Remove moment.js from reader view web extension
parent
3bb3548e
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
components/feature/readerview/src/main/assets/extensions/readerview/manifest.json
View file @
91bc4f13
...
...
@@ -5,7 +5,7 @@
"content_scripts"
:
[
{
"matches"
:
[
"*://*/*"
],
"js"
:
[
"readability/readability-0.2.0.js"
,
"readability/readability-readerable-0.2.0.js"
,
"moment/moment-2.24.0.js"
,
"readerview.js"
],
"js"
:
[
"readability/readability-0.2.0.js"
,
"readability/readability-readerable-0.2.0.js"
,
"readerview.js"
],
"css"
:
[
"readerview.css"
],
"run_at"
:
"document_idle"
}
...
...
components/feature/readerview/src/main/assets/extensions/readerview/moment/moment-2.24.0.js
deleted
100644 → 0
View file @
3bb3548e
This diff is collapsed.
Click to expand it.
components/feature/readerview/src/main/assets/extensions/readerview/readerview.js
View file @
91bc4f13
...
...
@@ -191,15 +191,23 @@ class ReaderView {
const
readingTimeMinsSlow
=
Math
.
ceil
(
length
/
charactersPerMinuteLow
);
const
readingTimeMinsFast
=
Math
.
ceil
(
length
/
charactersPerMinuteHigh
);
// TODO remove moment.js: https://github.com/mozilla-mobile/android-components/issues/2923
// We only want to show minutes and not have it converted to hours.
moment
.
relativeTimeThreshold
(
'
m
'
,
Number
.
MAX_SAFE_INTEGER
);
if
(
readingTimeMinsSlow
==
readingTimeMinsFast
)
{
return
moment
.
duration
(
readingTimeMinsFast
,
'
minutes
'
).
locale
(
lang
).
humanize
();
// Construct a localized and "humanized" reading time in minutes.
// If we have both a fast and slow reading time we'll show both e.g.
// "2 - 4 minutes", otherwise we'll just show "4 minutes".
var
parts
=
new
Intl
.
RelativeTimeFormat
(
lang
).
formatToParts
(
readingTimeMinsSlow
,
'
minute
'
);
if
(
parts
.
length
==
3
)
{
// No need to use part[0] which represents the literal "in".
var
readingTime
=
parts
[
1
].
value
;
// reading time in minutes
var
minutesLiteral
=
parts
[
2
].
value
;
// localized singular or plural literal of 'minute'
var
readingTimeString
=
`
${
readingTime
}
${
minutesLiteral
}
`
;
if
(
readingTimeMinsSlow
!=
readingTimeMinsFast
)
{
readingTimeString
=
`
${
readingTimeMinsFast
}
-
${
readingTimeString
}
`
;
}
return
readingTimeString
;
}
return
`
${
readingTimeMinsFast
}
-
${
moment
.
duration
(
readingTimeMinsSlow
,
'
minutes
'
).
locale
(
lang
).
humanize
()}
`
;
return
""
;
}
/**
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment