diff --git a/src/App.vue b/src/App.vue
index 3b1dc465..dd0f8faf 100644
--- a/src/App.vue
+++ b/src/App.vue
@@ -40,12 +40,13 @@ export default {
darkModePreference.addEventListener("change", () => {
this.setTheme();
});
- if (this.getPreferenceBoolean("watchHistory", false))
- if ("indexedDB" in window) {
- const request = indexedDB.open("piped-db", 2);
- request.onupgradeneeded = ev => {
- const db = request.result;
- console.log("Upgrading object store.");
+
+ if ("indexedDB" in window) {
+ const request = indexedDB.open("piped-db", 3);
+ request.onupgradeneeded = ev => {
+ const db = request.result;
+ console.log("Upgrading object store.");
+ if (this.getPreferenceBoolean("watchHistory", false)) {
if (!db.objectStoreNames.contains("watch_history")) {
const store = db.createObjectStore("watch_history", { keyPath: "videoId" });
store.createIndex("video_id_idx", "videoId", { unique: true });
@@ -55,11 +56,17 @@ export default {
const store = request.transaction.objectStore("watch_history");
store.createIndex("watchedAt", "watchedAt", { unique: false });
}
- };
- request.onsuccess = e => {
- window.db = e.target.result;
- };
- } else console.log("This browser doesn't support IndexedDB");
+ }
+ if (!db.objectStoreNames.contains("playlist_bookmarks")) {
+ const store = db.createObjectStore("playlist_bookmarks", { keyPath: "playlistId" });
+ store.createIndex("playlist_id_idx", "playlistId", { unique: true });
+ store.createIndex("id_idx", "id", { unique: true, autoIncrement: true });
+ }
+ };
+ request.onsuccess = e => {
+ window.db = e.target.result;
+ };
+ } else console.log("This browser doesn't support IndexedDB");
const App = this;
diff --git a/src/components/PlaylistPage.vue b/src/components/PlaylistPage.vue
index d84dea9c..69234876 100644
--- a/src/components/PlaylistPage.vue
+++ b/src/components/PlaylistPage.vue
@@ -14,6 +14,9 @@
+
@@ -144,6 +147,23 @@ export default {
});
this.download(data, this.playlist.name + ".txt", "text/plain");
},
+ async bookmarkPlaylist() {
+ if (!this.playlist) return;
+ if (window.db) {
+ const playlistId = this.$route.query.list;
+ var tx = window.db.transaction("playlist_bookmarks", "readwrite");
+ var store = tx.objectStore("playlist_bookmarks");
+ store.put({
+ playlistId: playlistId,
+ name: this.playlist.name,
+ uploader: this.playlist.uploader,
+ uploaderUrl: this.playlist.uploaderUrl,
+ thumbnail: this.playlist.thumbnailUrl,
+ uploaderAvatar: this.playlist.uploaderAvatar,
+ videos: this.playlist.videos,
+ });
+ }
+ },
},
};
diff --git a/src/components/PlaylistsPage.vue b/src/components/PlaylistsPage.vue
index 7383fd79..27e4834a 100644
--- a/src/components/PlaylistsPage.vue
+++ b/src/components/PlaylistsPage.vue
@@ -39,6 +39,25 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/locales/en.json b/src/locales/en.json
index 318f1bcf..32fb7197 100644
--- a/src/locales/en.json
+++ b/src/locales/en.json
@@ -120,7 +120,8 @@
"instance_donations": "Instance donations",
"reply_count": "{count} replies",
"no_valid_playlists": "The file doesn't contain valid playlists!",
- "with_playlist": "Share with playlist"
+ "with_playlist": "Share with playlist",
+ "bookmark_playlist": "Bookmark"
},
"comment": {
"pinned_by": "Pinned by {author}",
diff --git a/src/main.js b/src/main.js
index fb15e695..c56e4ae8 100644
--- a/src/main.js
+++ b/src/main.js
@@ -20,6 +20,7 @@ import {
faBook,
faServer,
faDonate,
+ faBookmark,
} from "@fortawesome/free-solid-svg-icons";
import { faGithub, faBitcoin, faYoutube } from "@fortawesome/free-brands-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/vue-fontawesome";
@@ -46,6 +47,7 @@ library.add(
faBook,
faServer,
faDonate,
+ faBookmark,
);
import router from "@/router/router.js";