File tree Expand file tree Collapse file tree 4 files changed +37
-4
lines changed Expand file tree Collapse file tree 4 files changed +37
-4
lines changed Original file line number Diff line number Diff line change @@ -72,7 +72,7 @@ export class CodingServer {
72
72
}
73
73
74
74
Logger . error ( `Error reading sessions: ${ e } ` ) ;
75
- await keychain . deleteToken ( TokenType . AccessToken ) ;
75
+ // await keychain.deleteToken(TokenType.AccessToken);
76
76
}
77
77
}
78
78
Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ import styled from 'styled-components';
4
4
import { view } from '@risingstack/react-easy-state' ;
5
5
import appStore from './store/appStore' ;
6
6
import { actions } from './store/constants' ;
7
+ import persistDataHook from './hooks/persistDataHook' ;
7
8
8
9
const LoadingWrapper = styled . div `
9
10
font-size: 16px;
@@ -31,12 +32,13 @@ function App() {
31
32
break ;
32
33
}
33
34
default :
34
- console . log ( type , value ) ;
35
35
break ;
36
36
}
37
37
} ) ;
38
38
} , [ updateCurrentMR ] ) ;
39
39
40
+ persistDataHook ( ) ;
41
+
40
42
if ( ! currentMR . iid ) {
41
43
return < LoadingWrapper > Please select an merge request first.</ LoadingWrapper > ;
42
44
}
Original file line number Diff line number Diff line change
1
+ import { useEffect , useRef } from 'react' ;
2
+ import { persistData , removeDataPersist } from '../store/appStore' ;
3
+
4
+ const persistDataHook = ( ) => {
5
+ const effect = useRef ( ( ) => {
6
+ } ) ;
7
+
8
+ useEffect ( ( ) => {
9
+ effect . current = persistData ( ) ;
10
+
11
+ return ( ) => {
12
+ removeDataPersist ( effect . current ) ;
13
+ } ;
14
+ } , [ ] ) ;
15
+
16
+ return effect . current ;
17
+ }
18
+
19
+ export default persistDataHook ;
Original file line number Diff line number Diff line change 1
- import { store } from '@risingstack/react-easy-state' ;
1
+ import { autoEffect , clearEffect , store } from '@risingstack/react-easy-state' ;
2
2
import { IMRWebViewDetail } from '../../src/typings/commonTypes' ;
3
3
4
+ export const vscode = acquireVsCodeApi ( ) ;
5
+
4
6
const appStore = store ( {
5
- currentMR : { } as IMRWebViewDetail ,
7
+ currentMR : ( vscode . getState ( ) ?. currentMR || { } ) as IMRWebViewDetail ,
6
8
updateCurrentMR ( data : IMRWebViewDetail ) {
7
9
appStore . currentMR = data ;
8
10
} ,
9
11
} ) ;
10
12
13
+ export const persistData = ( ) =>
14
+ autoEffect ( ( ) => {
15
+ const p = vscode . getState ( ) ;
16
+ vscode . setState ( {
17
+ ...p ,
18
+ currentMR : appStore . currentMR ,
19
+ } ) ;
20
+ } ) ;
21
+ export const removeDataPersist = ( e : ( ) => void ) => clearEffect ( e ) ;
22
+
11
23
export default appStore ;
You can’t perform that action at this time.
0 commit comments