Browse Source

Disable buttons while migrating & setup migrated flag

pull/14/head
JT 1 year ago
parent
commit
1863c8fbc3
  1. 3
      StabilityMatrix/DataDirectoryMigrationDialog.xaml
  2. 1
      StabilityMatrix/Helper/ISettingsManager.cs
  3. 6
      StabilityMatrix/Helper/SettingsManager.cs
  4. 1
      StabilityMatrix/Models/Settings/Settings.cs
  5. 9
      StabilityMatrix/ViewModels/DataDirectoryMigrationViewModel.cs
  6. 2
      StabilityMatrix/ViewModels/LaunchViewModel.cs
  7. 2
      StabilityMatrix/ViewModels/MainWindowViewModel.cs

3
StabilityMatrix/DataDirectoryMigrationDialog.xaml

@ -23,6 +23,7 @@
<!-- ReSharper disable once Xaml.StaticResourceNotResolved -->
<Style BasedOn="{StaticResource {x:Type ui:ContentDialog}}" TargetType="{x:Type local:DataDirectoryMigrationDialog}" />
<BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />
<converters:BoolNegationConverter x:Key="BoolNegationConverter"/>
<converters:ValueConverterGroup x:Key="InvertIsStringNullOrWhitespaceConverter">
<converters:IsStringNullOrWhitespaceConverter />
<converters:BoolNegationConverter />
@ -88,6 +89,7 @@
FontSize="16"
HorizontalAlignment="Center"
Margin="8"
IsEnabled="{Binding IsMigrating, Converter={StaticResource BoolNegationConverter}}"
Padding="16,8" />
<ui:Button
Appearance="Success"
@ -96,6 +98,7 @@
FontSize="16"
HorizontalAlignment="Center"
Margin="8"
IsEnabled="{Binding IsMigrating, Converter={StaticResource BoolNegationConverter}}"
Padding="16,8" />
</StackPanel>
</Grid>

1
StabilityMatrix/Helper/ISettingsManager.cs

@ -71,4 +71,5 @@ public interface ISettingsManager
Guid GetOldActivePackageId();
void SetActiveInstalledPackage(Guid guid);
void SetIsImportAsConnected(bool value);
void SetHasMigrated(bool hasMigrated);
}

6
StabilityMatrix/Helper/SettingsManager.cs

@ -414,6 +414,12 @@ public class SettingsManager : ISettingsManager
Settings.ModelSearchOptions = options;
SaveSettings();
}
public void SetHasMigrated(bool hasMigrated)
{
Settings.HasMigrated = hasMigrated;
SaveSettings();
}
/// <summary>
/// Loads settings from the settings file

1
StabilityMatrix/Models/Settings/Settings.cs

@ -24,6 +24,7 @@ public class Settings
public bool ModelBrowserNsfwEnabled { get; set; }
public bool IsNavExpanded { get; set; }
public bool IsImportAsConnected { get; set; }
public bool HasMigrated { get; set; }
public SharedFolderType? SharedFolderVisibleCategories { get; set; } =
SharedFolderType.StableDiffusion |

9
StabilityMatrix/ViewModels/DataDirectoryMigrationViewModel.cs

@ -33,6 +33,8 @@ public partial class DataDirectoryMigrationViewModel : ObservableObject
[ObservableProperty]
[NotifyPropertyChangedFor(nameof(MigrateProgressText))]
private int migrateProgressCount;
[ObservableProperty] private bool isMigrating;
public string AutoMigrateText => AutoMigrateCount == 0 ? string.Empty :
$"{AutoMigrateCount} Packages will be automatically migrated to the new format";
@ -77,6 +79,8 @@ public partial class DataDirectoryMigrationViewModel : ObservableObject
{
await using var delay = new MinimumDelay(200, 300);
IsMigrating = true;
// Since we are going to recreate venvs, need python to be installed
if (!prerequisiteHelper.IsPythonInstalled)
{
@ -136,8 +140,11 @@ public partial class DataDirectoryMigrationViewModel : ObservableObject
"StabilityMatrix", "Models");
var newModelsDir = Path.Combine(libraryPath, "Models");
Utilities.CopyDirectory(oldModelsDir, newModelsDir, true);
settingsManager.SetHasMigrated(true);
}
IsMigrating = false;
EventManager.Instance.OnInstalledPackagesChanged();
}
}

2
StabilityMatrix/ViewModels/LaunchViewModel.cs

@ -342,7 +342,7 @@ public partial class LaunchViewModel : ObservableObject
{
ConsoleHistory[^2] = output.TrimEnd('\n');
}
else if ((output.Contains("it/s") || output.Contains("s/it")) &&
else if ((output.Contains("it/s") || output.Contains("s/it") || output.Contains("B/s")) &&
!output.Contains("Total progress") && !output.Contains(" 0%"))
{
ConsoleHistory[^1] = output.TrimEnd('\n');

2
StabilityMatrix/ViewModels/MainWindowViewModel.cs

@ -167,7 +167,7 @@ public partial class MainWindowViewModel : ObservableObject
}
// Check if there are old packages, if so show migration dialog
if (settingsManager.GetOldInstalledPackages().Any())
if (settingsManager.GetOldInstalledPackages().Any() && !settingsManager.Settings.HasMigrated)
{
var dialog = dialogFactory.CreateDataDirectoryMigrationDialog();
var result = await dialog.ShowAsync();

Loading…
Cancel
Save