import React from 'react'; import style from './RandomPage.module.css'; import SideBar, {SideBarTitle} from '../../elements/SideBar/SideBar'; import Tag from '../../elements/Tag/Tag'; import PageTitle from '../../elements/PageTitle/PageTitle'; import VideoContainer from '../../elements/VideoContainer/VideoContainer'; import {APINode, callAPI} from '../../utils/Api'; import {TagType} from '../../types/VideoTypes'; import {VideoTypes} from '../../types/ApiTypes'; import {addKeyHandler, removeKeyHandler} from '../../utils/ShortkeyHandler'; interface state { videos: VideoTypes.VideoUnloadedType[]; tags: TagType[]; } interface GetRandomMoviesType { Videos: VideoTypes.VideoUnloadedType[]; Tags: TagType[]; } /** * Randompage shuffles random viedeopreviews and provides a shuffle btn */ class RandomPage extends React.Component<{}, state> { readonly LoadNR = 3; // random seed to load videos, remains page reload. seed = this.genRandInt(); constructor(props: {}) { super(props); // get previously stored location from localstorage const storedseed = global.localStorage.getItem('randpageseed'); if (storedseed != null) { this.seed = parseInt(storedseed, 10); } this.state = { videos: [], tags: [] }; this.keypress = this.keypress.bind(this); } genRandInt(): number { return Math.floor(Math.random() * 2147483647) + 1; } componentDidMount(): void { addKeyHandler(this.keypress); this.loadShuffledvideos(this.LoadNR); } componentWillUnmount(): void { removeKeyHandler(this.keypress); } render(): JSX.Element { return (