diff --git a/SimConnectMSFS/WasmModuleUpdater.cs b/SimConnectMSFS/WasmModuleUpdater.cs
index 0607f6bd..23f4e801 100644
--- a/SimConnectMSFS/WasmModuleUpdater.cs
+++ b/SimConnectMSFS/WasmModuleUpdater.cs
@@ -140,7 +140,6 @@ public bool InstallWasmModule(string communityFolder)
// Remove the old Wasm File
DeleteOldWasmFile(communityFolder);
- Log.Instance.log("WASM module has been installed successfully.", LogSeverity.Info);
return true;
}
@@ -188,7 +187,7 @@ public bool WasmModulesAreDifferent(string communityFolder)
string installedWASM;
string mobiflightWASM;
- if (communityFolder == null) return true;
+ if (String.IsNullOrEmpty(communityFolder)) return true;
string wasmModulePath = Path.Combine(communityFolder, @"mobiflight-event-module\modules\", WasmModuleName);
if (!File.Exists(wasmModulePath))
diff --git a/UI/MainForm.cs b/UI/MainForm.cs
index c2f78fa1..4ffc1a5e 100644
--- a/UI/MainForm.cs
+++ b/UI/MainForm.cs
@@ -2118,7 +2118,8 @@ private static void InstallWasmModule()
bool Update2020Successful = false;
bool Update2024Successful = false;
- try {
+ try
+ {
if (!updater.AutoDetectCommunityFolder())
{
@@ -2142,17 +2143,9 @@ private static void InstallWasmModule()
return;
}
- // Try updating the 2020 install
- if (Is2020Different)
- {
- Update2020Successful = updater.InstallWasmModule(updater.CommunityFolder);
- }
-
- // Try updating the 2024 install
- if (Is2024Different)
- {
- Update2024Successful = updater.InstallWasmModule(updater.CommunityFolder2024);
- }
+ // Install for both versions
+ Update2020Successful = HandleWasmInstall(updater, Is2020Different, updater.CommunityFolder, "2020");
+ Update2024Successful = HandleWasmInstall(updater, Is2024Different, updater.CommunityFolder2024, "2024");
// If either update is successful then show the success dialog.
if (Update2020Successful || Update2024Successful)
@@ -2164,7 +2157,8 @@ private static void InstallWasmModule()
return;
}
- } catch (Exception ex) {
+ }
+ catch (Exception ex) {
Log.Instance.log(ex.Message, LogSeverity.Error);
}
@@ -2175,6 +2169,38 @@ private static void InstallWasmModule()
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
+ ///
+ /// Handles all the necessary and log messages for installing the WASM with different versions of MSFS.
+ ///
+ /// The WASM updater to use
+ /// True if the versions of WASM were different
+ /// The path to the community folder
+ /// The version of MSFS, either "2020" or "2024"
+ ///
+ private static bool HandleWasmInstall(WasmModuleUpdater updater, bool isDifferent, string communityFolder, string msfsVersion)
+ {
+ if (String.IsNullOrEmpty(communityFolder))
+ {
+ Log.Instance.log($"Skipping WASM install for MSFS{msfsVersion} since no community folder was found. This likely means MSFS{msfsVersion} is not installed.", LogSeverity.Info);
+ return false;
+ }
+
+ if (!isDifferent)
+ {
+ Log.Instance.log($"WASM module for MSFS{msfsVersion} is already up-to-date.", LogSeverity.Info);
+ return false;
+ }
+
+ bool result = updater.InstallWasmModule(communityFolder);
+
+ if (result)
+ {
+ Log.Instance.log($"Successfully installed WASM module for MSFS{msfsVersion}.", LogSeverity.Info);
+ }
+
+ return result;
+ }
+
private void downloadLatestEventsToolStripMenuItem_Click(object sender, EventArgs e)
{
WasmModuleUpdater updater = new WasmModuleUpdater();