1
- import React from 'react' ;
2
- import { inject , observer } from 'app/componentConnectors ' ;
1
+ import React , { useMemo } from 'react' ;
2
+ import { useOvermind } from 'app/overmind ' ;
3
3
4
4
import AppearanceIcon from 'react-icons/lib/md/color-lens' ;
5
5
import CodeIcon from 'react-icons/lib/fa/code' ;
@@ -25,12 +25,20 @@ import { KeyMapping } from './KeyMapping';
25
25
26
26
import { Container , ContentContainer } from './elements' ;
27
27
28
- class PreferencesModal extends React . Component {
29
- getItems = ( ) => {
30
- const hasSubscription = this . props . store . isPatron ;
31
- const signedIn = this . props . store . isLoggedIn ;
28
+ const PreferencesModal : React . FC = ( ) => {
29
+ const {
30
+ state : {
31
+ isPatron,
32
+ isLoggedIn,
33
+ preferences : { itemId } ,
34
+ } ,
35
+ actions : {
36
+ preferences : { itemIdChanged } ,
37
+ } ,
38
+ } = useOvermind ( ) ;
32
39
33
- return [
40
+ const items = useMemo (
41
+ ( ) => [
34
42
{
35
43
id : 'appearance' ,
36
44
title : 'Appearance' ,
@@ -61,19 +69,19 @@ class PreferencesModal extends React.Component {
61
69
icon : < KeyboardIcon /> ,
62
70
content : < KeyMapping /> ,
63
71
} ,
64
- signedIn && {
72
+ isLoggedIn && {
65
73
id : 'integrations' ,
66
74
title : 'Integrations' ,
67
75
icon : < IntegrationIcon /> ,
68
76
content : < Integrations /> ,
69
77
} ,
70
- hasSubscription && {
78
+ isPatron && {
71
79
id : 'paymentInfo' ,
72
80
title : 'Payment Info' ,
73
81
icon : < CreditCardIcon /> ,
74
82
content : < PaymentInfo /> ,
75
83
} ,
76
- hasSubscription && {
84
+ isPatron && {
77
85
id : 'badges' ,
78
86
title : 'Badges' ,
79
87
icon : < StarIcon /> ,
@@ -85,26 +93,22 @@ class PreferencesModal extends React.Component {
85
93
icon : < FlaskIcon /> ,
86
94
content : < Experiments /> ,
87
95
} ,
88
- ] . filter ( x => x ) ;
89
- } ;
96
+ ] ,
97
+ [ isLoggedIn , isPatron ]
98
+ ) ;
90
99
91
- render ( ) {
92
- const items = this . getItems ( ) ;
93
- const item = items . find (
94
- currentItem => currentItem . id === this . props . store . preferences . itemId
95
- ) ;
100
+ const item = items . find ( currentItem => currentItem . id === itemId ) ;
96
101
97
- return (
98
- < Container >
99
- < SideNavigation
100
- itemId = { this . props . store . preferences . itemId }
101
- menuItems = { items }
102
- setItem = { this . props . signals . preferences . itemIdChanged }
103
- />
104
- < ContentContainer > { item . content } </ ContentContainer >
105
- </ Container >
106
- ) ;
107
- }
108
- }
102
+ return (
103
+ < Container >
104
+ < SideNavigation
105
+ itemId = { itemId }
106
+ menuItems = { items }
107
+ setItem = { itemIdChanged }
108
+ />
109
+ < ContentContainer > { item . content } </ ContentContainer >
110
+ </ Container >
111
+ ) ;
112
+ } ;
109
113
110
- export default inject ( 'store' , 'signals' ) ( observer ( PreferencesModal ) ) ;
114
+ export default PreferencesModal ;
0 commit comments