Skip to content

Commit 5418ca7

Browse files
committed
publish v2.0.0beta.1
1 parent bb6e395 commit 5418ca7

11 files changed

+132
-118
lines changed

dist/shikwasa.chapter.cjs.css

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/shikwasa.chapter.cjs.js

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -135,13 +135,11 @@ class Chapter {
135135
if (!this._chapterPatched) {
136136
this.init();
137137
this._chapterPatched = true;
138-
} else {
139-
this.clearList();
140-
}
141-
if (audio.chapters.length) {
142-
this.updateList(audio);
143138
}
144-
this.ui.handleChapterPanel(this.ctx, audio);
139+
this.updateList(audio);
140+
});
141+
this.ctx.on('audioparse', audio => {
142+
this.updateList(audio);
145143
});
146144
this.ctx.on('timeupdate', this.onTimeupdate.bind(this));
147145
}
@@ -151,9 +149,25 @@ class Chapter {
151149
this.current = null;
152150
}
153151
updateList(audio) {
154-
this.list = audio.chapters;
155-
this.ui.renderChapterList(this.ctx.chapters);
156-
this.clickChapterHandler();
152+
if (this.list.length) {
153+
this.clearList();
154+
}
155+
if (audio.chapters.length) {
156+
this.list = this.handleChapters(audio);
157+
this.ui.renderChapterList(this.ctx.chapters);
158+
this.clickChapterHandler();
159+
}
160+
this.ui.handleChapterPanel(this.ctx, audio);
161+
}
162+
handleChapters(audio) {
163+
if (audio.chapters && audio.chapters.length) {
164+
return audio.chapters.map((chap, i) => {
165+
if (!/^ch\d+$/.test(chap.id)) {
166+
chap.id = "ch".concat(i);
167+
}
168+
return chap;
169+
});
170+
}
157171
}
158172
patchPlayer() {
159173
var self = this;

dist/shikwasa.chapter.min.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)