Browse Source

penis man

Andrew 1 week ago
parent
commit
f8d4637745

+ 24 - 24
package-lock.json

@@ -11,6 +11,7 @@
         "animejs": "^4.0.2",
         "axios": "^1.10.0",
         "js-cookie": "^3.0.5",
+        "nanoid": "^5.1.5",
         "vue": "^3.5.17",
         "vue-router": "^4.5.1"
       },
@@ -1753,25 +1754,6 @@
         "vue": "^3.0.0"
       }
     },
-    "node_modules/@vue/devtools-core/node_modules/nanoid": {
-      "version": "5.1.5",
-      "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-5.1.5.tgz",
-      "integrity": "sha512-Ir/+ZpE9fDsNH0hQ3C68uyThDXzYcim2EqcZ8zn8Chtt1iylPT9xXJB0kPCnqzgcEGikO9RxSrh63MsmVCU7Fw==",
-      "dev": true,
-      "funding": [
-        {
-          "type": "github",
-          "url": "https://github.com/sponsors/ai"
-        }
-      ],
-      "license": "MIT",
-      "bin": {
-        "nanoid": "bin/nanoid.js"
-      },
-      "engines": {
-        "node": "^18 || >=20"
-      }
-    },
     "node_modules/@vue/devtools-kit": {
       "version": "7.7.7",
       "resolved": "https://registry.npmjs.org/@vue/devtools-kit/-/devtools-kit-7.7.7.tgz",
@@ -3481,9 +3463,9 @@
       "license": "MIT"
     },
     "node_modules/nanoid": {
-      "version": "3.3.11",
-      "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.11.tgz",
-      "integrity": "sha512-N8SpfPUnUp1bK+PMYW8qSWdl9U+wwNWI4QKxOYDy9JAro3WMX7p2OeVRF9v+347pnakNevPmiHhNmZ2HbFA76w==",
+      "version": "5.1.5",
+      "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-5.1.5.tgz",
+      "integrity": "sha512-Ir/+ZpE9fDsNH0hQ3C68uyThDXzYcim2EqcZ8zn8Chtt1iylPT9xXJB0kPCnqzgcEGikO9RxSrh63MsmVCU7Fw==",
       "funding": [
         {
           "type": "github",
@@ -3492,10 +3474,10 @@
       ],
       "license": "MIT",
       "bin": {
-        "nanoid": "bin/nanoid.cjs"
+        "nanoid": "bin/nanoid.js"
       },
       "engines": {
-        "node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1"
+        "node": "^18 || >=20"
       }
     },
     "node_modules/natural-compare": {
@@ -3750,6 +3732,24 @@
         "node": ">=4"
       }
     },
+    "node_modules/postcss/node_modules/nanoid": {
+      "version": "3.3.11",
+      "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.11.tgz",
+      "integrity": "sha512-N8SpfPUnUp1bK+PMYW8qSWdl9U+wwNWI4QKxOYDy9JAro3WMX7p2OeVRF9v+347pnakNevPmiHhNmZ2HbFA76w==",
+      "funding": [
+        {
+          "type": "github",
+          "url": "https://github.com/sponsors/ai"
+        }
+      ],
+      "license": "MIT",
+      "bin": {
+        "nanoid": "bin/nanoid.cjs"
+      },
+      "engines": {
+        "node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1"
+      }
+    },
     "node_modules/prelude-ls": {
       "version": "1.2.1",
       "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.2.1.tgz",

+ 1 - 0
package.json

@@ -14,6 +14,7 @@
     "animejs": "^4.0.2",
     "axios": "^1.10.0",
     "js-cookie": "^3.0.5",
+    "nanoid": "^5.1.5",
     "vue": "^3.5.17",
     "vue-router": "^4.5.1"
   },

+ 1 - 1
src/components/DesktopSidebar.vue

@@ -34,7 +34,7 @@ export default defineComponent({
             if (searchQuery.value.trim() === '') return this.router.push('/search')
             return this.router.push({
                 name: 'search',
-                params: { searchQuery: searchQuery.value.trim() },
+                query: { searchQuery: searchQuery.value },
             });
         },
     },

+ 4 - 5
src/components/Player.vue

