Skip to content

Commit

Permalink
fix(tasks): add new sanityTasks flag (#6089)
Browse files Browse the repository at this point in the history
  • Loading branch information
pedrobonamin authored Mar 20, 2024
1 parent 5bc629f commit ae89244
Showing 1 changed file with 16 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,33 @@ interface TaksEnabledProviderProps {
* @internal
*/
export function TasksEnabledProvider({children}: TaksEnabledProviderProps) {
const {enabled, isLoading} = useFeatureEnabled('studioTasks')
const {enabled, isLoading} = useFeatureEnabled('sanityTasks')

// Staging flag - keeping here until the new flag is added to staging.
const {enabled: stagingIsEnabled, isLoading: stagingIsLoading} = useFeatureEnabled('studioTasks')

const isWorkspaceEnabled = useWorkspace().tasks?.enabled

const value: TasksEnabledContextValue = useMemo(() => {
if (!enabled || !isWorkspaceEnabled || isLoading) {
if (!isWorkspaceEnabled || isLoading || stagingIsLoading) {
return {
enabled: false,
mode: null,
}
}
// The staging check will be removed when the sanityTasks flag is added to staging.
if (stagingIsEnabled || enabled) {
return {
enabled: true,
mode: 'default',
}
}

return {
enabled: true,
mode: 'default',
enabled: false,
mode: null,
}
}, [enabled, isLoading, isWorkspaceEnabled])
}, [enabled, isLoading, isWorkspaceEnabled, stagingIsEnabled, stagingIsLoading])

return <TasksEnabledContext.Provider value={value}>{children}</TasksEnabledContext.Provider>
}

0 comments on commit ae89244

Please sign in to comment.