Skip to content

Commit

Permalink
refactor: enhance legacy typing
Browse files Browse the repository at this point in the history
  • Loading branch information
AXeL-dev committed Oct 15, 2022
1 parent e823934 commit 25264b0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/store/utils/preload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
VideosSeniority,
HomeView,
LegacySettings,
LegacyVideoFlags,
} from 'types';
import { log } from 'helpers/logger';

Expand Down Expand Up @@ -96,8 +97,7 @@ const replaceLegacySettings = (

const replaceViewedFlagWithSeen = (videos: VideoCache[]) => {
return videos.map((video) => {
const { viewed, ...flags } =
(video.flags as typeof video.flags & { viewed: boolean }) || {};
const { viewed, ...flags } = (video.flags as LegacyVideoFlags) || {};
return {
...video,
flags: viewed
Expand Down
5 changes: 5 additions & 0 deletions src/types/legacy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
ViewSorting,
WatchLaterViewFilters,
} from './Settings';
import { VideoFlags } from './Video';

export interface LegacySettings extends Omit<Settings, 'viewOptions'> {
recentVideosSeniority: VideosSeniority;
Expand All @@ -17,3 +18,7 @@ export interface LegacySettings extends Omit<Settings, 'viewOptions'> {
watchLaterViewSorting: ViewSorting;
bookmarksViewSorting: ViewSorting;
}

export type LegacyVideoFlags = VideoFlags & {
viewed: boolean;
};

0 comments on commit 25264b0

Please sign in to comment.