strautomator / core

Strautomator Core
MIT License
42 stars 6 forks source link

Add condition to check if there are any Spotify tracks #52

Open PabiGamito opened 6 days ago

PabiGamito commented 6 days ago

I would like to only append some text which includes the list of Spotify tracks if there are actually any played during the activity. It would be nice to be able to have a condition for this.

PabiGamito commented 6 days ago

I was quickly taking a look at the code and it seems like there might be a bug with the condition logic:

    if (tracks.length > 0) {
        if (op == RecipeOperator.Equal) {
            valid = trackTitles.filter((t) => t == value).length > 0
        } else if (op == RecipeOperator.Like) {
            valid = trackTitles.filter((t) => t.includes(t)).length > 0
        } else if (op == RecipeOperator.NotLike) {
            valid = trackTitles.filter((t) => !t.includes(t)).length > 0
        }
    } else if (op == RecipeOperator.NotLike) {
        valid = true
    }

I would expect it to be t.includes(value) instead of t.includes(t).

I guess in the meantime because of this bug I can just use the includes with any value and it will always only be true when we have at least one track in the list.

igoramadas commented 5 days ago

You are right. I merged the PR and should be deployed on the weekend, thanks for spotting this.