Ver Fonte

add personal data interface (#173)

Klaudiusz Dembler há 4 anos atrás
pai
commit
658785aabe
2 ficheiros alterados com 60 adições e 0 exclusões
  1. 5 0
      src/hooks/personalData/index.ts
  2. 55 0
      src/hooks/personalData/types.d.ts

+ 5 - 0
src/hooks/personalData/index.ts

@@ -0,0 +1,5 @@
+import { UsePersonalData } from './types'
+export * from './types'
+
+// @ts-ignore replace with the implementation once ready
+export const usePersonalData: UsePersonalData = null

+ 55 - 0
src/hooks/personalData/types.d.ts

@@ -0,0 +1,55 @@
+type WatchedVideoFields = {
+  id: string
+}
+
+export const INTERRUPTED_VIDEO = 'INTERRUPTED'
+export const COMPLETED_VIDEO = 'COMPLETED'
+
+type InterruptedVideo = WatchedVideoFields & {
+  __typename: typeof INTERRUPTED_VIDEO
+  timestamp: number
+}
+type CompletedVideo = WatchedVideoFields & {
+  __typename: typeof INTERRUPTED_VIDEO
+  id: string
+}
+type WatchedVideo = InterruptedVideo | CompletedVideo
+
+type FollowedChannel = {
+  id: string
+}
+
+interface UserPersonalData {
+  // ==== watched videos ====
+
+  // get all the interrupted or completed videos
+  watchedVideos: () => Promise<WatchedVideo[]>
+
+  // get all the interrupted videos
+  interruptedVideos: () => Promise<InterruptedVideo[]>
+
+  // get all the completed videos
+  completedVideos: () => Promise<CompletedVideo[]>
+
+  // 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>
+
+  // ==== followed channels ====
+
+  // get all the followed channels
+  followedChannels: () => Promise<FollowedChannel[]>
+
+  // set the channel following status
+  setChannelFollowing: (id: string, follow: boolean) => Promise<void>
+
+  // get the following status of one specific channel
+  isFollowingChannel: (id: string) => Promise<boolean>
+}
+
+export type UsePersonalData = () => UserPersonalData