Skip to content

[Fix]: #1849 errors / optimizations #1886

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jul 22, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion client/packages/lowcoder/src/comps/controls/codeControl.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ export function codeControl<
const cardContent = params.disableCard
? ""
: getCardContent(this.unevaledValue, this.valueAndMsg, codeControlParams);
const { key, ...restParams } = params;
return (
<EditorContext.Consumer>
{(editorState) => (
Expand All @@ -197,7 +198,8 @@ export function codeControl<
<>
<Suspense fallback={null}>
<CodeEditor
{...params}
key={key}
{...restParams}
bordered
value={this.unevaledValue}
codeType={codeType}
Expand Down
16 changes: 8 additions & 8 deletions client/packages/lowcoder/src/pages/ApplicationV2/FolderView.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { useDispatch, useSelector } from "react-redux";
import { useParams } from "react-router-dom";
import { HomeBreadcrumbType, HomeLayout } from "./HomeLayout";
import {useEffect, useState} from "react";
import { useEffect, useState } from "react";
import { useDebouncedValue } from "util/hooks";
import {ApplicationCategoriesEnum, ApplicationMeta, FolderMeta} from "../../constants/applicationConstants";
import { buildFolderUrl } from "../../constants/routesURL";
import { folderElementsSelector, foldersSelector } from "../../redux/selectors/folderSelector";
Expand Down Expand Up @@ -100,13 +101,12 @@ export function FolderView() {
}, [searchValues]
);

useEffect(()=> {
const timer = setTimeout(() => {
if (searchValue.length > 2 || searchValue === "")
setSearchValues(searchValue)
}, 500);
return () => clearTimeout(timer);
}, [searchValue])
const debouncedSearchValue = useDebouncedValue(searchValue, 500);

useEffect(() => {
if (debouncedSearchValue.trim().length > 0 || debouncedSearchValue === "")
setSearchValues(debouncedSearchValue);
}, [debouncedSearchValue]);

return (
<>
Expand Down
17 changes: 9 additions & 8 deletions client/packages/lowcoder/src/pages/ApplicationV2/HomeView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import { HomeLayout } from "./HomeLayout";
import { getUser } from "../../redux/selectors/usersSelectors";
import { Helmet } from "react-helmet";
import { trans } from "i18n";
import {useState, useEffect } from "react";
import { useState, useEffect } from "react";
import { useDebouncedValue } from "util/hooks";
import {fetchFolderElements} from "@lowcoder-ee/util/pagination/axios";
import {ApplicationCategoriesEnum, ApplicationMeta, FolderMeta} from "@lowcoder-ee/constants/applicationConstants";
import {ApplicationPaginationType} from "@lowcoder-ee/util/pagination/type";
Expand Down Expand Up @@ -53,13 +54,13 @@ export function HomeView() {
}, [searchValues]
);

useEffect(()=> {
const timer = setTimeout(() => {
if (searchValue.length > 2 || searchValue === "")
setSearchValues(searchValue)
}, 500);
return () => clearTimeout(timer);
}, [searchValue])
const debouncedSearchValue = useDebouncedValue(searchValue, 500);

useEffect(() => {
if (debouncedSearchValue.trim().length > 0 || debouncedSearchValue === "") {
setSearchValues(debouncedSearchValue);
}
}, [debouncedSearchValue]);

const user = useSelector(getUser);

Expand Down
18 changes: 9 additions & 9 deletions client/packages/lowcoder/src/pages/ApplicationV2/TrashView.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { HomeLayout } from "./HomeLayout";
import { TRASH_URL } from "../../constants/routesURL";
import {useEffect, useState} from "react";
import { useEffect, useState } from "react";
import { useDebouncedValue } from "util/hooks";
import { trans } from "../../i18n";
import { Helmet } from "react-helmet";
import {fetchApplicationElements} from "@lowcoder-ee/util/pagination/axios";
Expand Down Expand Up @@ -46,14 +47,13 @@ export function TrashView() {
}, [searchValues]
);

//debouncing
useEffect(()=> {
const timer = setTimeout(() => {
if (searchValue.length > 2 || searchValue === "")
setSearchValues(searchValue)
}, 500);
return () => clearTimeout(timer);
}, [searchValue])
const debouncedSearchValue = useDebouncedValue(searchValue, 500);

useEffect(() => {
if (debouncedSearchValue.trim().length > 0 || debouncedSearchValue === "") {
setSearchValues(debouncedSearchValue);
}
}, [debouncedSearchValue]);

return (
<>
Expand Down
1 change: 1 addition & 0 deletions client/packages/lowcoder/src/pages/ApplicationV2/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ export default function ApplicationHome() {
routePath: ALL_APPLICATIONS_URL,
routeComp: HomeView,
icon: ({ selected, ...otherProps }) => selected ? <AppsIcon {...otherProps} width={"24px"}/> : <AppsIcon {...otherProps} width={"24px"}/>,
onSelected: (_, currentPath) => currentPath === ALL_APPLICATIONS_URL || currentPath.startsWith("/folder"),
},
],
},
Expand Down
17 changes: 9 additions & 8 deletions client/packages/lowcoder/src/pages/datasource/datasourceList.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import styled from "styled-components";
import { EditPopover, PointIcon, Search, TacoButton } from "lowcoder-design";
import {useEffect, useState} from "react";
import { useState, useEffect } from "react";
import { useDebouncedValue } from "util/hooks";
import { useDispatch, useSelector } from "react-redux";
import { getDataSourceTypesMap } from "../../redux/selectors/datasourceSelectors";
import { deleteDatasource } from "../../redux/reduxActions/datasourceActions";
Expand Down Expand Up @@ -124,13 +125,13 @@ export const DatasourceList = () => {
const [pageSize, setPageSize] = useState(10);
const [paginationLoading, setPaginationLoading] = useState(false);

useEffect(()=> {
const timer = setTimeout(() => {
if (searchValue.length > 2 || searchValue === "")
setSearchValues(searchValue)
}, 500);
return () => clearTimeout(timer);
}, [searchValue])
const debouncedSearchValue = useDebouncedValue(searchValue, 500);

useEffect(() => {
if (debouncedSearchValue.trim().length > 0 || debouncedSearchValue === "") {
setSearchValues(debouncedSearchValue);
}
}, [debouncedSearchValue]);

useEffect( () => {
setPaginationLoading(true);
Expand Down
16 changes: 8 additions & 8 deletions client/packages/lowcoder/src/pages/queryLibrary/LeftNav.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {useEffect, useState} from "react";
import { useEffect, useState } from "react";
import { useDebouncedValue } from "util/hooks";
import styled, { css } from "styled-components";
import {
BluePlusIcon,
Expand Down Expand Up @@ -174,14 +175,13 @@ export const LeftNav = (props: {
const [searchValue, setSearchValue] = useState("");
const datasourceTypes = useSelector(getDataSourceTypesMap);

useEffect(()=> {
const timer = setTimeout(() => {
if (searchValue.length > 2 || searchValue === "")
setSearchValues(searchValue)
}, 500);
return () => clearTimeout(timer);
}, [searchValue])
const debouncedSearchValue = useDebouncedValue(searchValue, 500);

useEffect(() => {
if (debouncedSearchValue.trim().length > 0 || debouncedSearchValue === "") {
setSearchValues(debouncedSearchValue);
}
}, [debouncedSearchValue]);


return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,18 @@ export function AdvancedSetting() {
}, [currentUser.currentOrgId])

useEffect(() => {
dispatch(fetchCommonSettings({ orgId: currentUser.currentOrgId }));
dispatch(fetchAllApplications({}));
}, [currentUser.currentOrgId, dispatch]);
// Only fetch common settings if not already loaded
if (Object.keys(commonSettings).length === 0) {
dispatch(fetchCommonSettings({ orgId: currentUser.currentOrgId }));
}
}, [currentUser.currentOrgId, dispatch, commonSettings]);

// Lazy load applications only when dropdown is opened
const handleDropdownOpen = () => {
if (appList.length === 0) {
dispatch(fetchAllApplications({}));
}
};

useEffect(() => {
setSettings(commonSettings);
Expand All @@ -110,9 +119,7 @@ export function AdvancedSetting() {
}
}, [canLeave]);

useEffect(() => {
dispatch(fetchCommonSettings({ orgId: currentUser.currentOrgId }));
}, [currentUser.currentOrgId, dispatch]);


const handleSave = (key: keyof typeof settings, onSuccess?: () => void) => {
return (value?: any) => {
Expand Down Expand Up @@ -178,6 +185,9 @@ export function AdvancedSetting() {
onChange={(value: string) => {
setSettings((v) => ({ ...v, defaultHomePage: value }));
}}
onDropdownVisibleChange={(open) => {
if (open) handleDropdownOpen();
}}
options={appListOptions}
filterOption={(input, option) => (option?.label as string).includes(input)}
/>
Expand Down
19 changes: 19 additions & 0 deletions client/packages/lowcoder/src/util/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import { constantColors } from "components/colorSelect/colorUtils";
import { AppState } from "@lowcoder-ee/redux/reducers";
import { getOrgUserStats } from "@lowcoder-ee/redux/selectors/orgSelectors";
import { fetchGroupsAction } from "@lowcoder-ee/redux/reduxActions/orgActions";
import debounce from "lodash/debounce";

export const ForceViewModeContext = React.createContext<boolean>(false);

Expand Down Expand Up @@ -282,3 +283,21 @@ export const useOrgUserCount = (orgId: string) => {

return userCount;
};

/**
* Returns a debounced version of the incoming value that only updates
*/
export function useDebouncedValue<T>(value: T, delay = 500): T {
const [debouncedValue, setDebouncedValue] = useState<T>(value);

const updater = useMemo(() => debounce(setDebouncedValue, delay), [delay]);

useEffect(() => {
updater(value);
return () => {
updater.cancel();
};
}, [value, updater]);

return debouncedValue;
}
Loading