fix: styles breaking in certain situations

This commit is contained in:
ThaUnknown 2023-01-06 13:19:48 +01:00
parent 00cb3deca0
commit 63d088710d
2 changed files with 15 additions and 6 deletions

View file

@ -1,6 +1,6 @@
{
"name": "Miru",
"version": "3.5.3",
"version": "3.5.4",
"author": "ThaUnknown_ <ThaUnknown@users.noreply.github.com>",
"description": "Stream anime torrents, real-time with no waiting for downloads.",
"main": "src/index.js",

View file

@ -68,15 +68,15 @@ export default class Subtitles {
if (track.type !== 'ass') track.header = defaultHeader
if (!this.current) {
this.current = track.number
const styleMatches = track.header.match(stylesRx)
for (let i = 0; i < styleMatches.length; ++i) {
const style = styleMatches[i].replace('Style:', '').trim()
this._stylesMap[style] = i + 1
}
}
this.tracks[track.number] = []
this._tracksString[track.number] = new Set()
this.headers[track.number] = track
const styleMatches = track.header.match(stylesRx)
for (let i = 0; i < styleMatches.length; ++i) {
const style = styleMatches[i].replace('Style:', '').trim()
this._stylesMap[style] = i + 1
}
this.onHeader()
}
@ -256,8 +256,17 @@ export default class Subtitles {
this.current = Number(trackNumber)
this.onHeader()
if (this.renderer && this.headers) {
const track = this.headers[this.current]
this.renderer.setTrack(this.current !== -1 ? this.headers[this.current].header.slice(0, -1) : defaultHeader)
if (this.tracks[this.current]) {
this._stylesMap = {
Default: 0
}
const styleMatches = track.header.match(stylesRx)
for (let i = 0; i < styleMatches.length; ++i) {
const style = styleMatches[i].replace('Style:', '').trim()
this._stylesMap[style] = i + 1
}
for (const subtitle of this.tracks[this.current]) this.renderer.createEvent(subtitle)
}
}