Skip to content

Commit

Permalink
chore(home): display the number of videos to remove on confirmation m…
Browse files Browse the repository at this point in the history
…odals of the watch later view
  • Loading branch information
AXeL-dev committed Jul 1, 2022
1 parent c6dddc6 commit 2910a20
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@ import { selectViewFilters } from 'store/selectors/settings';
import { setViewFilters } from 'store/reducers/settings';
import { HomeView, Nullable } from 'types';

interface RecentViewActionsProps {
hasVideos: boolean;
}
interface RecentViewActionsProps {}

function RecentViewActions(props: RecentViewActionsProps) {
const filters = useAppSelector(selectViewFilters(HomeView.Recent));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,12 @@ import {
import { Nullable } from 'types';
import { downloadFile } from 'helpers/file';

interface WatchLaterViewOptionsProps {}
interface WatchLaterViewOptionsProps {
videosCount: number;
}

function WatchLaterViewOptions(props: WatchLaterViewOptionsProps) {
const { videosCount } = props;
const watchLaterVideos = useAppSelector(selectWatchLaterVideos());
const viewedCount = useAppSelector(selectViewedWatchLaterVideosCount);
const dispatch = useAppDispatch();
Expand Down Expand Up @@ -72,7 +75,7 @@ function WatchLaterViewOptions(props: WatchLaterViewOptionsProps) {
const handleRemoveAll = () => {
setConfirmationDialogProps({
open: true,
title: 'Remove all videos',
title: `Remove all videos (${videosCount})`,
text: 'Are you sure that you want to remove all the videos from the watch later list?',
onClose: (confirmed) => {
if (confirmed) {
Expand All @@ -90,7 +93,7 @@ function WatchLaterViewOptions(props: WatchLaterViewOptionsProps) {
const handleRemoveViewed = () => {
setConfirmationDialogProps({
open: true,
title: 'Remove viewed videos',
title: `Remove viewed videos (${viewedCount})`,
text: 'Are you sure that you want to remove all viewed videos from the watch later list?',
onClose: (confirmed) => {
if (confirmed) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import WatchLaterViewFilters from './WatchLaterViewFilters';
import WatchLaterViewOptions from './WatchLaterViewOptions';

interface WatchLaterViewActionsProps {
hasVideos: boolean;
videosCount: number;
}

function WatchLaterViewActions(props: WatchLaterViewActionsProps) {
const { hasVideos } = props;
const { videosCount } = props;

return (
<Box
Expand All @@ -19,7 +19,9 @@ function WatchLaterViewActions(props: WatchLaterViewActionsProps) {
}}
>
<WatchLaterViewFilters />
{hasVideos ? <WatchLaterViewOptions /> : null}
{videosCount > 0 ? (
<WatchLaterViewOptions videosCount={videosCount} />
) : null}
</Box>
);
}
Expand Down
8 changes: 3 additions & 5 deletions src/ui/components/pages/Home/TabActions/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,15 @@ interface TabActionsProps {
}

function TabActions(props: TabActionsProps) {
const { tab, recentVideosCount, watchLaterVideosCount } = props;
const { tab, watchLaterVideosCount } = props;
const channelsCount = useAppSelector(selectActiveChannelsCount);

switch (tab) {
case HomeView.Recent:
return channelsCount > 0 ? (
<RecentViewActions hasVideos={recentVideosCount > 0} />
) : null;
return channelsCount > 0 ? <RecentViewActions /> : null;
case HomeView.WatchLater:
return channelsCount > 0 ? (
<WatchLaterViewActions hasVideos={watchLaterVideosCount > 0} />
<WatchLaterViewActions videosCount={watchLaterVideosCount} />
) : null;
default:
return null;
Expand Down

0 comments on commit 2910a20

Please sign in to comment.