Skip to content

Commit

Permalink
fix fatal bug for idb version change
Browse files Browse the repository at this point in the history
  • Loading branch information
yanjiaxuan committed Jun 1, 2021
1 parent fd515cc commit 95394cf
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 18 deletions.
43 changes: 31 additions & 12 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "tomatox",
"version": "1.2.2",
"version": "1.2.3",
"description": "A free fast beautiful online video player with electron.",
"main": "./dist/main.js",
"scripts": {
Expand Down
8 changes: 3 additions & 5 deletions src/renderer/utils/db/indexed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,18 @@ export default class Indexed {
public static init(): Promise<Indexed> {
return new Promise((resolve, reject) => {
if (!this.instance) {
const dbReq = window.indexedDB.open('TOMATOX', 2);
const dbReq = window.indexedDB.open('TOMATOX', 3);
dbReq.onupgradeneeded = () => {
const db = dbReq.result;
if (db.objectStoreNames.contains(TABLES.TABLE_HISTORY)) {
db.deleteObjectStore(TABLES.TABLE_HISTORY);
if (!db.objectStoreNames.contains(TABLES.TABLE_HISTORY)) {
const table = db.createObjectStore(TABLES.TABLE_HISTORY, {
keyPath: 'id'
});
table.createIndex('lastPlayDate', 'lastPlayDate', {
unique: false
});
}
if (db.objectStoreNames.contains(TABLES.TABLE_COLLECT)) {
db.deleteObjectStore(TABLES.TABLE_COLLECT);
if (!db.objectStoreNames.contains(TABLES.TABLE_COLLECT)) {
db.createObjectStore(TABLES.TABLE_COLLECT, {
keyPath: 'id'
});
Expand Down

0 comments on commit 95394cf

Please sign in to comment.