@@ -18,20 +18,6 @@ const ArchiveComponent: React.FC<ArchiveComponentProps> = ({
1818 number | undefined
1919 > ( undefined ) ;
2020
21- const handleTriggerArchiving = (
22- doneFileAvailable : boolean ,
23- lineNumber ?: number ,
24- ) : void => {
25- setArchiveLineNumber ( lineNumber ) ;
26- setPromptItem (
27- doneFileAvailable
28- ? lineNumber
29- ? promptItemArchivingSingle
30- : promptItemArchivingAll
31- : promptItemChooseChangeFile ,
32- ) ;
33- } ;
34-
3521 const handleArchiveAllConfirm = ( ) : void => {
3622 ipcRenderer . send ( "archiveTodos" ) ;
3723 } ;
@@ -48,30 +34,46 @@ const ArchiveComponent: React.FC<ArchiveComponentProps> = ({
4834 ipcRenderer . send ( "createFile" , true , archiveLineNumber ) ;
4935 } ;
5036
51- const promptItemArchivingAll = {
52- id : "archive" ,
53- headline : t ( "prompt.archive.headline" ) ,
54- text : t ( "prompt.archive.text" ) ,
55- button1 : t ( "archive" ) ,
56- onButton1 : handleArchiveAllConfirm ,
57- } ;
37+ const handleTriggerArchiving = (
38+ doneFileAvailable : boolean ,
39+ lineNumber ?: number ,
40+ ) : void => {
41+ setArchiveLineNumber ( lineNumber ) ;
5842
59- const promptItemArchivingSingle = {
60- id : "archive" ,
61- headline : t ( "prompt.archive.headline.single" ) ,
62- text : t ( "prompt.archive.text.single" ) ,
63- button1 : t ( "archive" ) ,
64- onButton1 : handleArchiveSingleConfirm ,
65- } ;
43+ // Define prompt items here to get fresh translations every time
44+ const promptItemArchivingAll = {
45+ id : "archive" ,
46+ headline : t ( "prompt.archive.headline" ) ,
47+ text : t ( "prompt.archive.text" ) ,
48+ button1 : t ( "archive" ) ,
49+ onButton1 : handleArchiveAllConfirm ,
50+ } ;
51+
52+ const promptItemArchivingSingle = {
53+ id : "archive" ,
54+ headline : t ( "prompt.archive.headline.single" ) ,
55+ text : t ( "prompt.archive.text.single" ) ,
56+ button1 : t ( "archive" ) ,
57+ onButton1 : handleArchiveSingleConfirm ,
58+ } ;
59+
60+ const promptItemChooseChangeFile = {
61+ id : "changeFile" ,
62+ headline : t ( "prompt.archive.changeFile.headline" ) ,
63+ text : t ( "prompt.archive.changeFile.text" ) ,
64+ button1 : t ( "openFile" ) ,
65+ onButton1 : handleOpenDoneFile ,
66+ button2 : t ( "createFile" ) ,
67+ onButton2 : handleCreateDoneFile ,
68+ } ;
6669
67- const promptItemChooseChangeFile = {
68- id : "changeFile" ,
69- headline : t ( "prompt.archive.changeFile.headline" ) ,
70- text : t ( "prompt.archive.changeFile.text" ) ,
71- button1 : t ( "openFile" ) ,
72- onButton1 : handleOpenDoneFile ,
73- button2 : t ( "createFile" ) ,
74- onButton2 : handleCreateDoneFile ,
70+ setPromptItem (
71+ doneFileAvailable
72+ ? lineNumber
73+ ? promptItemArchivingSingle
74+ : promptItemArchivingAll
75+ : promptItemChooseChangeFile ,
76+ ) ;
7577 } ;
7678
7779 useEffect ( ( ) : void => {
@@ -85,7 +87,7 @@ const ArchiveComponent: React.FC<ArchiveComponentProps> = ({
8587 return ( ) : void => {
8688 ipcRenderer . off ( "triggerArchiving" , handleTriggerArchiving ) ;
8789 } ;
88- } , [ ] ) ;
90+ } , [ handleTriggerArchiving ] ) ;
8991
9092 return < > </ > ;
9193} ;
0 commit comments