@@ -36,6 +36,7 @@ public class QAVSOperation
3636 public QAVSOperationType type { get ; set ; } = QAVSOperationType . ModInstall ;
3737 public string name { get ; set ; } = "" ;
3838 public int operationId { get ; set ; } = 0 ;
39+ public bool isDone { get ; set ; } = false ;
3940 }
4041
4142 public class QAVSModManager
@@ -97,7 +98,7 @@ public QueuedMod(string path, string filename, int operationId)
9798 public static void InstallFirstModFromQueue ( )
9899 {
99100 if ( installingMod || installQueue . Count <= 0 ) return ;
100- runningOperations . Remove ( installQueue [ 0 ] . queuedOperationId ) ;
101+ runningOperations [ installQueue [ 0 ] . queuedOperationId ] . isDone = true ;
101102 installingMod = true ;
102103 int operationId = operations ;
103104 operations ++ ;
@@ -108,7 +109,7 @@ public static void InstallFirstModFromQueue()
108109 File . Move ( installQueue [ 0 ] . path , Path . GetDirectoryName ( installQueue [ 0 ] . path ) + Path . DirectorySeparatorChar + installQueue [ 0 ] . filename ) ;
109110 installQueue [ 0 ] . path = Path . GetDirectoryName ( installQueue [ 0 ] . path ) + Path . DirectorySeparatorChar + installQueue [ 0 ] . filename ;
110111 CoreVars . cosmetics . InstallCosmetic ( CoreService . coreVars . currentApp , Path . GetExtension ( installQueue [ 0 ] . filename ) , installQueue [ 0 ] . path , true ) ;
111- runningOperations . Remove ( operationId ) ;
112+ runningOperations [ operationId ] . isDone = true ;
112113 installQueue . RemoveAt ( 0 ) ;
113114 installingMod = false ;
114115 InstallFirstModFromQueue ( ) ;
@@ -118,10 +119,10 @@ public static void InstallFirstModFromQueue()
118119 {
119120 IMod mod = modManager . TryParseMod ( installQueue [ 0 ] . path ) . Result ;
120121 mod . Install ( ) . Wait ( ) ;
121- runningOperations . Remove ( operationId ) ;
122+ runningOperations [ operationId ] . isDone = true ;
122123 } catch ( Exception e )
123124 {
124- runningOperations . Remove ( operationId ) ;
125+ runningOperations [ operationId ] . isDone = true ;
125126 operationId = operations ;
126127 operations ++ ;
127128 runningOperations . Add ( operationId , new QAVSOperation { type = QAVSOperationType . Error , name = "Error installing mod: " + e . Message + "\n \n To remove this message restart QuestAppVersionSwitcher" , operationId = operationId } ) ;
@@ -158,7 +159,7 @@ public static void UninstallMod(string id)
158159 }
159160
160161 // {"success": true, "msg": "Success/Error: blah blah"}
161- runningOperations . Remove ( operationId ) ;
162+ runningOperations [ operationId ] . isDone = true ;
162163 }
163164
164165 public static void DeleteMod ( string id )
@@ -175,7 +176,7 @@ public static void DeleteMod(string id)
175176 break ;
176177 }
177178 }
178- runningOperations . Remove ( operationId ) ;
179+ runningOperations [ operationId ] . isDone = true ;
179180 }
180181
181182 public static void InstallModFromUrl ( string url )
@@ -193,15 +194,15 @@ public static void InstallModFromUrl(string url)
193194 //CoreService.browser.EvaluateJavascript("ShowToast('Downloaded, now installing', '#FFFFFF', '#222222')", null);
194195 Thread t = new Thread ( ( ) =>
195196 {
196- runningOperations . Remove ( operationId ) ;
197+ runningOperations [ operationId ] . isDone = true ;
197198 InstallMod ( modPath , Path . GetFileName ( modPath ) ) ;
198199 FileManager . DeleteFileIfExisting ( modPath ) ;
199200 } ) ;
200201 t . Start ( ) ;
201202 } ;
202203 m . DownloadCanceled += manager =>
203204 {
204- runningOperations . Remove ( operationId ) ;
205+ runningOperations [ operationId ] . isDone = true ;
205206 } ;
206207 m . StartDownload ( url , modPath ) ;
207208 QAVSWebserver . managers . Add ( m ) ;
@@ -221,10 +222,10 @@ public static void EnableMod(string id)
221222 {
222223 m . Install ( ) . Wait ( ) ;
223224 modManager . ForceSave ( ) ;
224- runningOperations . Remove ( operationId ) ;
225+ runningOperations [ operationId ] . isDone = true ;
225226 } catch ( Exception e )
226227 {
227- runningOperations . Remove ( operationId ) ;
228+ runningOperations [ operationId ] . isDone = true ;
228229 operationId = operations ;
229230 operations ++ ;
230231 runningOperations . Add ( operationId , new QAVSOperation { type = QAVSOperationType . Error , name = "Error enabling mod: " + e . Message + "\n \n To remove this message restart QuestAppVersionSwitcher" , operationId = operationId } ) ;
@@ -243,6 +244,12 @@ public static string GetMods()
243244 operations = runningOperations . Values . ToList ( )
244245 } ) ;
245246 }
247+
248+
249+ public static string GetOperations ( )
250+ {
251+ return JsonSerializer . Serialize ( runningOperations ) ;
252+ }
246253
247254 public static byte [ ] GetModCover ( string id )
248255 {
0 commit comments