mirror of
https://github.com/TeamPiped/Piped.git
synced 2024-08-14 23:57:27 +00:00
Merge 5567b3c417
into 3eb846ec6b
This commit is contained in:
commit
1045817654
5 changed files with 70 additions and 2 deletions
|
@ -26,7 +26,7 @@
|
||||||
|
|
||||||
<LoadingIndicatorPage :show-content="videosStore != null" class="video-grid">
|
<LoadingIndicatorPage :show-content="videosStore != null" class="video-grid">
|
||||||
<template v-for="video in videos" :key="video.url">
|
<template v-for="video in videos" :key="video.url">
|
||||||
<VideoItem v-if="shouldShowVideo(video)" :is-feed="true" :item="video" />
|
<VideoItem v-if="shouldShowVideo(video)" :is-feed="true" :item="video" @update:watched="onUpdateWatched" />
|
||||||
</template>
|
</template>
|
||||||
</LoadingIndicatorPage>
|
</LoadingIndicatorPage>
|
||||||
</template>
|
</template>
|
||||||
|
@ -100,6 +100,15 @@ export default {
|
||||||
this.loadMoreVideos();
|
this.loadMoreVideos();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
onUpdateWatched(urls = null) {
|
||||||
|
if (urls === null) {
|
||||||
|
if (this.videos.length > 0) this.updateWatched(this.videos);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const subset = this.videos.filter(({ url }) => urls.includes(url));
|
||||||
|
if (subset.length > 0) this.updateWatched(subset);
|
||||||
|
},
|
||||||
shouldShowVideo(video) {
|
shouldShowVideo(video) {
|
||||||
switch (this.selectedFilter.toLowerCase()) {
|
switch (this.selectedFilter.toLowerCase()) {
|
||||||
case "shorts":
|
case "shorts":
|
||||||
|
|
|
@ -146,7 +146,7 @@
|
||||||
@change="onChange($event)"
|
@change="onChange($event)"
|
||||||
/>
|
/>
|
||||||
</label>
|
</label>
|
||||||
<label v-if="watchHistory" class="pref" for="chkHideWatched">
|
<label class="pref" for="chkHideWatched">
|
||||||
<strong v-t="'actions.hide_watched'" />
|
<strong v-t="'actions.hide_watched'" />
|
||||||
<input id="chkHideWatched" v-model="hideWatched" class="checkbox" type="checkbox" @change="onChange($event)" />
|
<input id="chkHideWatched" v-model="hideWatched" class="checkbox" type="checkbox" @change="onChange($event)" />
|
||||||
</label>
|
</label>
|
||||||
|
|
|
@ -118,6 +118,18 @@
|
||||||
>
|
>
|
||||||
<font-awesome-icon icon="circle-minus" />
|
<font-awesome-icon icon="circle-minus" />
|
||||||
</button>
|
</button>
|
||||||
|
<button
|
||||||
|
v-if="
|
||||||
|
isFeed &&
|
||||||
|
(this.getPreferenceBoolean('watchHistory', false) ||
|
||||||
|
this.getPreferenceBoolean('hideWatched', false))
|
||||||
|
"
|
||||||
|
@click="toggleWatched(item.url.substr(-11))"
|
||||||
|
ref="watchButton"
|
||||||
|
>
|
||||||
|
<font-awesome-icon icon="eye-slash" v-if="item.watched" :title="$t('actions.mark_as_unwatched')" />
|
||||||
|
<font-awesome-icon icon="eye" v-else :title="$t('actions.mark_as_watched')" />
|
||||||
|
</button>
|
||||||
<PlaylistAddModal v-if="showModal" :video-id="item.url.substr(-11)" @close="showModal = !showModal" />
|
<PlaylistAddModal v-if="showModal" :video-id="item.url.substr(-11)" @close="showModal = !showModal" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -152,6 +164,7 @@ export default {
|
||||||
playlistId: { type: String, default: null },
|
playlistId: { type: String, default: null },
|
||||||
admin: { type: Boolean, default: false },
|
admin: { type: Boolean, default: false },
|
||||||
},
|
},
|
||||||
|
emits: ["update:watched"],
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
showModal: false,
|
showModal: false,
|
||||||
|
@ -194,6 +207,48 @@ export default {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
toggleWatched(videoId) {
|
||||||
|
if (window.db) {
|
||||||
|
// Should match WatchVideo.vue
|
||||||
|
var tx = window.db.transaction("watch_history", "readwrite");
|
||||||
|
var store = tx.objectStore("watch_history");
|
||||||
|
var instance = this;
|
||||||
|
|
||||||
|
if (this.item.watched) {
|
||||||
|
let request = store.delete(videoId);
|
||||||
|
request.onsuccess = function () {
|
||||||
|
instance.$emit("update:watched", [instance.item.url]);
|
||||||
|
};
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var request = store.get(videoId);
|
||||||
|
request.onsuccess = function (event) {
|
||||||
|
var video = event.target.result;
|
||||||
|
if (video) {
|
||||||
|
video.watchedAt = Date.now();
|
||||||
|
} else {
|
||||||
|
// Should match WatchVideo.vue
|
||||||
|
video = {
|
||||||
|
videoId: videoId,
|
||||||
|
title: instance.item.title,
|
||||||
|
duration: instance.item.duration,
|
||||||
|
thumbnail: instance.item.thumbnailUrl,
|
||||||
|
uploaderUrl: instance.item.uploaderUrl,
|
||||||
|
uploaderName: instance.item.uploader,
|
||||||
|
watchedAt: Date.now(),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
// Set time to end for shouldShowVideo
|
||||||
|
video.currentTime = instance.item.duration;
|
||||||
|
// Save
|
||||||
|
store.put(video);
|
||||||
|
// Disappear if hideWatched is on
|
||||||
|
instance.$emit("update:watched", [instance.item.url]);
|
||||||
|
instance.shouldShowVideo();
|
||||||
|
};
|
||||||
|
}
|
||||||
|
},
|
||||||
},
|
},
|
||||||
components: { PlaylistAddModal },
|
components: { PlaylistAddModal },
|
||||||
};
|
};
|
||||||
|
|
|
@ -120,6 +120,8 @@
|
||||||
"show_chapters": "Chapters",
|
"show_chapters": "Chapters",
|
||||||
"store_search_history": "Store Search history",
|
"store_search_history": "Store Search history",
|
||||||
"hide_watched": "Hide watched videos in the feed",
|
"hide_watched": "Hide watched videos in the feed",
|
||||||
|
"mark_as_watched": "Mark as Watched",
|
||||||
|
"mark_as_unwatched": "Mark as Unwatched",
|
||||||
"documentation": "Documentation",
|
"documentation": "Documentation",
|
||||||
"status_page": "Status",
|
"status_page": "Status",
|
||||||
"source_code": "Source code",
|
"source_code": "Source code",
|
||||||
|
|
|
@ -2,6 +2,7 @@ import { createApp } from "vue";
|
||||||
import { library } from "@fortawesome/fontawesome-svg-core";
|
import { library } from "@fortawesome/fontawesome-svg-core";
|
||||||
import {
|
import {
|
||||||
faEye,
|
faEye,
|
||||||
|
faEyeSlash,
|
||||||
faThumbtack,
|
faThumbtack,
|
||||||
faCheck,
|
faCheck,
|
||||||
faHeart,
|
faHeart,
|
||||||
|
@ -26,6 +27,7 @@ import { faGithub, faBitcoin, faYoutube } from "@fortawesome/free-brands-svg-ico
|
||||||
import { FontAwesomeIcon } from "@fortawesome/vue-fontawesome";
|
import { FontAwesomeIcon } from "@fortawesome/vue-fontawesome";
|
||||||
library.add(
|
library.add(
|
||||||
faEye,
|
faEye,
|
||||||
|
faEyeSlash,
|
||||||
faGithub,
|
faGithub,
|
||||||
faBitcoin,
|
faBitcoin,
|
||||||
faThumbtack,
|
faThumbtack,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue