♻️ Pull request feedback

This commit is contained in:
Manuel
2023-01-28 23:01:15 +01:00
parent 52a1dc5523
commit dabb7c2409
3 changed files with 12 additions and 11 deletions

View File

@@ -33,7 +33,7 @@ export const AppearanceTab = ({
label={t('appearance.icon.label')} label={t('appearance.icon.label')}
description={t('appearance.icon.description')} description={t('appearance.icon.description')}
variant="default" variant="default"
data={isLoading ? [] : data.files} data={data.files ?? []}
withAsterisk withAsterisk
required required
{...form.getInputProps('appearance.iconUrl')} {...form.getInputProps('appearance.iconUrl')}

View File

@@ -184,7 +184,7 @@ export const useCategoryActions = (configName: string | undefined, category: Cat
if (!configName) return; if (!configName) return;
updateConfig( updateConfig(
configName, configName,
(previous): ConfigType => { (previous) => {
const currentItem = previous.categories.find((x) => x.id === category.id); const currentItem = previous.categories.find((x) => x.id === category.id);
if (!currentItem) return previous; if (!currentItem) return previous;
// Find the main wrapper // Find the main wrapper

View File

@@ -140,10 +140,13 @@ export function Search() {
const openInNewTab = config?.settings.common.searchEngine.properties.openInNewTab const openInNewTab = config?.settings.common.searchEngine.properties.openInNewTab
? '_blank' ? '_blank'
: '_self'; : '_self';
const [OverseerrResults, setOverseerrResults] = useState<any[]>([]);
const [opened, setOpened] = useState(false); const [opened, setOpened] = useState(false);
const { data, isLoading, error } = useQuery( const {
data: OverseerrResults,
isLoading,
error,
} = useQuery(
['overseerr', debounced], ['overseerr', debounced],
async () => { async () => {
if (debounced !== '' && selectedSearchEngine.value === 'overseerr' && debounced.length > 3) { if (debounced !== '' && selectedSearchEngine.value === 'overseerr' && debounced.length > 3) {
@@ -159,10 +162,6 @@ export function Search() {
} }
); );
useEffect(() => {
setOverseerrResults(data ?? []);
}, [data]);
const isModuleEnabled = config?.settings.customization.layout.enabledSearchbar; const isModuleEnabled = config?.settings.customization.layout.enabledSearchbar;
if (!isModuleEnabled) { if (!isModuleEnabled) {
return null; return null;
@@ -172,7 +171,7 @@ export function Search() {
return ( return (
<Box style={{ width: '100%', maxWidth: 400 }}> <Box style={{ width: '100%', maxWidth: 400 }}>
<Popover <Popover
opened={OverseerrResults.length > 0 && opened && searchQuery.length > 3} opened={OverseerrResults && OverseerrResults.length > 0 && opened && searchQuery.length > 3}
position="bottom" position="bottom"
withinPortal withinPortal
shadow="md" shadow="md"
@@ -221,10 +220,12 @@ export function Search() {
</Popover.Target> </Popover.Target>
<Popover.Dropdown> <Popover.Dropdown>
<ScrollArea style={{ height: '80vh', maxWidth: '90vw' }} offsetScrollbars> <ScrollArea style={{ height: '80vh', maxWidth: '90vw' }} offsetScrollbars>
{OverseerrResults.slice(0, 4).map((result, index) => ( {OverseerrResults && OverseerrResults.slice(0, 4).map((result: any, index: number) => (
<React.Fragment key={index}> <React.Fragment key={index}>
<OverseerrMediaDisplay key={result.id} media={result} /> <OverseerrMediaDisplay key={result.id} media={result} />
{index < OverseerrResults.length - 1 && index < 3 && <Divider variant="dashed" my="xs" />} {index < OverseerrResults.length - 1 && index < 3 && (
<Divider variant="dashed" my="xs" />
)}
</React.Fragment> </React.Fragment>
))} ))}
</ScrollArea> </ScrollArea>