@@ -11,19 +11,25 @@ import globals from '../extensionGlobals'
1111import { Manifest } from './types'
1212import { StageResolver , tryStageResolvers } from './utils/setupStage'
1313import { HttpResourceFetcher } from '../resourcefetcher/httpResourceFetcher'
14+ import * as localizedText from '../localizedText'
1415
1516const logger = getLogger ( 'lsp' )
1617
1718interface StorageManifest {
1819 etag : string
1920 content : string
21+ muteDeprecation : boolean
2022}
2123
2224type ManifestStorage = Record < string , StorageManifest >
2325
2426export const manifestStorageKey = 'aws.toolkit.lsp.manifest'
2527const manifestTimeoutMs = 15000
2628
29+ export async function resetManifestState ( ) {
30+ await globals . globalState . update ( manifestStorageKey , { } )
31+ }
32+
2733export class ManifestResolver {
2834 constructor (
2935 private readonly manifestURL : string ,
@@ -98,22 +104,42 @@ export class ManifestResolver {
98104 }
99105 }
100106
107+ /**
108+ * Check if the current manifest is deprecated.
109+ * If yes and user hasn't muted this notification, shows a toast message with two buttons:
110+ * - OK: close and do nothing
111+ * - Don't Show Again: Update global state (muteDecprecation) so the deprecation message is never shown for this manifest.
112+ * @param manifest
113+ */
101114 private checkDeprecation ( manifest : Manifest ) : void {
102- if ( manifest . isManifestDeprecated ) {
115+ if ( manifest . isManifestDeprecated && ! this . getStorage ( ) [ this . lsName ] . muteDeprecation ) {
103116 const deprecationMessage = `${ this . lsName } manifest is deprecated. No future updates will be available.`
104117 logger . info ( deprecationMessage )
105- void vscode . window . showInformationMessage ( deprecationMessage )
118+
119+ void vscode . window
120+ . showInformationMessage ( deprecationMessage , localizedText . ok , localizedText . dontShow )
121+ . then ( ( button ) => {
122+ if ( button === localizedText . dontShow ) {
123+ this . getStorage ( ) [ this . lsName ] . muteDeprecation = true
124+ }
125+ } )
106126 }
107127 }
108128
109129 private async saveManifest ( etag : string , content : string ) : Promise < void > {
110130 const storage = this . getStorage ( )
111131
132+ // Only true when incoming manifest is deprecated & existing muteDeprecation is true (set by user)
133+ const muteDeprecation =
134+ ( storage [ this . lsName ] ? storage [ this . lsName ] . muteDeprecation : false ) &&
135+ ( JSON . parse ( content ) as Manifest ) . isManifestDeprecated
136+
112137 globals . globalState . tryUpdate ( manifestStorageKey , {
113138 ...storage ,
114139 [ this . lsName ] : {
115140 etag,
116141 content,
142+ muteDeprecation,
117143 } ,
118144 } )
119145 }
0 commit comments