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 {
7272 }
7373
7474 Logger . error ( `Error reading sessions: ${ e } ` ) ;
75- await keychain . deleteToken ( TokenType . AccessToken ) ;
75+ // await keychain.deleteToken(TokenType.AccessToken);
7676 }
7777 }
7878
Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ import styled from 'styled-components';
44import { view } from '@risingstack/react-easy-state' ;
55import appStore from './store/appStore' ;
66import { actions } from './store/constants' ;
7+ import persistDataHook from './hooks/persistDataHook' ;
78
89const LoadingWrapper = styled . div `
910 font-size: 16px;
@@ -31,12 +32,13 @@ function App() {
3132 break ;
3233 }
3334 default :
34- console . log ( type , value ) ;
3535 break ;
3636 }
3737 } ) ;
3838 } , [ updateCurrentMR ] ) ;
3939
40+ persistDataHook ( ) ;
41+
4042 if ( ! currentMR . iid ) {
4143 return < LoadingWrapper > Please select an merge request first.</ LoadingWrapper > ;
4244 }
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' ;
22import { IMRWebViewDetail } from '../../src/typings/commonTypes' ;
33
4+ export const vscode = acquireVsCodeApi ( ) ;
5+
46const appStore = store ( {
5- currentMR : { } as IMRWebViewDetail ,
7+ currentMR : ( vscode . getState ( ) ?. currentMR || { } ) as IMRWebViewDetail ,
68 updateCurrentMR ( data : IMRWebViewDetail ) {
79 appStore . currentMR = data ;
810 } ,
911} ) ;
1012
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+
1123export default appStore ;
You can’t perform that action at this time.
0 commit comments