Skip to content

Commit

Permalink
fix theme switching
Browse files Browse the repository at this point in the history
  • Loading branch information
mvladic committed Oct 21, 2024
1 parent 97c5222 commit de933a1
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 10 deletions.
11 changes: 9 additions & 2 deletions packages/home/settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,13 @@ class SettingsController {
setTimeFormat(value);
}

onThemeSwitchedTimeout: any;

switchTheme(value: boolean) {
if (this.onThemeSwitchedTimeout) {
return;
}

this.isDarkTheme = value;
setIsDarkTheme(value);
this.onThemeSwitched();
Expand Down Expand Up @@ -238,9 +244,10 @@ class SettingsController {
"../../node_modules/flexlayout-react/style/light.css";
}

setTimeout(() => {
this.onThemeSwitchedTimeout = setTimeout(() => {
this.onThemeSwitchedTimeout = undefined;
content.style.opacity = "";
}, 200);
}, 500);
}

removeItemFromMRU(mruItem: IMruItem) {
Expand Down
22 changes: 14 additions & 8 deletions packages/project-editor/flow/editor/render.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -179,11 +179,6 @@ export const ComponentEnclosure = observer(
return;
}

if (this.updateComponentTimeout) {
clearTimeout(this.updateComponentTimeout);
this.updateComponentTimeout = undefined;
}

if (this.elRef.current && this.listIndex == 0) {
const component = this.props.component;
if (component instanceof ProjectEditor.PageClass) {
Expand All @@ -198,7 +193,6 @@ export const ComponentEnclosure = observer(

if (this.elRef.current.offsetParent == null) {
// do not calculate geometry if element is not visible

this.updateComponentTimeout = setTimeout(() => {
this.updateComponentTimeout = undefined;
this.updateComponentGeometry();
Expand All @@ -221,12 +215,24 @@ export const ComponentEnclosure = observer(
}
};

debounceUpdateComponentGeometry = () => {
if (this.updateComponentTimeout) {
clearTimeout(this.updateComponentTimeout);
this.updateComponentTimeout = undefined;
}

this.updateComponentTimeout = setTimeout(() => {
this.updateComponentTimeout = undefined;
this.updateComponentGeometry();
});
};

componentDidMount() {
this.updateComponentGeometry();
this.debounceUpdateComponentGeometry();
}

componentDidUpdate() {
this.updateComponentGeometry();
this.debounceUpdateComponentGeometry();
}

componentWillUnmount() {
Expand Down

0 comments on commit de933a1

Please sign in to comment.