diff --git a/src/components/AddToGroupModal.vue b/src/components/AddToGroupModal.vue new file mode 100644 index 00000000..f7b56c43 --- /dev/null +++ b/src/components/AddToGroupModal.vue @@ -0,0 +1,54 @@ + + diff --git a/src/components/ChannelPage.vue b/src/components/ChannelPage.vue index af504a44..c04046fc 100644 --- a/src/components/ChannelPage.vue +++ b/src/components/ChannelPage.vue @@ -27,6 +27,13 @@ @click="subscribeHandler" > + + + + @@ -79,6 +88,7 @@ import ContentItem from "./ContentItem.vue"; import WatchOnButton from "./WatchOnButton.vue"; import LoadingIndicatorPage from "./LoadingIndicatorPage.vue"; import CollapsableText from "./CollapsableText.vue"; +import AddToGroupModal from "./AddToGroupModal.vue"; export default { components: { @@ -87,6 +97,7 @@ export default { WatchOnButton, LoadingIndicatorPage, CollapsableText, + AddToGroupModal, }, data() { return { @@ -95,6 +106,7 @@ export default { tabs: [], selectedTab: 0, contentItems: [], + showGroupModal: false, }; }, mounted() { diff --git a/src/components/FeedPage.vue b/src/components/FeedPage.vue index 0bca8f72..1c22ab3d 100644 --- a/src/components/FeedPage.vue +++ b/src/components/FeedPage.vue @@ -99,18 +99,7 @@ export default { if (!window.db) return; - const cursor = this.getChannelGroupsCursor(); - cursor.onsuccess = e => { - const cursor = e.target.result; - if (cursor) { - const group = cursor.value; - this.channelGroups.push({ - groupName: group.groupName, - channels: JSON.parse(group.channels), - }); - cursor.continue(); - } - }; + this.loadChannelGroups(); }, activated() { document.title = this.$t("titles.feed") + " - Piped"; @@ -135,6 +124,10 @@ export default { }); } }, + async loadChannelGroups() { + const groups = await this.getChannelGroups(); + this.channelGroups.push(...groups); + }, loadMoreVideos() { if (!this.videosStore) return; this.currentVideoCount = Math.min(this.currentVideoCount + this.videoStep, this.videosStore.length); diff --git a/src/components/SubscriptionsPage.vue b/src/components/SubscriptionsPage.vue index 9bfb6bff..c532fa8d 100644 --- a/src/components/SubscriptionsPage.vue +++ b/src/components/SubscriptionsPage.vue @@ -143,18 +143,8 @@ export default { this.channelGroups.push(this.selectedGroup); if (!window.db) return; - const cursor = this.getChannelGroupsCursor(); - cursor.onsuccess = e => { - const cursor = e.target.result; - if (cursor) { - const group = cursor.value; - this.channelGroups.push({ - groupName: group.groupName, - channels: JSON.parse(group.channels), - }); - cursor.continue(); - } - }; + + this.loadChannelGroups(); }, activated() { document.title = "Subscriptions - Piped"; @@ -173,6 +163,10 @@ export default { }); } }, + async loadChannelGroups() { + const groups = await this.getChannelGroups(); + this.channelGroups.push(...groups); + }, handleButton(subscription) { const channelId = subscription.url.split("/")[2]; if (this.authenticated) { diff --git a/src/locales/en.json b/src/locales/en.json index c9a903e9..5c9f55ad 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -147,7 +147,8 @@ "show_search_suggestions": "Show search suggestions", "delete_automatically": "Delete automatically after", "generate_qrcode": "Generate QR Code", - "download_frame": "Download frame" + "download_frame": "Download frame", + "add_to_group": "Add to group" }, "comment": { "pinned_by": "Pinned by {author}", diff --git a/src/main.js b/src/main.js index 37148852..9d6f8382 100644 --- a/src/main.js +++ b/src/main.js @@ -247,11 +247,26 @@ const mixin = { elem.click(); elem.remove(); }, - getChannelGroupsCursor() { - if (!window.db) return; - var tx = window.db.transaction("channel_groups", "readonly"); - var store = tx.objectStore("channel_groups"); - return store.index("groupName").openCursor(); + async getChannelGroups() { + return new Promise(resolve => { + let channelGroups = []; + var tx = window.db.transaction("channel_groups", "readonly"); + var store = tx.objectStore("channel_groups"); + const cursor = store.index("groupName").openCursor(); + cursor.onsuccess = e => { + const cursor = e.target.result; + if (cursor) { + const group = cursor.value; + channelGroups.push({ + groupName: group.groupName, + channels: JSON.parse(group.channels), + }); + cursor.continue(); + } else { + resolve(channelGroups); + } + }; + }); }, createOrUpdateChannelGroup(group) { var tx = window.db.transaction("channel_groups", "readwrite");