File tree Expand file tree Collapse file tree 2 files changed +20
-22
lines changed
overmind/namespaces/preferences
pages/common/Modals/PreferencesModal/Badges Expand file tree Collapse file tree 2 files changed +20
-22
lines changed Original file line number Diff line number Diff line change 1+ import { Badge } from '@codesandbox/common/lib/types' ;
2+ import { json } from 'overmind' ;
3+
14import { Action , AsyncAction } from 'app/overmind' ;
25import { setVimExtensionEnabled } from 'app/vscode/initializers' ;
3- import { json } from 'overmind' ;
46
57export const viewModeChanged : Action < {
68 showEditor : boolean ;
@@ -59,13 +61,11 @@ export const settingChanged: Action<{
5961 } ) ;
6062} ;
6163
62- export const setBadgeVisibility : AsyncAction < {
63- id : string ;
64- visible : boolean ;
65- } > = async ( { state, effects } , { id, visible } ) => {
66- const { badges } = state . user ;
67-
68- badges . forEach ( ( badge , index ) => {
64+ export const setBadgeVisibility : AsyncAction < Pick <
65+ Badge ,
66+ 'id' | 'visible'
67+ > > = async ( { effects, state } , { id, visible } ) => {
68+ state . user . badges . forEach ( ( badge , index ) => {
6969 if ( badge . id === id ) {
7070 state . user . badges [ index ] . visible = visible ;
7171 }
Original file line number Diff line number Diff line change @@ -8,37 +8,35 @@ import { Title } from '../elements';
88
99export const Badges : FunctionComponent = ( ) => {
1010 const {
11- state : {
12- user : { badges } ,
13- } ,
1411 actions : {
1512 preferences : { setBadgeVisibility } ,
1613 } ,
14+ state : {
15+ user : { badges } ,
16+ } ,
1717 } = useOvermind ( ) ;
18- const badgesCount = badges . length ;
1918
2019 return (
2120 < div >
2221 < Title > Badges</ Title >
22+
2323 < strong >
24- You currently have { badgesCount } badge
25- { badgesCount === 1 ? '' : 's' } . You can click on the badges to toggle
24+ You currently have { badges . length } badge
25+ { badges . length === 1 ? '' : 's' } . You can click on the badges to toggle
2626 visibility.
2727 </ strong >
28+
2829 < Margin top = { 2 } >
2930 { badges . map ( badge => (
3031 < Badge
32+ badge = { badge }
33+ onClick = { ( { id, visible } ) =>
34+ setBadgeVisibility ( { id, visible : ! visible } )
35+ }
3136 key = { badge . id }
37+ size = { 128 }
3238 tooltip = { false }
33- onClick = { b =>
34- setBadgeVisibility ( {
35- ...b ,
36- visible : ! b . visible ,
37- } )
38- }
39- badge = { badge }
4039 visible = { badge . visible }
41- size = { 128 }
4240 />
4341 ) ) }
4442 </ Margin >
You can’t perform that action at this time.
0 commit comments