66 SEARCH_TERM_INPUT_ID ,
77} from './popup/constants'
88import {
9+ Hint ,
10+ HintPreferences ,
911 SearchReplaceActions ,
1012 SearchReplaceBackgroundMessage ,
1113 SearchReplaceContentMessage ,
@@ -268,15 +270,32 @@ function setCount(result: SearchReplaceResult, translationFn: TranslationProxy)
268270 }
269271}
270272
271- function setHints ( hints ?: string [ ] ) {
273+ function setHints ( hints ?: Hint [ ] ) {
272274 const hintsElement = document . getElementById ( 'hints' )
273275 if ( hintsElement ) {
274276 hintsElement . innerHTML = ''
275277 if ( hints ) {
278+ console . log ( 'Hints' , hints )
276279 for ( const hint of hints ) {
280+ console . log ( 'hint' , hint )
281+ // check that this hint has not been previously dismissed by reading the local storage
282+
277283 const hintElement = document . createElement ( 'div' )
278- hintElement . innerText = hint
279- hintElement . className = 'hint alert alert-info'
284+ hintElement . innerText = hint . hint
285+ hintElement . setAttribute ( 'role' , 'alert' )
286+ const dismissButton = document . createElement ( 'button' )
287+ dismissButton . className = 'btn-close'
288+ dismissButton . setAttribute ( 'data-bs-dismiss' , 'alert' )
289+ dismissButton . setAttribute ( 'aria-label' , 'Close' )
290+ dismissButton . setAttribute ( 'type' , 'button' )
291+ hintElement . appendChild ( dismissButton )
292+ dismissButton . onclick = function ( ) {
293+ const searchReplaceInput = getInputValues ( false )
294+ const history = constructSearchReplaceHistory ( )
295+ const hintPreferences : HintPreferences = { [ hint . name ] : true }
296+ sendToStorage ( searchReplaceInput , history , hintPreferences )
297+ }
298+ hintElement . className = 'hint alert alert-info alert-dismissible'
280299 hintsElement . appendChild ( hintElement )
281300 }
282301 }
@@ -310,14 +329,15 @@ async function storeTerms(
310329 // This counts the terms on the page
311330 const url = await contentScriptCall ( 'count' , searchReplaceInput , history )
312331 // This sends the search replace terms to the background page and stores them
313- sendToStorage ( searchReplaceInput , history , url , save )
332+ sendToStorage ( searchReplaceInput , history , { } , url , save )
314333 }
315334 }
316335}
317336
318337function sendToStorage (
319338 searchReplaceInstance : SearchReplaceInstance ,
320339 history : SearchReplaceInstance [ ] ,
340+ hintPreferences ?: HintPreferences ,
321341 url ?: string ,
322342 save ?: boolean
323343) {
@@ -329,6 +349,7 @@ function sendToStorage(
329349 storage : {
330350 instance : searchReplaceInstance ,
331351 history,
352+ hintPreferences,
332353 } ,
333354 action : 'store' ,
334355 url,
0 commit comments