Leo 3 vuotta sitten
vanhempi
commit
41eebc655d
2 muutettua tiedostoa jossa 17 lisäystä ja 30 poistoa
  1. 16 29
      libs/db/getDb.ts
  2. 1 1
      styles/library.module.scss

+ 16 - 29
libs/db/getDb.ts

@@ -14,40 +14,27 @@ export interface NovelDb extends DBSchema {
 }
 
 export default function getDb() {
-  return openDB<NovelDb>("NovelDit", 2, {
+  return openDB<NovelDb>("NovelDit", 3, {
     upgrade(db, oldVersion, newVersion) {
-      console.log(oldVersion, newVersion);
-      if (oldVersion === 0) {
-        const historyStore = db.createObjectStore("history", {
-          keyPath: "uri",
-        });
-
-        historyStore.createIndex("historyUpdateTime", "readTime", {
-          unique: false,
-        });
-
-        historyStore.createIndex(
-          "historyIsReading",
-          ["isReading", "readTime"],
-          {
-            unique: false,
-          }
-        );
+      if (newVersion && newVersion > oldVersion) {
+        db.deleteObjectStore("history");
+      }
 
-        historyStore.createIndex("historyIsFavorite", "isFavorite", {
-          unique: false,
-        });
-      } else if (oldVersion === 1) {
-        const historyStore = db.transaction("history", "versionchange");
+      const historyStore = db.createObjectStore("history", {
+        keyPath: "uri",
+      });
 
-        const store = historyStore.store;
+      historyStore.createIndex("historyUpdateTime", "readTime", {
+        unique: false,
+      });
 
-        store.deleteIndex("historyIsFavorite");
+      historyStore.createIndex("historyIsReading", ["isReading", "readTime"], {
+        unique: false,
+      });
 
-        store.createIndex("historyIsFavorite", "isFavorite", {
-          unique: false,
-        });
-      }
+      historyStore.createIndex("historyIsFavorite", "isFavorite", {
+        unique: false,
+      });
     },
   });
 }

+ 1 - 1
styles/library.module.scss

@@ -1,5 +1,5 @@
 .library-header {
-  @apply bg-neutral-50 pt-6 border-b border-gray-900/10;
+  @apply bg-neutral-100 pt-6 border-b border-gray-900/10;
 
   :global(.dark) & {
     @apply border-gray-50/[0.06] bg-slate-900;