Bug fixes
This commit is contained in:
@@ -27,14 +27,14 @@ export function Homepage() {
|
||||
currentLocation,
|
||||
setCurrentLocation,
|
||||
} = useCommonHooks();
|
||||
const dateOptions: Intl.DateTimeFormatOptions = !isMobile
|
||||
? {
|
||||
const dateOptions: Intl.DateTimeFormatOptions = isMobile
|
||||
? {}
|
||||
: {
|
||||
weekday: 'long',
|
||||
year: 'numeric',
|
||||
month: 'long',
|
||||
day: 'numeric',
|
||||
}
|
||||
: {};
|
||||
};
|
||||
|
||||
const date = new Date().toLocaleDateString('en-US', dateOptions);
|
||||
|
||||
|
||||
@@ -139,6 +139,8 @@ export default function Search({
|
||||
}
|
||||
if (item.key === 'Enter') {
|
||||
if (providerLabel === 'Show help') {
|
||||
setSearchValue('');
|
||||
closeDropdown();
|
||||
openProviderModal();
|
||||
} else if (item.target.value.startsWith('/')) {
|
||||
mutateAsync({
|
||||
@@ -162,9 +164,9 @@ export default function Search({
|
||||
open(validUrl, '_self');
|
||||
} else if (urlPattern.test(item.target.value)) {
|
||||
if (/^(https?:\/\/).*/i.test(item.target.value))
|
||||
window.location = item.target.value;
|
||||
globalThis.location = item.target.value;
|
||||
else open(`https://${item.target.value}`, '_self');
|
||||
} else if (item.target.value !== '') {
|
||||
} else if (item.target.value.length > 0) {
|
||||
mutateAsync({
|
||||
method: 'POST',
|
||||
endpoint: searchEndpoint,
|
||||
@@ -309,19 +311,17 @@ export default function Search({
|
||||
};
|
||||
});
|
||||
}
|
||||
const historyOptions = [
|
||||
...options
|
||||
.filter((option: any) => {
|
||||
return splittedSearch.every((searchWord) =>
|
||||
option.value
|
||||
.toLowerCase()
|
||||
.trim()
|
||||
.split(' ')
|
||||
.some((word: string) => word.includes(searchWord)),
|
||||
);
|
||||
})
|
||||
.slice(0, 10 * historyMultiplier),
|
||||
];
|
||||
const historyOptions = options
|
||||
.filter((option: any) => {
|
||||
return splittedSearch.every((searchWord) =>
|
||||
option.value
|
||||
.toLowerCase()
|
||||
.trim()
|
||||
.split(' ')
|
||||
.some((word: string) => word.includes(searchWord)),
|
||||
);
|
||||
})
|
||||
.slice(0, 10 * historyMultiplier);
|
||||
|
||||
if (historyOptions.length >= 10 * historyMultiplier) {
|
||||
return [
|
||||
@@ -343,43 +343,14 @@ export default function Search({
|
||||
const renderItem: any = (item: any) => {
|
||||
const Icon =
|
||||
allIcons[
|
||||
(item.option.icon ?? item.option.prefix === '/g')
|
||||
? 'FaGoogle'
|
||||
: (providers.find((p: Provider) => p.prefix === item.option.prefix)?.icon ?? '')
|
||||
item.option.icon
|
||||
? item.option.icon
|
||||
: item.option.prefix === '/g'
|
||||
? 'FaGoogle'
|
||||
: (providers.find((p: Provider) => p.prefix === item.option.prefix)?.icon ??
|
||||
'')
|
||||
];
|
||||
return !searchValue.startsWith('!') ? (
|
||||
item.option.value === 'load' ? (
|
||||
<Group
|
||||
pos={'relative'}
|
||||
m={0}
|
||||
p={0}
|
||||
gap={0}
|
||||
w={'100%'}
|
||||
h={'2rem'}
|
||||
onClick={(e) => {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
setHistoryMultiplier((prev: number) => prev + 1);
|
||||
}}
|
||||
>
|
||||
<Text
|
||||
w={'100%'}
|
||||
c={'var(--mantine-color-accent-0)'}
|
||||
style={{ textAlign: 'center' }}
|
||||
>
|
||||
{item.option.label}
|
||||
</Text>
|
||||
</Group>
|
||||
) : (
|
||||
<SearchSelectItem
|
||||
item={item}
|
||||
handleSearchHistoryItem={handleSearchHistoryItem}
|
||||
searchEndpoint={searchEndpoint}
|
||||
setSearchValue={setSearchValue}
|
||||
Icon={Icon}
|
||||
/>
|
||||
)
|
||||
) : (
|
||||
return searchValue.startsWith('!') ? (
|
||||
<Group
|
||||
pos={'relative'}
|
||||
m={0}
|
||||
@@ -409,6 +380,36 @@ export default function Search({
|
||||
{item.option.name}
|
||||
</Text>
|
||||
</Group>
|
||||
) : item.option.value === 'load' ? (
|
||||
<Group
|
||||
pos={'relative'}
|
||||
m={0}
|
||||
p={0}
|
||||
gap={0}
|
||||
w={'100%'}
|
||||
h={'2rem'}
|
||||
onClick={(e) => {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
setHistoryMultiplier((prev: number) => prev + 1);
|
||||
}}
|
||||
>
|
||||
<Text
|
||||
w={'100%'}
|
||||
c={'var(--mantine-color-accent-0)'}
|
||||
style={{ textAlign: 'center' }}
|
||||
>
|
||||
{item.option.label}
|
||||
</Text>
|
||||
</Group>
|
||||
) : (
|
||||
<SearchSelectItem
|
||||
item={item}
|
||||
handleSearchHistoryItem={handleSearchHistoryItem}
|
||||
searchEndpoint={searchEndpoint}
|
||||
setSearchValue={setSearchValue}
|
||||
Icon={Icon}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -490,7 +491,7 @@ export default function Search({
|
||||
|
||||
return (
|
||||
<>
|
||||
{dropdownOpened && <Overlay blur={5} onClick={closeDropdown} />}
|
||||
{dropdownOpened && <Overlay blur={5} onClick={closeDropdown} fixed zIndex={200} />}
|
||||
<Stack
|
||||
style={{
|
||||
height: position === 'center' ? '100%' : '100px',
|
||||
|
||||
Reference in New Issue
Block a user