@@ -2243,15 +2243,13 @@ async function shouldShowEndOfLifeWarning(
22432243 debug : Logger [ 'debug' ]
22442244) {
22452245 try {
2246- const { showEndOfLifeConnectionModal, networkTraffic } =
2247- preferences . getPreferences ( ) ;
2248- if ( ! showEndOfLifeConnectionModal ) {
2249- return ;
2250- }
22512246 const latestEndOfLifeServerVersion = await getLatestEndOfLifeServerVersion (
2252- networkTraffic
2247+ preferences . getPreferences ( ) . networkTraffic
2248+ ) ;
2249+ return (
2250+ preferences . getPreferences ( ) . showEndOfLifeConnectionModal &&
2251+ isEndOfLifeVersion ( serverVersion , latestEndOfLifeServerVersion )
22532252 ) ;
2254- return isEndOfLifeVersion ( serverVersion , latestEndOfLifeServerVersion ) ;
22552253 } catch ( err ) {
22562254 debug (
22572255 'failed to get instance details to determine if the server version is end-of-life' ,
@@ -2265,10 +2263,24 @@ export const showEndOfLifeMongoDBWarningModal = (
22652263 connectionId : string ,
22662264 version : string
22672265) : ConnectionsThunkAction < void > => {
2268- return ( _dispatch , getState , { track } ) => {
2266+ return ( _dispatch , getState , { track, preferences } ) => {
2267+ const abortController = new AbortController ( ) ;
2268+ const removeListener = preferences . onPreferenceValueChanged (
2269+ 'showEndOfLifeConnectionModal' ,
2270+ ( shouldShow ) => {
2271+ if ( ! shouldShow ) {
2272+ abortController . abort ( ) ;
2273+ removeListener ( ) ;
2274+ }
2275+ }
2276+ ) ;
22692277 const connectionInfo = getCurrentConnectionInfo ( getState ( ) , connectionId ) ;
22702278 track ( 'Screen' , { name : 'end_of_life_mongodb_modal' } , connectionInfo ) ;
2271- void _showEndOfLifeMongoDBWarningModal ( connectionInfo , version ) ;
2279+ void _showEndOfLifeMongoDBWarningModal (
2280+ connectionInfo ,
2281+ version ,
2282+ abortController . signal
2283+ ) ;
22722284 } ;
22732285} ;
22742286
0 commit comments