-
Notifications
You must be signed in to change notification settings - Fork 34
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
fix(quantic): fixed display of timestamps in youtube templates #4676
base: master
Are you sure you want to change the base?
Conversation
Pull Request ReportPR Title✅ Title follows the conventional commit spec. Live demo linksBundle Size
SSR Progress
Detailed logssearch : buildInteractiveResultsearch : buildInteractiveInstantResult search : buildInteractiveRecentResult search : buildInteractiveCitation search : buildGeneratedAnswer recommendation : missing SSR support case-assist : missing SSR support insight : missing SSR support commerce : missing SSR support |
packages/quantic/force-app/main/default/lwc/quanticUtils/__tests__/quanticUtils.test.js
Outdated
Show resolved
Hide resolved
getYoutubeFormatTimestamp() { | ||
const hours = Math.floor(this.getHours()); | ||
const minutes = Math.floor(this.getMinutes()) % 60; | ||
const seconds = Math.floor(this.getSeconds()) % 60; | ||
let timestamp = ''; | ||
|
||
const formattedSeconds = seconds < 10 ? '0' + seconds : seconds; | ||
|
||
if (hours > 0) { | ||
const formattedMinutes = minutes < 10 ? '0' + minutes : minutes; | ||
timestamp += hours + ':' + formattedMinutes + ':' + formattedSeconds; | ||
} else { | ||
const formattedMinutes = | ||
minutes === 0 ? '0' : minutes < 10 ? '0' + minutes : minutes; | ||
timestamp += formattedMinutes + ':' + formattedSeconds; | ||
} | ||
|
||
return timestamp; | ||
} | ||
|
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.
Here you could probably use string literals and a helper function to simplify this logic and avoid having to declare formattedMinutes
twice. What do you think?
getYoutubeFormatTimestamp() { | |
const hours = Math.floor(this.getHours()); | |
const minutes = Math.floor(this.getMinutes()) % 60; | |
const seconds = Math.floor(this.getSeconds()) % 60; | |
let timestamp = ''; | |
const formattedSeconds = seconds < 10 ? '0' + seconds : seconds; | |
if (hours > 0) { | |
const formattedMinutes = minutes < 10 ? '0' + minutes : minutes; | |
timestamp += hours + ':' + formattedMinutes + ':' + formattedSeconds; | |
} else { | |
const formattedMinutes = | |
minutes === 0 ? '0' : minutes < 10 ? '0' + minutes : minutes; | |
timestamp += formattedMinutes + ':' + formattedSeconds; | |
} | |
return timestamp; | |
} | |
getYoutubeFormatTimestamp() { | |
const format = (num) => (num < 10 ? '0' + num : num); | |
const hours = Math.floor(this.getHours()); | |
const minutes = Math.floor(this.getMinutes()) % 60; | |
const seconds = Math.floor(this.getSeconds()) % 60; | |
const formattedSeconds = format(seconds); | |
const formattedMinutes = format(minutes); | |
if (hours > 0) { | |
return `${hours}:${formattedMinutes}:${formattedSeconds}`; | |
} else { | |
return `${minutes === 0 ? '0' : formattedMinutes}:${formattedSeconds}`; | |
} | |
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.
Could be yeah, I don't see any impact in going one way or another,
personally, not a big fan of declaring a function inside a method tho.
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.
then you could declare it outside X) I just think its a bit more readable IMO
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.
That's a class we are dealing with, declaring it outside as a method? no we don't wont expose that in this class.
Declaring it as an orphan function in the file? could be but what does it add?
Anyway we are having a discussion about an extremely minor thing, that mainly boils down to preference but does not have a real impact.
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.
Also as a general rule, I don't think minor things like this could be stoppers to not approve PRs,
mainly to avoid doing a lot of back and forth on PRs before getting them merged.
If there are things impactful that can be improved yes of course they are the most welcome,
For very minor things where doing something can be done using method A or method B but without a real impact if any, yes they also are the most welcome to suggest, but should not be stoppers from approving PRs.
That's my opinion and that's the logic I follow at least to approve PRs or not,
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 was mostly kidding for the function, but I agree with you that functions inside of class methods are usually not the best practice. In this case however, it was such a small and simple function that I thought it was making the method more readable than not.
Anyways, as you said, this is definitely not a blocker for me, but I do think of readability as being impactful.
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't believe it's not easier than this in JS to convert ms to timestamp haha
well done
SFINT-5816
Before
After