Arnavion / libjass

Renders ASS subs in the browser.
Apache License 2.0
174 stars 29 forks source link

dialogues ID will be created next to the last dialogues ID from previous object #115

Closed jokerrider007 closed 5 years ago

jokerrider007 commented 5 years ago

when I use libjass.ASS.fromUrl multiple time. ASS object dialogues ID will be created next to the last dialogues ID from previous ASS object.

capture1

capture2

How can I get ASS object dialogues ID doesn't relate form previous object?

Arnavion commented 5 years ago

It doesn't matter. The ID doesn't need to start from 0; it only needs to be unique.

jokerrider007 commented 5 years ago

Can I clear object ID start from 0? l need to upload multiple files and each ASS object dialogues ID start From 0 before storing to the database.

Arnavion commented 5 years ago

If you're sure that you're going to only create and work with one ASS object at a time (ie you're not going to create Dialogue objects for multiple ASS at the same time), then you can set Dialogue._lastDialogueId to -1 before creating the next ASS object. Every newly created Dialogue object sets its id to ++Dialogue._lastDialogueId

Alternatively use the Dialogue's index in the ass.dialogues array as your database key instead of its id property.