* ui: start highlight ui * ui: tag items * ui: connecting highlights to notes api... * Highlight feature refinements (#2948) * ui: move clips player to foss, connect notes api to hl * ui: tune note/hl editing, prevent zoom slider body from jumping around * ui: safe check for tag * ui: fix thumbnail gen * ui: fix thumbnail gen * ui: make player modal wider, add shadow * ui: custom warn barge for clips * ui: swap icon for note event wrapper * ui: rm other, fix cancel * ui: moving around creation modal * ui: bg tint * ui: rm disabled for text btn * ui: fix ownership sorting * ui: close player on bg click * ui: fix query, fix min distance for default range * ui: move hl list header out of list comp * ui: spot list header segmented size * Various improvements in highlights (#2955) * ui: update hl in hlPanel comp * ui: rm debug * ui: fix icons file --------- Co-authored-by: Sudheer Salavadi <connect.uxmaster@gmail.com>
61 lines
1.9 KiB
TypeScript
61 lines
1.9 KiB
TypeScript
import React, {useEffect, useState} from 'react';
|
|
import cn from 'classnames';
|
|
import {observer} from 'mobx-react-lite';
|
|
import {Button} from 'UI';
|
|
import stl from './AutoplayTimer.module.css';
|
|
import clsOv from './overlay.module.css';
|
|
import AutoplayToggle from 'Shared/AutoplayToggle';
|
|
import {useStore} from 'App/mstore';
|
|
|
|
function AutoplayTimer({history}: any) {
|
|
let timer: NodeJS.Timer;
|
|
const [cancelled, setCancelled] = useState(false);
|
|
const [counter, setCounter] = useState(5);
|
|
const {clipStore} = useStore();
|
|
|
|
useEffect(() => {
|
|
if (counter > 0) {
|
|
timer = setTimeout(() => {
|
|
setCounter(counter - 1);
|
|
}, 1000);
|
|
}
|
|
|
|
if (counter === 0) {
|
|
clipStore.next();
|
|
}
|
|
|
|
return () => clearTimeout(timer);
|
|
}, [counter]);
|
|
|
|
const cancel = () => {
|
|
clearTimeout(timer);
|
|
setCancelled(true);
|
|
};
|
|
|
|
if (cancelled) return null;
|
|
|
|
return (
|
|
<div className={cn(clsOv.overlay, stl.overlayBg, "z-10")}>
|
|
<div className="border p-5 shadow-lg bg-white rounded">
|
|
<div className="mb-5">
|
|
Autoplaying next clip in <span className="font-medium">{counter}</span> seconds
|
|
</div>
|
|
|
|
<div className="flex items-center justify-between">
|
|
<div className="mr-10">
|
|
<AutoplayToggle/>
|
|
</div>
|
|
<div className="flex items-center">
|
|
<Button variant="text-primary" onClick={cancel}>
|
|
Cancel
|
|
</Button>
|
|
<div className="px-2"/>
|
|
<Button variant="outline" onClick={() => clipStore.next()}>Play Now</Button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
);
|
|
}
|
|
|
|
export default observer(AutoplayTimer);
|