File size: 5,749 Bytes
1f122c3
 
 
 
1185ec1
1f122c3
 
 
 
 
f27679f
 
 
 
 
 
1f122c3
 
 
38d787b
 
 
 
df83860
a3f1817
 
1f122c3
a3f1817
 
 
 
 
 
 
 
1f122c3
f62b8d3
 
1f122c3
df83860
 
 
9cea1bb
 
 
 
 
 
a3f1817
 
 
38d787b
 
 
a3f1817
8f2b05f
 
 
 
 
 
 
 
 
 
a3f1817
 
 
1f122c3
a3f1817
 
f62b8d3
4c34e70
 
 
f62b8d3
 
1f122c3
 
 
 
 
 
 
 
 
 
 
 
df83860
 
 
 
e40bd21
8f2b05f
b965e2b
a3f1817
 
 
df83860
b965e2b
df83860
 
 
38d787b
 
 
 
 
f27679f
 
 
 
 
 
 
 
 
 
a3f1817
 
 
 
 
 
 
 
 
 
 
 
 
 
1f122c3
a3f1817
1f122c3
 
a3f1817
 
1f122c3
a3f1817
1f122c3
 
f62b8d3
 
 
1f122c3
 
df83860
 
 
 
 
9cea1bb
 
 
 
 
 
 
 
 
 
a3f1817
 
 
 
 
38d787b
 
 
 
 
a3f1817
 
1f122c3
a3f1817
1f122c3
 
 
8f2b05f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
a3f1817
 
 
 
 
 
 
 
 
4c34e70
 
 
 
 
 
 
1f122c3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
"use client"

import { create } from "zustand"

import { ChannelInfo, VideoInfo, InterfaceDisplayMode, InterfaceView, InterfaceMenuMode, InterfaceHeaderMode, CommentInfo, UserInfo } from "@/types/general"

