Spaces:
Running
Running
File size: 7,782 Bytes
1f122c3 ac7030c 1f122c3 f27679f 1f122c3 38d787b 6215321 b8c4528 ac7030c b8c4528 ac7030c b8c4528 38d787b df83860 a3f1817 1f122c3 a3f1817 1f122c3 f62b8d3 1f122c3 df83860 9cea1bb 3d4392e a3f1817 38d787b 3d4392e 09a7c47 8f2b05f ac7030c 8f2b05f ac7030c 8f2b05f ac7030c a3f1817 ac7030c 1f122c3 ac7030c f62b8d3 ac7030c 4c34e70 ac7030c 1f122c3 df83860 f42b4a1 8f2b05f b965e2b 09a7c47 a3f1817 09a7c47 a3f1817 df83860 b965e2b df83860 6215321 b8c4528 ac7030c b8c4528 ac7030c b8c4528 38d787b b8c4528 f27679f a3f1817 1f122c3 a3f1817 1f122c3 a3f1817 1f122c3 a3f1817 1f122c3 f62b8d3 1f122c3 df83860 9cea1bb 3d4392e a3f1817 38d787b 3d4392e 1f122c3 3d4392e 1f122c3 8f2b05f 09a7c47 8f2b05f ac7030c 8f2b05f ac7030c 8f2b05f ac7030c 8f2b05f 3d4392e 8f2b05f a3f1817 ac7030c a3f1817 ac7030c a3f1817 4c34e70 ac7030c 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 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 |
"use client"
import { create } from "zustand"
import { ChannelInfo, MediaInfo, 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
jwtToken: string
setJwtToken: (jwtToken: string) => void
searchQuery: string
setSearchQuery: (searchQuery?: string) => void
showAutocompleteBox: boolean
setShowAutocompleteBox: (showAutocompleteBox: boolean) => void
searchAutocompleteQuery: string
setSearchAutocompleteQuery: (searchAutocompleteQuery?: string) => void
searchAutocompleteResults: MediaInfo[]
setSearchAutocompleteResults: (searchAutocompleteResults: MediaInfo[]) => void
searchResults: MediaInfo[]
setSearchResults: (searchResults: MediaInfo[]) => 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
publicMedia?: MediaInfo
setPublicMedia: (publicMedia?: MediaInfo) => void
publicComments: CommentInfo[]
setPublicComments: (publicComment: CommentInfo[]) => void
publicMedias: MediaInfo[]
setPublicMedias: (publicMedias?: MediaInfo[]) => void
latentMedia?: MediaInfo
setPublicLatentMedia: (latentMedia?: MediaInfo) => void
latentMedias: MediaInfo[]
setPublicLatentMedias: (latentMedias?: MediaInfo[]) => void
publicChannelVideos: MediaInfo[]
setPublicChannelVideos: (publicChannelVideos: MediaInfo[]) => void
publicTrack?: MediaInfo
setPublicTrack: (publicTrack?: MediaInfo) => void
publicTracks: MediaInfo[]
setPublicTracks: (publicTracks: MediaInfo[]) => void
userVideo?: MediaInfo
setUserVideo: (userVideo?: MediaInfo) => void
userVideos: MediaInfo[]
setUserVideos: (userVideos: MediaInfo[]) => void
recommendedVideos: MediaInfo[]
setRecommendedVideos: (recommendedVideos: MediaInfo[]) => void
// currentPrompts: MediaInfo[]
// setCurrentPrompts: (currentPrompts: MediaInfo[]) => 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_media",
"/embed": "public_media_embed",
"/music": "public_music_videos",
"/channels": "public_channels",
"/dream": "public_latent_media",
"/dream/embed": "public_latent_media_embed",
"/channel": "public_channel",
// those are reserved for future use
"/gaming": "public_music_videos",
"/live": "public_music_videos",
"/tv": "public_music_videos",
"/account": "user_account",
"/account/channel": "user_channel",
}
set({ view: routes[pathname] || "not_found" })
},
jwtToken: "",
setJwtToken: (jwtToken: string) => {
set({ jwtToken })
},
searchAutocompleteQuery: "",
setSearchAutocompleteQuery: (searchAutocompleteQuery?: string) => {
set({ searchAutocompleteQuery })
},
showAutocompleteBox: false,
setShowAutocompleteBox: (showAutocompleteBox: boolean) => {
set({ showAutocompleteBox })
},
searchAutocompleteResults: [] as MediaInfo[],
setSearchAutocompleteResults: (searchAutocompleteResults: MediaInfo[]) => {
set({ searchAutocompleteResults })
},
searchQuery: "",
setSearchQuery: (searchQuery?: string) => {
set({ searchQuery })
},
searchResults: [] as MediaInfo[],
setSearchResults: (searchResults: MediaInfo[]) => {
set({ searchResults })
},
currentUser: undefined,
setCurrentUser: (currentUser?: UserInfo) => {
set({ currentUser })
},
headerMode: "normal" as InterfaceHeaderMode,
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 })
},
publicMedia: undefined,
setPublicMedia: (publicMedia?: MediaInfo) => {
set({ publicMedia })
},
publicComments: [],
setPublicComments: (publicComments: CommentInfo[]) => {
set({ publicComments })
},
publicMedias: [],
setPublicMedias: (publicMedias: MediaInfo[] = []) => {
set({
publicMedias: Array.isArray(publicMedias) ? publicMedias : []
})
},
latentMedia: undefined,
setPublicLatentMedia: (latentMedia?: MediaInfo) => {
set({ latentMedia })
},
latentMedias: [],
setPublicLatentMedias: (latentMedias: MediaInfo[] = []) => {
set({
latentMedias: Array.isArray(latentMedias) ? latentMedias : []
})
},
publicTrack: undefined,
setPublicTrack: (publicTrack?: MediaInfo) => {
set({ publicTrack })
},
publicTracks: [],
setPublicTracks: (publicTracks: MediaInfo[] = []) => {
set({
publicTracks: Array.isArray(publicTracks) ? publicTracks : []
})
},
publicChannelVideos: [],
setPublicChannelVideos: (publicChannelVideos: MediaInfo[] = []) => {
set({
publicMedias: Array.isArray(publicChannelVideos) ? publicChannelVideos : []
})
},
userVideo: undefined,
setUserVideo: (userVideo?: MediaInfo) => { set({ userVideo }) },
userVideos: [],
setUserVideos: (userVideos: MediaInfo[] = []) => {
set({
userVideos: Array.isArray(userVideos) ? userVideos : []
})
},
recommendedVideos: [],
setRecommendedVideos: (recommendedVideos: MediaInfo[]) => {
set({
recommendedVideos: Array.isArray(recommendedVideos) ? recommendedVideos : []
})
},
})) |