-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Prospective solution for livestream appearance #1077
Conversation
Merge with main project master branch
Travis Travis Build build Windows Tests No cache npm install Linux njs 12.14.1 build build travis windows build linux test export export node windows travis_wait linux tests javascript sudo script local_dir commit commit
packages/ui/lib/utils.ts
Outdated
if (!_.isFinite(parseInt(duration)) || duration <= 0) { | ||
export function formatDuration(duration, livestream?) { | ||
if (livestream) { | ||
return 'LIVE'; |
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 string should be localized
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.
fyi, in UI package localized string must be passed from higher component, can not require useTranslation
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.
Understood, I'll add localization. @haidang666 Should localization happen in the Seekbar component?
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.
Yes, but there is one more thing, you don't need to add the translation key to all languages JSON files, only in en.json
.
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've got the Seekbar component in the app package modified as follows:
However this doesn't seem to have affected the actual timestamps when a song is playing since those are calculated and displayed dynamically (as far as I can tell). Is there just something I'm missing for how to implement the localization properly?
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 you got the wrong SeekBar
. The app/PlayerBarContainer
uses ui/PlayerBar
which uses the SeekBar
in UI package (https://github.com/nukeop/nuclear/blob/master/packages/ui/lib/components/Seekbar/index.tsx)
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 think I got the localization working this time. I added the translation to the PlayerBarContainer like you suggested and re-worked some of our changes in the Seekbar UI component
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 more thing u should revert other language file change, only need keep the english one
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've reverted the other language file changes. Only en.json will reflect the live keys.
Pulling in localization from Livestreamfix2
Adding check for NaN timeToEnd to fix seekbar UI bug
adding localization to live timestamps
@@ -23,6 +23,9 @@ export type PlayerBarProps = PlayerControlsProps & | |||
}; | |||
|
|||
const VOLUME_POPUP_BREAKPOINT = 570; | |||
|
|||
let livestream = false; |
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.
can you rename it to isLivestream
for consistency of naming with other boolean variables?
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 should be reflected in latest commit.
Thanks!
} | ||
if (typeof timeToEnd === 'string') { | ||
livestream = true; | ||
fill = 100; |
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.
You should never mutate props. Instead of doing all this, you should pass different props to child elements. You can also determine whether we're dealing with a live stream or not in a single line.
E.g.:
const isLivestream = isNan(timetoEnd) || isString(timeToEnd);
Then depending on this variable, pass a different fill value to the seekbar:
fill={isLivestream ? 100 : fill}
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.
const isLivestream = isNan(timetoEnd) || isString(timeToEnd);
Almost have something like this working, above line fills SeekBar by default but the line in our repo now has it empty by default.
fill={isLivestream ? 100 : fill}
I like this line, I've added it to the PR.
Thanks for reviewing!
@@ -62,7 +62,7 @@ export const QueueItem = ({ | |||
|
|||
<div className={styles.item_duration_container}> | |||
<div className={styles.item_duration}> | |||
{duration} | |||
{duration === '00:00' && !isLoading ? 'LIVE' : duration} |
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.
Can you use the same localization method for this 'LIVE' string as well? Generally we don't want to have any bare strings that aren't localized, with some common sense exceptions (like this 00:00 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.
Indeed this file does not need to be changed at all, I've reverted this back to its previous state as the localization for this component is already done in app/components/PlayQueue/index.js
Thanks for iterating on this with us. I added some comments to your changes. There are some typing errors in the CI logs, could you please take a look at them? I can fix them for you later if you don't want to do it too. |
…s in components/PlayQueue)
…ream localizations.
Type Errors should be gone now. Thanks! |
Thanks! I squashed and merged this now |
Fix partially implemented for #970