Conversation
src/content/ServicesRegistry.js
Outdated
| { | ||
| hosts: [ 'radiolist.com.ua' ], | ||
| options: { | ||
| statusStrategy: StatusStrategies.checkSelector, |
There was a problem hiding this comment.
We can make it a factory method and get rid off statusArgs.
StatusStrategies.getCheckSelector(".jouele-status-playing .jouele-info-control-button-icon_pause")
There was a problem hiding this comment.
I would keep things generic for all the strategies, i.e. passing the args as a property on the options object, as I see there will be other strategies with a different params count etc.
| '.icon-toggle.mod-mute .icon-button.mod-muted', | ||
| '.icon-toggle.mod-mute .icon-button.mod-sound' | ||
| ] | ||
| ].map(item => oneSelectorHelper.apply(null, item)); |
There was a problem hiding this comment.
wow, looks like a magic :)
maybe simple declarative way, like radiolist.com.ua below?
There was a problem hiding this comment.
I mean, in this case you should always remember what's 2, 3, 4 arguments for.
There was a problem hiding this comment.
It's true, but it will be very redundant with the amount of services that we have
| status = hasPlayingVideo ? Status.PLAYING : Status.PAUSED; | ||
| } | ||
| return status; | ||
| } |
There was a problem hiding this comment.
According to some clean code guides, it's better to leave exclusions in the beginning and do stuff after.
static getStatus() {
let status = Status.PAUSED;
const videos = document.getElementsByTagName("video");
if (videos.length > 0) {
const hasPlayingVideo = Array.from(videos).some((player) => !player.paused);
status = hasPlayingVideo ? Status.PLAYING : Status.PAUSED;
}
return status;
}becomes
static getStatus() {
const videos = document.getElementsByTagName("video");
if (!videos.length) {
return Status.PAUSED;
}
const hasPlayingVideo = Array.from(videos).some((player) => !player.paused);
return hasPlayingVideo
? Status.PLAYING
: Status.PAUSED;
}There was a problem hiding this comment.
Here I don't have an exclusion - it's the actual condition of continuation.
Also it's always good to have one return.
I would keep it like this.
src/content/Control.Strategies.js
Outdated
| } | ||
|
|
||
| static play() { | ||
| clickSelector.pause(); |
There was a problem hiding this comment.
looks funny :))))
play() => pause()
There was a problem hiding this comment.
The method is static, so it won't work.
Oh, actually, I added separate args here, I'll update.
Co-Authored-By: Oleksandr Karpov <karpov.alexandr.b@gmail.com>
Co-Authored-By: Oleksandr Karpov <karpov.alexandr.b@gmail.com>
Co-Authored-By: Oleksandr Karpov <karpov.alexandr.b@gmail.com>
Co-Authored-By: Oleksandr Karpov <karpov.alexandr.b@gmail.com>
Co-Authored-By: Oleksandr Karpov <karpov.alexandr.b@gmail.com>
No description provided.