mirror of
https://github.com/ajnart/homarr.git
synced 2025-11-14 09:25:47 +01:00
Bugfix for dynamic urls not properly replaces on Search (#2124)
* Bugfix for search items * Fixing server side rendering issues
This commit is contained in:
@@ -13,6 +13,7 @@ import { useTranslation } from 'next-i18next';
|
|||||||
import { useRouter } from 'next/router';
|
import { useRouter } from 'next/router';
|
||||||
import { ReactNode, forwardRef, useMemo, useRef, useState } from 'react';
|
import { ReactNode, forwardRef, useMemo, useRef, useState } from 'react';
|
||||||
import { useConfigContext } from '~/config/provider';
|
import { useConfigContext } from '~/config/provider';
|
||||||
|
import { useGetExternalUrl } from '~/hooks/useExternalUrl';
|
||||||
import { api } from '~/utils/api';
|
import { api } from '~/utils/api';
|
||||||
|
|
||||||
import { MovieModal } from './Search/MovieModal';
|
import { MovieModal } from './Search/MovieModal';
|
||||||
@@ -141,6 +142,7 @@ const getItemComponent = (icon: SearchAutoCompleteItem['icon']) => {
|
|||||||
|
|
||||||
const useConfigApps = (search: string) => {
|
const useConfigApps = (search: string) => {
|
||||||
const { config } = useConfigContext();
|
const { config } = useConfigContext();
|
||||||
|
const getHref = useGetExternalUrl();
|
||||||
return useMemo(() => {
|
return useMemo(() => {
|
||||||
if (search.trim().length === 0) return [];
|
if (search.trim().length === 0) return [];
|
||||||
const apps = config?.apps.filter((app) =>
|
const apps = config?.apps.filter((app) =>
|
||||||
@@ -153,7 +155,7 @@ const useConfigApps = (search: string) => {
|
|||||||
value: app.name,
|
value: app.name,
|
||||||
sort: 'app',
|
sort: 'app',
|
||||||
metaData: {
|
metaData: {
|
||||||
url: app.behaviour.externalUrl,
|
url: getHref(app),
|
||||||
},
|
},
|
||||||
})) ?? []
|
})) ?? []
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -3,6 +3,10 @@ import * as tldts from 'tldts';
|
|||||||
import { AppType } from '~/types/app';
|
import { AppType } from '~/types/app';
|
||||||
|
|
||||||
export const useGetExternalUrl = () => {
|
export const useGetExternalUrl = () => {
|
||||||
|
if (typeof window === 'undefined') {
|
||||||
|
return (appType: AppType) => appType.behaviour.externalUrl || appType.url;
|
||||||
|
}
|
||||||
|
|
||||||
const parsedUrl = useMemo(() => {
|
const parsedUrl = useMemo(() => {
|
||||||
try {
|
try {
|
||||||
return tldts.parse(window.location.toString());
|
return tldts.parse(window.location.toString());
|
||||||
|
|||||||
Reference in New Issue
Block a user