mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-11-25 17:36:18 -05:00
Moving main ThemeContext.Provider into Theme module. Using live elapsed timers on Downloads page.
This commit is contained in:
parent
854cdf597a
commit
fdfd1e98fc
9 changed files with 163 additions and 91 deletions
|
|
@ -1,5 +1,6 @@
|
|||
import {useEffect, useState} from "react";
|
||||
import {
|
||||
favoriteVideo,
|
||||
fetchDomains,
|
||||
filesSearch,
|
||||
getArchive,
|
||||
|
|
@ -25,7 +26,7 @@ import {
|
|||
} from "../api";
|
||||
import {createSearchParams, useSearchParams} from "react-router-dom";
|
||||
import {toast} from "react-semantic-toasts";
|
||||
import {enumerate, humanFileSize, secondsToString} from "../components/Common";
|
||||
import {enumerate, humanFileSize, secondsToFullDuration} from "../components/Common";
|
||||
|
||||
const calculatePage = (offset, limit) => {
|
||||
return offset && limit ? Math.round((offset / limit) + 1) : 1;
|
||||
|
|
@ -265,11 +266,24 @@ export const useVideo = (videoId) => {
|
|||
}
|
||||
}
|
||||
|
||||
const setFavorite = async (value) => {
|
||||
if (!videoFile) {
|
||||
console.error('No video to favorite');
|
||||
return
|
||||
}
|
||||
try {
|
||||
await favoriteVideo(videoFile.video.id, value);
|
||||
fetchVideo();
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
fetchVideo();
|
||||
}, [videoId]);
|
||||
|
||||
return {videoFile, prevFile, nextFile};
|
||||
return {videoFile, prevFile, nextFile, setFavorite};
|
||||
}
|
||||
|
||||
export const useChannel = (channel_id) => {
|
||||
|
|
@ -648,7 +662,7 @@ export const useVideoStatistics = () => {
|
|||
const fetchStatistics = async () => {
|
||||
try {
|
||||
let stats = await getStatistics();
|
||||
stats.videos.sum_duration = secondsToString(stats.videos.sum_duration);
|
||||
stats.videos.sum_duration = secondsToFullDuration(stats.videos.sum_duration);
|
||||
stats.videos.sum_size = humanFileSize(stats.videos.sum_size, true);
|
||||
stats.videos.max_size = humanFileSize(stats.videos.max_size, true);
|
||||
stats.historical.average_size = humanFileSize(stats.historical.average_size, true);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue