Skip to content

Commit 6e8d7e6

Browse files
committed
fix experiemnts
1 parent 8efc358 commit 6e8d7e6

File tree

3 files changed

+52
-64
lines changed

3 files changed

+52
-64
lines changed

packages/app/src/app/overmind/namespaces/preferences/actions.ts

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -131,30 +131,3 @@ export const zenModeToggled: Action = ({ state }) => {
131131
export const codeMirrorForced: Action = ({ state }) => {
132132
state.preferences.settings.codeMirror = true;
133133
};
134-
135-
export const toggleContainerLspExperiment: AsyncAction = async ({
136-
state,
137-
effects,
138-
}) => {
139-
if (!state.user) {
140-
return;
141-
}
142-
try {
143-
await effects.api.updateExperiments({
144-
container_lsp: !state.user.experiments.containerLsp,
145-
});
146-
state.user.experiments.containerLsp = !state.user.experiments.containerLsp;
147-
// Allow the flush to go through and flip button
148-
requestAnimationFrame(() => {
149-
if (
150-
effects.browser.confirm(
151-
'We need to refresh for this to take effect, or you can refresh later'
152-
)
153-
) {
154-
effects.browser.reload();
155-
}
156-
});
157-
} catch (error) {
158-
effects.notificationToast.error('Unable to toggl LSP experiment');
159-
}
160-
};
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import React, { useState, useEffect } from 'react';
2+
import { useOvermind } from 'app/overmind';
3+
import { SubDescription, PaddedPreference } from '../elements';
4+
5+
export const ContainerLSP: React.FunctionComponent = () => {
6+
const { state } = useOvermind();
7+
const [containerLSP, setContainerLSP] = useState(false);
8+
useEffect(() => {
9+
const value = window.localStorage.getItem('CONTAINER_LSP');
10+
11+
if (value === 'true') {
12+
return setContainerLSP(true);
13+
}
14+
return setContainerLSP(false);
15+
}, []);
16+
17+
const setValue = (val: boolean) => {
18+
setContainerLSP(val);
19+
window.localStorage.setItem('CONTAINER_LSP', val.toString());
20+
location.reload();
21+
};
22+
23+
return state.user ? (
24+
<>
25+
<PaddedPreference
26+
title="Use container language server"
27+
type="boolean"
28+
value={containerLSP}
29+
setValue={val => setValue(val)}
30+
tooltip="Language server"
31+
/>
32+
<SubDescription>
33+
As part of making containers more powerful we now allow the language
34+
server to run there. Please help us test it :-)
35+
</SubDescription>
36+
</>
37+
) : null;
38+
};
Lines changed: 14 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,18 @@
1-
import { useOvermind } from 'app/overmind';
21
import React from 'react';
32

4-
import {
5-
PaddedPreference,
6-
PreferenceContainer,
7-
Rule,
8-
SubContainer,
9-
SubDescription,
10-
Title,
11-
} from '../elements';
3+
import { PreferenceContainer, Rule, SubContainer, Title } from '../elements';
124
import { NewSidebar } from './NewSidebar';
5+
import { ContainerLSP } from './ContainerLSP';
136

14-
export const Experiments: React.FunctionComponent = () => {
15-
const { state, actions } = useOvermind();
16-
17-
return (
18-
<div>
19-
<Title>Experiments</Title>
20-
<SubContainer>
21-
<PreferenceContainer>
22-
<NewSidebar />
23-
<Rule />
24-
<PaddedPreference
25-
title="Use container language server"
26-
type="boolean"
27-
value={state.user.experiments.containerLsp}
28-
setValue={() => {
29-
actions.preferences.toggleContainerLspExperiment();
30-
}}
31-
tooltip="Language server"
32-
/>
33-
<SubDescription>
34-
As part of making containers more powerful we now allow the language
35-
server to run there. Please help us test it :-)
36-
</SubDescription>
37-
</PreferenceContainer>
38-
</SubContainer>
39-
</div>
40-
);
41-
};
7+
export const Experiments: React.FunctionComponent = () => (
8+
<div>
9+
<Title>Experiments</Title>
10+
<SubContainer>
11+
<PreferenceContainer>
12+
<NewSidebar />
13+
<Rule />
14+
<ContainerLSP />
15+
</PreferenceContainer>
16+
</SubContainer>
17+
</div>
18+
);

0 commit comments

Comments
 (0)