diff options
author | 2019-09-04 15:44:36 +0200 | |
---|---|---|
committer | 2019-09-04 15:44:36 +0200 | |
commit | 3843c2488df81840960d8db3cfdec33597e17159 (patch) | |
tree | 638571fb96ccd7ffd882399bbf98dee03bc1f023 /src/features | |
parent | update todos app url (diff) | |
download | ferdium-app-3843c2488df81840960d8db3cfdec33597e17159.tar.gz ferdium-app-3843c2488df81840960d8db3cfdec33597e17159.tar.zst ferdium-app-3843c2488df81840960d8db3cfdec33597e17159.zip |
Resend todos config on Franz setting changes
Diffstat (limited to 'src/features')
-rw-r--r-- | src/features/todos/components/TodosWebview.js | 74 | ||||
-rw-r--r-- | src/features/todos/store.js | 13 |
2 files changed, 45 insertions, 42 deletions
diff --git a/src/features/todos/components/TodosWebview.js b/src/features/todos/components/TodosWebview.js index 288c1906f..9dd313109 100644 --- a/src/features/todos/components/TodosWebview.js +++ b/src/features/todos/components/TodosWebview.js | |||
@@ -22,10 +22,6 @@ const styles = theme => ({ | |||
22 | '&:hover $closeTodosButton': { | 22 | '&:hover $closeTodosButton': { |
23 | opacity: 1, | 23 | opacity: 1, |
24 | }, | 24 | }, |
25 | }, | ||
26 | webview: { | ||
27 | height: '100%', | ||
28 | |||
29 | '& webview': { | 25 | '& webview': { |
30 | height: '100%', | 26 | height: '100%', |
31 | }, | 27 | }, |
@@ -191,45 +187,43 @@ class TodosWebview extends Component { | |||
191 | const { width, delta, isDragging } = this.state; | 187 | const { width, delta, isDragging } = this.state; |
192 | 188 | ||
193 | return ( | 189 | return ( |
194 | <> | 190 | <div |
195 | <div | 191 | className={classes.root} |
196 | className={classes.root} | 192 | style={{ width: isVisible ? width : 0 }} |
197 | style={{ width: isVisible ? width : 0 }} | 193 | onMouseUp={() => this.stopResize()} |
198 | onMouseUp={() => this.stopResize()} | 194 | ref={(node) => { this.node = node; }} |
199 | ref={(node) => { this.node = node; }} | 195 | > |
196 | <button | ||
197 | onClick={() => togglePanel()} | ||
198 | className={isVisible ? classes.closeTodosButton : classes.openTodosButton} | ||
199 | type="button" | ||
200 | > | 200 | > |
201 | <button | 201 | <Icon icon={isVisible ? 'mdiChevronRight' : 'mdiCheckAll'} size={2} /> |
202 | onClick={() => togglePanel()} | 202 | </button> |
203 | className={isVisible ? classes.closeTodosButton : classes.openTodosButton} | 203 | <div |
204 | type="button" | 204 | className={classes.resizeHandler} |
205 | > | 205 | style={Object.assign({ left: delta }, isDragging ? { width: 600, marginLeft: -200 } : {})} // This hack is required as resizing with webviews beneath behaves quite bad |
206 | <Icon icon={isVisible ? 'mdiChevronRight' : 'mdiCheckAll'} size={2} /> | 206 | onMouseDown={e => this.startResize(e)} |
207 | </button> | 207 | /> |
208 | {isDragging && ( | ||
208 | <div | 209 | <div |
209 | className={classes.resizeHandler} | 210 | className={classes.dragIndicator} |
210 | style={Object.assign({ left: delta }, isDragging ? { width: 600, marginLeft: -200 } : {})} // This hack is required as resizing with webviews beneath behaves quite bad | 211 | style={{ left: delta }} // This hack is required as resizing with webviews beneath behaves quite bad |
211 | onMouseDown={e => this.startResize(e)} | ||
212 | /> | ||
213 | {isDragging && ( | ||
214 | <div | ||
215 | className={classes.dragIndicator} | ||
216 | style={{ left: delta }} // This hack is required as resizing with webviews beneath behaves quite bad | ||
217 | /> | ||
218 | )} | ||
219 | <Webview | ||
220 | className={classes.webview} | ||
221 | onDidAttach={() => { | ||
222 | const { setTodosWebview } = this.props; | ||
223 | setTodosWebview(this.webview); | ||
224 | this.startListeningToIpcMessages(); | ||
225 | }} | ||
226 | partition="persist:todos" | ||
227 | preload="./features/todos/preload.js" | ||
228 | ref={(webview) => { this.webview = webview ? webview.view : null; }} | ||
229 | src={environment.TODOS_FRONTEND} | ||
230 | /> | 212 | /> |
231 | </div> | 213 | )} |
232 | </> | 214 | <Webview |
215 | className={classes.webview} | ||
216 | onDidAttach={() => { | ||
217 | const { setTodosWebview } = this.props; | ||
218 | setTodosWebview(this.webview); | ||
219 | this.startListeningToIpcMessages(); | ||
220 | }} | ||
221 | partition="persist:todos" | ||
222 | preload="./features/todos/preload.js" | ||
223 | ref={(webview) => { this.webview = webview ? webview.view : null; }} | ||
224 | src={environment.TODOS_FRONTEND} | ||
225 | /> | ||
226 | </div> | ||
233 | ); | 227 | ); |
234 | } | 228 | } |
235 | } | 229 | } |
diff --git a/src/features/todos/store.js b/src/features/todos/store.js index acf95df0d..bb1df9415 100644 --- a/src/features/todos/store.js +++ b/src/features/todos/store.js | |||
@@ -59,6 +59,7 @@ export default class TodoStore extends FeatureStore { | |||
59 | 59 | ||
60 | this._allReactions = createReactions([ | 60 | this._allReactions = createReactions([ |
61 | this._setFeatureEnabledReaction, | 61 | this._setFeatureEnabledReaction, |
62 | this._updateTodosConfig, | ||
62 | ]); | 63 | ]); |
63 | 64 | ||
64 | this._registerReactions(this._allReactions); | 65 | this._registerReactions(this._allReactions); |
@@ -121,11 +122,14 @@ export default class TodoStore extends FeatureStore { | |||
121 | // Todos client message handlers | 122 | // Todos client message handlers |
122 | 123 | ||
123 | _onTodosClientInitialized = () => { | 124 | _onTodosClientInitialized = () => { |
125 | const { authToken } = this.stores.user; | ||
126 | const { isDarkThemeActive } = this.stores.ui; | ||
127 | if (!this.webview) return; | ||
124 | this.webview.send(IPC.TODOS_HOST_CHANNEL, { | 128 | this.webview.send(IPC.TODOS_HOST_CHANNEL, { |
125 | action: 'todos:configure', | 129 | action: 'todos:configure', |
126 | data: { | 130 | data: { |
127 | authToken: this.stores.user.authToken, | 131 | authToken, |
128 | theme: this.stores.ui.isDarkThemeActive ? ThemeType.dark : ThemeType.default, | 132 | theme: isDarkThemeActive ? ThemeType.dark : ThemeType.default, |
129 | }, | 133 | }, |
130 | }); | 134 | }); |
131 | }; | 135 | }; |
@@ -144,4 +148,9 @@ export default class TodoStore extends FeatureStore { | |||
144 | 148 | ||
145 | this.isFeatureEnabled = isTodosEnabled; | 149 | this.isFeatureEnabled = isTodosEnabled; |
146 | }; | 150 | }; |
151 | |||
152 | _updateTodosConfig = () => { | ||
153 | // Resend the config if any part changes in Franz: | ||
154 | this._onTodosClientInitialized(); | ||
155 | } | ||
147 | } | 156 | } |