PreMiD / Extension-old

🧩 Source code of the official PreMiD extension.
https://premid.app/
Mozilla Public License 2.0
75 stars 28 forks source link

fix: set correct start timestamp #239

Closed fawni closed 4 months ago

fawni commented 1 year ago

returns the correct start timestamp in getTimestamps method.

the previous way sets the current time as the start timestamp which makes discord believe that media just started playing. discord already checks the current time and compares it with the timestamps available.

here's the difference to further clarify:

16_03_2023-19_48_Discord_7VPggqH

16_03_2023-19_46_Discord_NaPKWC7

note that discord currently does not render the shown timestamp bar by default so this is not much of an issue as of now, but this might change in the future.

Bas950 commented 4 months ago

Since 2.6.0 this function has been changed to:

    /**
     * Converts time and duration integers into snowflake timestamps
     * @param {Number} elementTime Current element time seconds
     * @param {Number} elementDuration Element duration seconds
     */
    getTimestamps(elementTime: number, elementDuration: number) {
        const startTime = Math.floor(Date.now() / 1000) - elementTime,
            endTime = startTime + elementDuration;
        return [startTime, endTime];
    }