@@ -3,8 +3,9 @@ import { tauriBaseQuery } from '$lib/state/backendQuery';
3
3
import { butlerModule } from '$lib/state/butlerModule' ;
4
4
import { ReduxTag } from '$lib/state/tags' ;
5
5
import { uiStatePersistConfig , uiStateSlice } from '$lib/state/uiState.svelte' ;
6
+ import { mergeUnlisten } from '@gitbutler/ui/utils/mergeUnlisten' ;
6
7
import { combineReducers , configureStore } from '@reduxjs/toolkit' ;
7
- import { buildCreateApi , coreModule , type RootState } from '@reduxjs/toolkit/query' ;
8
+ import { buildCreateApi , coreModule , setupListeners , type RootState } from '@reduxjs/toolkit/query' ;
8
9
import { FLUSH , PAUSE , PERSIST , persistReducer , PURGE , REGISTER , REHYDRATE } from 'redux-persist' ;
9
10
import persistStore from 'redux-persist/lib/persistStore' ;
10
11
import type { Tauri } from '$lib/backend/tauri' ;
@@ -71,13 +72,17 @@ export class ClientState {
71
72
githubApi : this . githubApi ,
72
73
gitlabApi : this . gitlabApi
73
74
} ) ;
75
+ setupListeners ( this . store . dispatch ) ;
74
76
this . dispatch = this . store . dispatch ;
75
77
this . rootState = this . store . getState ( ) ;
76
78
77
79
$effect ( ( ) =>
78
- this . store . subscribe ( ( ) => {
79
- this . rootState = this . store . getState ( ) ;
80
- } )
80
+ mergeUnlisten (
81
+ this . store . subscribe ( ( ) => {
82
+ this . rootState = this . store . getState ( ) ;
83
+ } ) ,
84
+ setupListeners ( this . store . dispatch )
85
+ )
81
86
) ;
82
87
}
83
88
}
@@ -162,6 +167,8 @@ export function createGitHubApi(butlerMod: ReturnType<typeof butlerModule>) {
162
167
reducerPath : 'github' ,
163
168
tagTypes : Object . values ( ReduxTag ) ,
164
169
baseQuery : tauriBaseQuery ,
170
+ refetchOnFocus : true ,
171
+ refetchOnReconnect : true ,
165
172
endpoints : ( _ ) => {
166
173
return { } ;
167
174
}
@@ -178,6 +185,8 @@ export function createGitLabApi(butlerMod: ReturnType<typeof butlerModule>) {
178
185
reducerPath : 'gitlab' ,
179
186
tagTypes : Object . values ( ReduxTag ) ,
180
187
baseQuery : tauriBaseQuery ,
188
+ refetchOnFocus : true ,
189
+ refetchOnReconnect : true ,
181
190
endpoints : ( _ ) => {
182
191
return { } ;
183
192
}
0 commit comments