Skip to content

Table fixes related to sorting and text overflow visibility + added destroyInactiveTabPane in tab comp #1304

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
Nov 14, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
added icon dictionary to avoid downloading icons again
  • Loading branch information
raheeliftikhar5 committed Nov 14, 2024
commit fc4f9a87e8e2541ac393d460e8b43f74ade3f62f
25 changes: 18 additions & 7 deletions client/packages/lowcoder/src/comps/controls/iconControl.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,12 @@ import {
useIcon,
wrapperToControlItem,
} from "lowcoder-design";
import { ReactNode, useCallback, useState } from "react";
import { memo, ReactNode, useCallback, useMemo, useState } from "react";
import styled from "styled-components";
import { setFieldsNoTypeCheck } from "util/objectUtils";
import { StringControl } from "./codeControl";
import { ControlParams } from "./controlParams";
import { IconDictionary } from "@lowcoder-ee/constants/iconConstants";

const ButtonWrapper = styled.div`
width: 100%;
Expand Down Expand Up @@ -208,14 +209,24 @@ type ChangeModeAction = {
useCodeEditor: boolean;
};

export function IconControlView(props: { value: string }) {
export const IconControlView = memo((props: { value: string }) => {
const { value } = props;
const icon = useIcon(value);
if (icon) {
return icon.getView();
}
return <StyledImage src={value} alt="" />;
}

return useMemo(() => {
if (value && IconDictionary[value] && IconDictionary[value]?.title === icon?.title) {
return IconDictionary[value];
}

if (value && icon) {
const renderIcon = icon.getView();
IconDictionary[value] = renderIcon;
return renderIcon;
}

return <StyledImage src={value} alt="" />;
}, [icon, value, IconDictionary[value]])
});

export class IconControl extends AbstractComp<ReactNode, string, Node<ValueAndMsg<string>>> {
private readonly useCodeEditor: boolean;
Expand Down
5 changes: 5 additions & 0 deletions client/packages/lowcoder/src/constants/iconConstants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export let IconDictionary: Record<string, any> = {};

export const resetIconDictionary = () => {
IconDictionary = {};
}
2 changes: 2 additions & 0 deletions client/packages/lowcoder/src/pages/editor/AppEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import dayjs from "dayjs";
import { currentApplication } from "@lowcoder-ee/redux/selectors/applicationSelector";
import { notificationInstance } from "components/GlobalInstances";
import { AppState } from "@lowcoder-ee/redux/reducers";
import { resetIconDictionary } from "@lowcoder-ee/constants/iconConstants";

const AppSnapshot = lazy(() => {
return import("pages/editor/appSnapshot")
Expand Down Expand Up @@ -188,6 +189,7 @@ const AppEditor = React.memo(() => {
useEffect(() => {
if(!isLowcoderCompLoading) {
fetchApplication();
resetIconDictionary();
}
}, [isLowcoderCompLoading, fetchApplication]);

Expand Down
Loading