-
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes Fillers & Custom Shows Preloading (#505)
- Loading branch information
1 parent
f568150
commit 6a96a82
Showing
16 changed files
with
353 additions
and
237 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,4 @@ | ||
export const OneDayMillis = 1000 * 60 * 60 * 24; | ||
|
||
// Special ID to use for in-progress entity operations | ||
export const UnsavedId = 'unsaved'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { useLoaderData } from 'react-router-dom'; | ||
import { UnsavedId } from '../helpers/constants'; | ||
import { CustomShowPreload } from '../preloaders/customShowLoaders'; | ||
import { setCurrentCustomShow } from '../store/channelEditor/actions'; | ||
import { useCustomShowEditor } from '../store/selectors'; | ||
import { useCustomShowWithInitialData } from './useCustomShows'; | ||
import { useTunarrApi } from './useTunarrApi'; | ||
|
||
export const usePreloadedCustomShow = () => { | ||
const apiClient = useTunarrApi(); | ||
const { show: preloadShow, programs: preloadPrograms } = | ||
useLoaderData() as CustomShowPreload; | ||
|
||
const [customShow, customPrograms] = useCustomShowWithInitialData( | ||
apiClient, | ||
preloadShow.id, | ||
preloadShow.id !== UnsavedId, | ||
{ | ||
customShow: preloadShow, | ||
programs: preloadPrograms, | ||
}, | ||
); | ||
|
||
const customShowEditor = useCustomShowEditor(); | ||
|
||
if (customShowEditor.currentEntity?.id !== customShow.data.id) { | ||
setCurrentCustomShow(customShow.data, customPrograms.data); | ||
} | ||
|
||
return customShowEditor; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { FillerPreload } from '@/preloaders/fillerListLoader'; | ||
import { setCurrentFillerList } from '@/store/channelEditor/actions'; | ||
import { useLoaderData } from 'react-router-dom'; | ||
import { UnsavedId } from '../helpers/constants'; | ||
import { useFillerListEditor } from '../store/selectors'; | ||
import { useFillersWithInitialData } from './useFillerLists'; | ||
import { useTunarrApi } from './useTunarrApi'; | ||
|
||
export const usePreloadedFiller = () => { | ||
const apiClient = useTunarrApi(); | ||
const { filler: preloadFiller, programs: preloadPrograms } = | ||
useLoaderData() as FillerPreload; | ||
|
||
const [filler, fillerPrograms] = useFillersWithInitialData( | ||
apiClient, | ||
preloadFiller.id, | ||
preloadFiller.id !== UnsavedId, | ||
{ | ||
filler: preloadFiller, | ||
fillerListPrograms: preloadPrograms, | ||
}, | ||
); | ||
|
||
const fillerListEditor = useFillerListEditor(); | ||
|
||
if (fillerListEditor.currentEntity?.id !== filler.data.id) { | ||
setCurrentFillerList(filler.data, fillerPrograms.data); | ||
} | ||
|
||
return fillerListEditor; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.