@@ -1,7 +1,7 @@
 <script>
 import { defineComponent } from 'vue'
 import { config } from '@/main.js'
-import { animate } from 'animejs'
+import { animate, createSpring } from 'animejs'
 
 // icon imports
 import Heart from '@/components/icons/Heart.vue'
@@ -38,12 +38,12 @@ export default defineComponent({
             size,
             config,
             screenHeight,
-            videoHeight,
+            videoHeight
         }
     },
     methods: {
-        handlePlay() {
-            const video = document.getElementById('video-player')
+        handlePlay(event) {
+            const video = event.target;
 
             if (video.paused) {
                 video.play()
@@ -58,7 +58,6 @@ export default defineComponent({
 })
 
 function animateDetail(id) {
-    console.log('monkey')
     animate(id, {
         width: {
             from: '50px',

+ 183 - 3
src/components/VideoFeed.vue

@@ -1,15 +1,195 @@
-<script lang="ts">
-import {defineComponent} from 'vue'
+<script>
+import { defineComponent } from 'vue'
+import Player from '@/components/Player.vue'
+import { config } from '@/main.js'
+import { animate, createSpring } from 'animejs'
 
 export default defineComponent({
-name: "VideoFeed"
+    name: 'VideoFeed',
+    data() {
+        return {
+            player1: null,
+            player2: null,
+            config,
+            animating: false,
+            feedIndex: 0,
+            currentPlayer: "player1",
+            stiffness: 550,
+            damping: 15
+        }
+    },
+    props: {
+        feed: {
+            type: Object,
+            required: true
+        }
+    },
+    methods: {
+        scrollDown() {
+            if(this.animating) return;
+            if (this.feedIndex >= this.feed.length - 1) {
+                console.log("Reached end of feed");
+                this.animating = false;
+                return;
+            }
+
+            this.animating = true;
+            const screenHeight = window.innerHeight;
+            const inactivePlayer = this.currentPlayer === "player1" ? ".player2" : ".player1";
+            const activePlayer = this.currentPlayer === "player1" ? ".player1" : ".player2";
+            const nextIndex = this.feedIndex + 1; // calculate this early!
+
+            // Move the inactive player down
+            animate(inactivePlayer, {
+                translateY: screenHeight,
+                duration: 0
+            });
+
+            if (this.currentPlayer === "player1") {
+                this.player2 = this.feed[nextIndex];
+            } else {
+                this.player1 = this.feed[nextIndex];
+            }
+
+            // animate players
+            animate(activePlayer, {
+                translateY: [0, -screenHeight],
+                duration: 500,
+                ease: createSpring({stiffness: this.stiffness, damping: this.damping})
+            });
+
+            animate(inactivePlayer, {
+                translateY: [screenHeight, 0],
+                duration: 500,
+                ease: createSpring({stiffness: this.stiffness, damping: this.damping})
+            }).then(() => {
+                const nextPlayer = this.currentPlayer === "player1" ? "player2" : "player1";
+                this.feedIndex = nextIndex;
+                this.currentPlayer = nextPlayer;
+                this.animating = false;
+            });
+        },
+        scrollUp() {
+            if(this.animating) return;
+            if (this.feedIndex <= 0) {
+                console.log("Reached beginning of feed");
+                this.animating = false;
+                return;
+            }
+
+            this.animating = true;
+            const screenHeight = window.innerHeight;
+            const inactivePlayer = this.currentPlayer === "player1" ? ".player2" : ".player1";
+            const activePlayer = this.currentPlayer === "player1" ? ".player1" : ".player2";
+            const nextIndex = this.feedIndex - 1; // calculate this early!
+
+            // Move the inactive player up
+            animate(inactivePlayer, {
+                translateY: -screenHeight,
+                duration: 0
+            });
+
+            if (this.currentPlayer === "player1") {
+                this.player2 = this.feed[nextIndex];
+            } else {
+                this.player1 = this.feed[nextIndex];
+            }
+
+            // animate players
+            animate(activePlayer, {
+                translateY: [0, screenHeight],
+                duration: 500,
+                ease: createSpring({stiffness: this.stiffness, damping: this.damping})
+            });
+
+            animate(inactivePlayer, {
+                translateY: [-screenHeight, 0],
+                duration: 500,
+                ease: createSpring({stiffness: this.stiffness, damping: this.damping})
+            }).then(() => {
+                const nextPlayer = this.currentPlayer === "player1" ? "player2" : "player1";
+                this.feedIndex = nextIndex;
+                this.currentPlayer = nextPlayer;
+                this.animating = false;
+            });
+        },
+        handleScroll(event) {
+            if(this.animating) return;
+
+            if(event.deltaY > 0) {
+                this.scrollDown();
+            } else {
+                this.scrollUp();
+            }
+        },
+    },
+    created () {
+        // initial setup for players
+        this.player1 = this.feed[this.feedIndex];
+        this.player2 = this.feed[this.feedIndex + 1];
+        document.addEventListener("DOMContentLoaded", () => {
+            animate(".player2", {
+                translateY: window.innerHeight,
+                duration: 1
+            })
+        })
+
+        document.addEventListener("wheel", this.handleScroll);
+    },
+    components: { Player },
 })
 </script>
 
 <template>
+    <div id="player-container">
+        <Player
+            class-name="player1 player-wrapper"
+            :video="player1?.id ?? 1"
+            :key="player1?.id ?? 1"
+            :information="{
+                title: player1?.title ?? '',
+                description: player1?.description ?? '',
+                likes: player1?.likes ?? 13242,
+                dislikes: player1?.dislikes ?? 13242,
+                comments: player1?.comments ?? 13242,
+                shares: player1?.shares ?? 13242,
+                author: player1?.author?.username ?? 'john clapper',
+                authorAvatar: `${config.serverURL}/account/${player1?.author?.id ?? 1}/picture`,
+            }"
+        />
 
+        <Player
+            class-name="player2 player-wrapper"
+            :video="player2?.id ?? 1"
+            :key="player2?.id ?? 1"
+            :information="{
+                title: player2?.title ?? '',
+                description: player2?.description ?? '',
+                likes: player2?.likes ?? 13242,
+                dislikes: player2?.dislikes ?? 13242,
+                comments: player2?.comments ?? 13242,
+                shares: player2?.shares ?? 13242,
+                author: player2?.author?.username ?? 'johnclapper',
+                authorAvatar: `${config.serverURL}/account/${player2?.author?.id ?? 1}/picture`,
+            }"
+        />
+    </div>
 </template>
 
 <style scoped>
+.player-wrapper {
+    position: absolute;
+    width: 100%;
+    height: 100vh;
+    top: 0;
+    left: 0;
+}
+
+.player1 {
+    position: absolute;
+}
 
+.player2 {
+    position: absolute;
+}
 </style>

+ 6 - 1
src/components/VideoSearchResult.vue

@@ -5,6 +5,7 @@ import Deodorant from '@/components/icons/Deodorant.vue'
 import Heart from '@/components/icons/Heart.vue'
 import Contact from '@/components/icons/Contact.vue'
 import ArrowRight from '@/components/icons/ArrowRight.vue'
+import { useRouter } from 'vue-router'
 
 export default defineComponent({
     name: 'VideoSearchResult',
@@ -14,6 +15,10 @@ export default defineComponent({
             size: 30
         }
     },
+    setup() {
+        const router = useRouter()
+        return { router }
+    },
     props: {
         id: {
             type: Number,
@@ -54,7 +59,7 @@ export default defineComponent({
         <img :src="`${config.serverURL}/video/${id}/thumbnail`" class="search-result-thumbnail" />
         <div class="search-result-details">
             <h1>{{title}}</h1>
-            <span class="search-result-author">
+            <span class="search-result-author" @click="this.router.push(`/profile/${id}`)">
 					<img :src="`${config.serverURL}/account/${id}/picture`" class="search-result-author-image" />
 					<p>{{author}}</p>
 				</span>

+ 1 - 1
src/router/index.js

@@ -25,7 +25,7 @@ const router = createRouter({
         {
             path: '/login',
             name: 'login',
-            component: LoginView,
+            component: LoginView
         },
     ],
 })

+ 36 - 4
src/views/HomeView.vue

@@ -2,18 +2,50 @@
 import { defineComponent } from 'vue'
 import Sidebar from '@/components/Sidebar.vue'
 import Player from '@/components/Player.vue'
+import VideoFeed from '@/components/VideoFeed.vue'
 
 export default defineComponent({
     name: 'HomeView',
-    components: { Player, Sidebar },
+    components: { VideoFeed, Player, Sidebar },
 })
 </script>
 
 <template>
     <div class="main">
         <Sidebar />
-        <Player :video="1" :information="{
-            'id': 1, 'title': 'Habibi video', 'description': 'iga', 'likes': 1000000, 'dislikes': 0, 'comments': 1, 'shares': 1, 'author': { 'id': 1, 'pictureHash': null, 'username': 'hajeebtok' }
-        }"/>
+        <VideoFeed
+            :feed="
+                [{
+                    id: 1,
+                    title: 'Habibi video',
+                    description: 'niga',
+                    likes: 1000000,
+                    dislikes: 0,
+                    comments: 1,
+                    shares: 1,
+                    author: { id: 1, pictureHash: null, username: 'hajeebtok' },
+                },
+                {
+                    title: '10 thousan nigger',
+                    description: 'today. i will sink 10 children in seaman',
+                    likes: 100,
+                    dislikes: 1,
+                    comments: 0,
+                    shares: 0,
+                    id: 2,
+                    author: { id: 6, pictureHash: null, username: 'jimmy_beast.58' },
+                },
+                {
+                    id: 3,
+                    title: 'third video',
+                    description: 'niga',
+                    likes: 1000000,
+                    dislikes: 0,
+                    comments: 1,
+                    shares: 1,
+                    author: { id: 1, pictureHash: null, username: 'hajeebtok' },
+                }]
+            "
+        />
     </div>
 </template>

+ 2 - 6
src/views/ProfileView.vue

@@ -49,16 +49,12 @@ export default defineComponent({
             })
             .then((response) => {
                 if (response.data.error)
-                    return (this.videos = {
-                        username: 'profile not found',
-                        followers: 'profile not found',
-                        following: 'profile not found',
-                    })
+                    return (this.videos = [])
                 this.videos = response.data
                 console.log(this.videos)
             })
             .catch((error) => {
-                this.videos = {};
+                this.videos = [];
 
                 console.error('Error in getting profile id ' + this.$route.params.id + ' videos!')
                 console.error(error)

+ 13 - 7
src/views/SearchView.vue

@@ -10,12 +10,13 @@ export default defineComponent({
     name: 'SearchView',
     components: { VideoSearchResult, Sidebar, SearchIcon },
     methods: {
-        async search() {
+        async search(searchQuery = null) {
             let searchBar;
-            if(!this.$route.params.searchQuery) searchBar = document.getElementById('search-bar')
-            else searchBar = { value: this.$route.params.searchQuery }
-            const searchStatus = document.getElementById('search-status')
+            if(searchQuery == null) { searchBar = document.getElementById('search-bar') }
+            else { searchBar = { value: searchQuery } }
+            const searchStatus = document.getElementById('search-status');
 
+            console.log(searchBar.value);
             if (searchBar.value.trim() === '') return (searchStatus.innerText = `no`)
             searchStatus.innerText = 'searching!!'
             const response = await axios.post(`${config.serverURL}/video/search`, {
@@ -28,7 +29,6 @@ export default defineComponent({
 
             this.searchResults = response.data
             searchStatus.innerText = '';
-            this.$route.params.searchQuery = null
         },
     },
     data() {
@@ -37,7 +37,13 @@ export default defineComponent({
         }
     },
     created () {
-        if(this.$route.params.searchQuery) search();
+        console.log(window.location.search);
+        const searchParams = new URLSearchParams(window.location.search);
+        if(searchParams.get('searchQuery')) {
+            document.addEventListener("DOMContentLoaded", () => {
+                this.search(searchParams.get('searchQuery'));
+            });
+        }
     }
 })
 </script>
@@ -47,7 +53,7 @@ export default defineComponent({
         <Sidebar />
         <div class="search-container">
             <div class="search-bar-container">
-                <button class="search-button" @click="search">
+                <button class="search-button" @click="search()">
                     <SearchIcon :size="50" />
                 </button>
                 <input type="text" placeholder="Search" class="search-bar" id="search-bar" />