export const useStore = create<{
  displayMode: InterfaceDisplayMode
  setDisplayMode: (displayMode: InterfaceDisplayMode) => void

  headerMode: InterfaceHeaderMode
  setHeaderMode: (headerMode: InterfaceHeaderMode) => void

  menuMode: InterfaceMenuMode
  setMenuMode: (menuMode: InterfaceMenuMode) => void

  view: InterfaceView
  setView: (view?: InterfaceView) => void

  setPathname: (pathname: string) => void

  currentUser?: UserInfo
  setCurrentUser: (currentUser?: UserInfo) => void

  publicChannel?: ChannelInfo
  setPublicChannel: (setPublicChannel?: ChannelInfo) => void

  publicChannels: ChannelInfo[]
  setPublicChannels: (publicChannels?: ChannelInfo[]) => void

  userChannel?: ChannelInfo
  setUserChannel: (userChannel?: ChannelInfo) => void

  userChannels: ChannelInfo[]
  setUserChannels: (userChannels?: ChannelInfo[]) => void

  currentTag?: string
  setCurrentTag: (currentTag?: string) => void

  currentTags: string[]
  setCurrentTags: (currentTags?: string[]) => void

  currentModels: string[]
  setCurrentModels: (currentModels?: string[]) => void

  currentModel?: string
  setCurrentModel: (currentModel?: string) => void

  publicVideo?: VideoInfo
  setPublicVideo: (publicVideo?: VideoInfo) => void

  publicComments: CommentInfo[]
  setPublicComments: (publicComment: CommentInfo[]) => void

  publicVideos: VideoInfo[]
  setPublicVideos: (publicVideos: VideoInfo[]) => void

  publicChannelVideos: VideoInfo[]
  setPublicChannelVideos: (publicChannelVideos: VideoInfo[]) => void

  publicTrack?: VideoInfo
  setPublicTrack: (publicTrack?: VideoInfo) => void

  publicTracks: VideoInfo[]
  setPublicTracks: (publicTracks: VideoInfo[]) => void

  userVideo?: VideoInfo
  setUserVideo: (userVideo?: VideoInfo) => void

  userVideos: VideoInfo[]
  setUserVideos: (userVideos: VideoInfo[]) => void

  recommendedVideos: VideoInfo[]
  setRecommendedVideos: (recommendedVideos: VideoInfo[]) => void

  // currentPrompts: VideoInfo[]
  // setCurrentPrompts: (currentPrompts: VideoInfo[]) => void
}>((set, get) => ({
  displayMode: "desktop",
  setDisplayMode: (displayMode: InterfaceDisplayMode) => {
    set({ displayMode })
  },

  view: "home",
  setView: (view?: InterfaceView) => {
    // TODO: download videos for this new channel
    set({ view: view || "home" })
  },

  setPathname: (pathname: string) => {
    const routes: Record<string, InterfaceView> = {
      "/": "home",
      "/watch": "public_video",
      "/embed": "public_video_embed",
      "/music": "public_music_videos",
      "/channels": "public_channels",
      "/channel": "public_channel",
      "/account": "user_account",
      "/account/channel": "user_channel",
    }

    set({ view: routes[pathname] || "not_found" })
  },

  currentUser: undefined,
  setCurrentUser: (currentUser?: UserInfo) => {
    set({ currentUser })
  },
  
  headerMode: "normal",
  setHeaderMode: (headerMode: InterfaceHeaderMode) => {
    set({ headerMode })
  },

  menuMode: "normal_icon",
  setMenuMode: (menuMode: InterfaceMenuMode) => {
    set({ menuMode })
  },

  publicChannel: undefined,
  setPublicChannel: (publicChannel?: ChannelInfo) => {
    // TODO: download videos for this new channel
    set({ publicChannel })
  },

  publicChannels: [],
  setPublicChannels: (publicChannels: ChannelInfo[] = []) => {
    // TODO: download videos for this new channel
    set({ publicChannels: Array.isArray(publicChannels) ? publicChannels : [] })
  },

  userChannel: undefined,
  setUserChannel: (userChannel?: ChannelInfo) => {
    // TODO: download videos for this new channel
    set({ userChannel })
  },

  userChannels: [],
  setUserChannels: (userChannels: ChannelInfo[] = []) => {
    // TODO: download videos for this new channel
    set({ userChannels: Array.isArray(userChannels) ? userChannels : [] })
  },

  currentTag: undefined,
  setCurrentTag: (currentTag?: string) => {
    set({ currentTag })
  },

  currentTags: [],
  setCurrentTags: (currentTags?: string[]) => {
    set({ currentTags })
  },

  currentModels: [],
  setCurrentModels: (currentModels?: string[]) => {
    set({ currentModels })
  },

  currentModel: undefined,
  setCurrentModel: (currentModel?: string) => {
    set({ currentModel })
  },

  publicVideo: undefined,
  setPublicVideo: (publicVideo?: VideoInfo) => {
    set({ publicVideo })
  },

  publicComments: [],
  setPublicComments: (publicComments: CommentInfo[]) => {
    set({ publicComments })
  },

  publicVideos: [],
  setPublicVideos: (publicVideos: VideoInfo[] = []) => {
    set({
      publicVideos: Array.isArray(publicVideos) ? publicVideos : [] 
    })
  },


  publicTrack: undefined,
  setPublicTrack: (publicTrack?: VideoInfo) => {
    set({ publicTrack })
  },

  publicTracks: [],
  setPublicTracks: (publicTracks: VideoInfo[] = []) => {
    set({
      publicTracks: Array.isArray(publicTracks) ? publicTracks : [] 
    })
  },

  publicChannelVideos: [],
  setPublicChannelVideos: (publicChannelVideos: VideoInfo[] = []) => {
    set({
      publicVideos: Array.isArray(publicChannelVideos) ? publicChannelVideos : [] 
    })
  },

  userVideo: undefined,
  setUserVideo: (userVideo?: VideoInfo) => { set({ userVideo }) },

  userVideos: [],
  setUserVideos: (userVideos: VideoInfo[] = []) => {
    set({
      userVideos: Array.isArray(userVideos) ? userVideos : [] 
    })
  },

  recommendedVideos: [],
  setRecommendedVideos: (recommendedVideos: VideoInfo[]) => {
    set({
      recommendedVideos: Array.isArray(recommendedVideos) ? recommendedVideos : [] 
    })
  },
}))