Skip to content
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

Live update disable #50

Merged
merged 4 commits into from
Mar 20, 2024
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
41 changes: 23 additions & 18 deletions src/src/components/LiveUpdateSettings/LiveUpdateSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,29 @@ export interface ILiveUpdateSettingsProp {

function LiveUpdateSettings(
props: ILiveUpdateSettingsProp,
): React.FunctionComponentElement<React.ReactNode> {
return (
<ErrorBoundary>
<div className='LiveUpdateSettings'>
<Text className='LiveUpdateSettings__Text' size={14}>
Live Update:
</Text>
<Switcher
checked={Boolean(props.enabled)}
onChange={() => {
props.onLiveUpdateConfigChange({ enabled: !props.enabled });
}}
size='small'
color='primary'
/>
</div>
</ErrorBoundary>
);
): React.FunctionComponentElement<React.ReactNode> | null {
//@ts-ignore
if (window.live_updates_enabled == 1) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we just have to use bool as is without transforming it to int. JSON object safely supports boolean type so we can use it as is.

return (
<ErrorBoundary>
<div className='LiveUpdateSettings'>
<Text className='LiveUpdateSettings__Text' size={14}>
Live Update:
</Text>
<Switcher
checked={Boolean(props.enabled)}
onChange={() => {
props.onLiveUpdateConfigChange({ enabled: !props.enabled });
}}
size='small'
color='primary'
/>
</div>
</ErrorBoundary>
);
}
props.onLiveUpdateConfigChange({ enabled: false });
return null;
}

export default React.memo<ILiveUpdateSettingsProp>(LiveUpdateSettings);
2 changes: 2 additions & 0 deletions src/src/services/models/projects/projectsModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ function getProjectsData() {
}).then((data: IProject) => {
//@ts-ignore
window.telemetry_enabled = data.telemetry_enabled;
//@ts-ignore
window.live_updates_enabled = data.live_updates_enabled;
model.setState({
project: data,
});
Expand Down
Loading