Browse Source

fix personal data types file

Klaudiusz Dembler 4 năm trước cách đây
mục cha
commit
ec1f77adcc

+ 1 - 1
src/hooks/usePersonalData/localStorageClient/localStorageClient.tsx

@@ -46,7 +46,7 @@ const watchedVideo = async (id: string) => {
 const setWatchedVideo = async (
   __typename: typeof COMPLETED_VIDEO | typeof INTERRUPTED_VIDEO,
   id: string,
-  timestamp: number
+  timestamp?: number
 ) => {
   const currentVideos = await watchedVideos()
   const currentVideo = currentVideos.find((v) => v.id === id)

+ 11 - 13
src/hooks/usePersonalData/localStorageClient/types.d.ts → src/hooks/usePersonalData/localStorageClient/types.ts

@@ -5,21 +5,21 @@ type WatchedVideoFields = {
 export const INTERRUPTED_VIDEO = 'INTERRUPTED'
 export const COMPLETED_VIDEO = 'COMPLETED'
 
-type InterruptedVideo = WatchedVideoFields & {
+export type InterruptedVideo = WatchedVideoFields & {
   __typename: typeof INTERRUPTED_VIDEO
   timestamp: number
 }
-type CompletedVideo = WatchedVideoFields & {
+export type CompletedVideo = WatchedVideoFields & {
   __typename: typeof COMPLETED_VIDEO
   id: string
 }
-type WatchedVideo = InterruptedVideo | CompletedVideo
+export type WatchedVideo = InterruptedVideo | CompletedVideo
 
-type FollowedChannel = {
+export type FollowedChannel = {
   id: string
 }
 
-interface PersonalDataClient {
+export interface PersonalDataClient {
   // ==== watched videos ====
 
   // get all the interrupted or completed videos
@@ -34,12 +34,12 @@ interface PersonalDataClient {
   // get status of one specific watched video
   watchedVideo: (id: string) => Promise<WatchedVideo | null>
 
-  // mark the video as interrupted
-  setWatchedVideo: (__typename: typeof INTERRUPTED_VIDEO, id: string, timestamp: number) => Promise<void>
-
-  // mark the video as completed
-  setWatchedVideo: (__typename: typeof COMPLETED_VIDEO, id: string) => Promise<void>
-
+  // mark the video as interrupted or completed
+  setWatchedVideo: (
+    __typename: typeof INTERRUPTED_VIDEO | typeof COMPLETED_VIDEO,
+    id: string,
+    timestamp?: number
+  ) => Promise<void>
   // ==== followed channels ====
 
   // get all the followed channels
@@ -51,5 +51,3 @@ interface PersonalDataClient {
   // get the following status of one specific channel
   isFollowingChannel: (id: string) => Promise<boolean>
 }
-
-export type UsePersonalData = () => UserPersonalData