Skip to content

Commit 20342c7

Browse files
author
Lucas Araujo
committed
[DDW-738] Notification knob
1 parent 3672fb2 commit 20342c7

File tree

3 files changed

+35
-1
lines changed

3 files changed

+35
-1
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// @flow
2+
3+
import { useLayoutEffect } from 'react';
4+
import { observer } from 'mobx-react';
5+
import { boolean } from '@storybook/addon-knobs';
6+
import { useDiscreetModeFeature } from '../../../source/renderer/app/features';
7+
8+
export const DiscreetModeNotificationKnob = observer(() => {
9+
const feature = useDiscreetModeFeature();
10+
const tooltipKnob = boolean('Discreet mode tooltip', false, 'Dicreet Mode');
11+
const notificationKnob = boolean(
12+
'Discreet mode notification',
13+
false,
14+
'Dicreet Mode'
15+
);
16+
17+
useLayoutEffect(() => {
18+
const knobBoolValue = JSON.parse(notificationKnob);
19+
if (knobBoolValue !== feature.isNotificationEnabled) {
20+
feature.setDiscreetModeNotification(knobBoolValue);
21+
}
22+
}, [notificationKnob, feature.isNotificationEnabled]);
23+
24+
useLayoutEffect(() => {
25+
const knobBoolValue = JSON.parse(tooltipKnob);
26+
if (knobBoolValue !== feature.isSettingsTooltipEnabled) {
27+
feature.setDiscreetModeSettingsTooltip(knobBoolValue);
28+
}
29+
}, [tooltipKnob, feature.isSettingsTooltipEnabled]);
30+
31+
return null;
32+
});

storybook/stories/_support/DiscreetModeToggleKnob.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { useDiscreetModeFeature } from '../../../source/renderer/app/features';
77

88
export const DiscreetModeToggleKnob = observer(() => {
99
const feature = useDiscreetModeFeature();
10-
const knob = boolean('Toogle discreet mode', false);
10+
const knob = boolean('Toogle discreet mode', false, 'Dicreet Mode');
1111

1212
useLayoutEffect(() => {
1313
if (knob !== feature.isDiscreetMode) {

storybook/stories/_support/StoryProvider.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {
1313
BrowserLocalStorageBridge,
1414
} from '../../../source/renderer/app/features';
1515
import { DiscreetModeToggleKnob } from './DiscreetModeToggleKnob';
16+
import { DiscreetModeNotificationKnob } from './DiscreetModeNotificationKnob';
1617

1718
type Props = {
1819
children: Node,
@@ -188,6 +189,7 @@ export default class StoryProvider extends Component<Props> {
188189
<>
189190
{this.props.children}
190191
<DiscreetModeToggleKnob />
192+
<DiscreetModeNotificationKnob />
191193
</>
192194
</DiscreetModeFeatureProvider>
193195
</BrowserLocalStorageBridge>

0 commit comments

Comments
 (0)