Skip to content
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

Merged
merged 84 commits into from
Nov 8, 2021

Conversation

jreiser1
Copy link
Contributor

@jreiser1 jreiser1 commented Oct 17, 2021

Fix partially implemented for #970

Jacob Netwal and others added 30 commits September 6, 2021 14:43
njs 12.14.1
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
if (!_.isFinite(parseInt(duration)) || duration <= 0) {
export function formatDuration(duration, livestream?) {
if (livestream) {
return 'LIVE';
Copy link
Owner

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

Copy link
Collaborator

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

Copy link
Contributor Author

@jreiser1 jreiser1 Oct 19, 2021

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?

Copy link
Collaborator

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.

Copy link
Contributor Author

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:
image

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?

Copy link
Collaborator

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)

Copy link
Contributor Author

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

Copy link
Collaborator

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

Copy link
Contributor

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.

@nukeop nukeop added needs changes The author needs to make changes to this pull request. under review This pull request is being reviewed by maintainers. labels Oct 18, 2021
@haidang666 haidang666 linked an issue Oct 21, 2021 that may be closed by this pull request
@@ -23,6 +23,9 @@ export type PlayerBarProps = PlayerControlsProps &
};

const VOLUME_POPUP_BREAKPOINT = 570;

let livestream = false;
Copy link
Owner

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?

Copy link
Contributor

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;
Copy link
Owner

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}

Copy link
Contributor

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}
Copy link
Owner

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).

Copy link
Contributor

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

@nukeop
Copy link
Owner

nukeop commented Oct 21, 2021

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.

@1lluzi0nzz
Copy link
Contributor

Type Errors should be gone now.

Thanks!

@nukeop nukeop merged commit 4487fe3 into nukeop:master Nov 8, 2021
@nukeop
Copy link
Owner

nukeop commented Nov 8, 2021

Thanks! I squashed and merged this now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs changes The author needs to make changes to this pull request. under review This pull request is being reviewed by maintainers.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve appearance when playing livestream
5 participants