export type RefreshPresentation = {
showFullPageLoading: boolean
statusUpdating: boolean
treatAsOffline: boolean
}
export function whileRefreshing(hasCachedSeries: boolean): RefreshPresentation {
return {
showFullPageLoading: !hasCachedSeries,
statusUpdating: hasCachedSeries,
treatAsOffline: false,
}
}
export function afterRefresh(input: {
hasCachedSeries: boolean
fetchSucceeded: boolean
networkOnline: boolean
}): RefreshPresentation {
if (input.fetchSucceeded) {
return {
showFullPageLoading: false,
statusUpdating: false,
treatAsOffline: false,
}
}
return {
showFullPageLoading: !input.hasCachedSeries,
statusUpdating: false,
treatAsOffline: !input.networkOnline || input.hasCachedSeries,
}
}