mirror of
				https://github.com/TeamPiped/Piped.git
				synced 2025-11-04 06:31:55 +00:00 
			
		
		
		
	Make timestamps in comments seek instead of reload
This commit is contained in:
		@@ -71,6 +71,7 @@ export default {
 | 
			
		||||
        uploader: { type: String, default: null },
 | 
			
		||||
        videoId: { type: String, default: null },
 | 
			
		||||
    },
 | 
			
		||||
    emits: ["seek"],
 | 
			
		||||
    data() {
 | 
			
		||||
        return {
 | 
			
		||||
            loadingReplies: false,
 | 
			
		||||
@@ -79,6 +80,21 @@ export default {
 | 
			
		||||
            nextpage: null,
 | 
			
		||||
        };
 | 
			
		||||
    },
 | 
			
		||||
    mounted() {
 | 
			
		||||
        const thisComment = this;
 | 
			
		||||
        this.$el.querySelectorAll("a").forEach(elem => {
 | 
			
		||||
            if (elem.innerText.match(/(?:[\d]{1,2}:)?(?:[\d]{1,2}):(?:[\d]{1,2})/)) {
 | 
			
		||||
                elem.addEventListener("click", function (event) {
 | 
			
		||||
                    if (!event || !event.target) return;
 | 
			
		||||
                    if (!event.target.getAttribute("href").match(/(?<=t=)\d{1,}/)) return;
 | 
			
		||||
 | 
			
		||||
                    const time = parseInt(event.target.getAttribute("href").match(/(?<=t=)\d{1,}/)[0]);
 | 
			
		||||
                    thisComment.$emit("seek", time);
 | 
			
		||||
                    event.preventDefault();
 | 
			
		||||
                });
 | 
			
		||||
            }
 | 
			
		||||
        });
 | 
			
		||||
    },
 | 
			
		||||
    methods: {
 | 
			
		||||
        async loadReplies() {
 | 
			
		||||
            if (!this.showingReplies && this.loadingReplies) {
 | 
			
		||||
 
 | 
			
		||||
@@ -186,6 +186,7 @@
 | 
			
		||||
                    :comment="comment"
 | 
			
		||||
                    :uploader="video.uploader"
 | 
			
		||||
                    :video-id="getVideoId()"
 | 
			
		||||
                    @seek="navigate"
 | 
			
		||||
                />
 | 
			
		||||
            </div>
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user