Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
English (US) release notes, mirroring CHANGELOG.md (Brazilian Portuguese). Before publishing a version, add a `## [VERSION]` section to **both** files: the workflow publishes the section matching the tag from each one and fails if either is missing.

## [Unreleased]
### Fixes
- Settings: `config.json` keeps the settings this version doesn't know instead of dropping them on save. It is what lets you switch between the current version and **Legacy** (the old interface, published next to 1.7.0) without losing anything on either side. (#201)

## [1.7.0-beta.4]
### What's new
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
Notas em português do Brasil; a versão em inglês (Estados Unidos) fica em `CHANGELOG.en-US.md`. Antes de publicar uma versão, adicione uma seção `## [VERSÃO]` com o changelog daquela versão **nos dois arquivos**. O workflow publica as duas seções correspondentes à tag na mesma release e falha se faltar alguma.

## [Unreleased]
### Correções
- Ajustes: o `config.json` guarda de volta os ajustes que esta versão não conhece em vez de descartá-los ao salvar. É o que deixa trocar entre a versão atual e a **Legacy** (a interface antiga, publicada junto da 1.7.0) sem perder nada dos dois lados. (#201)

## [1.7.0-beta.4]
### Novidades
Expand Down
6 changes: 6 additions & 0 deletions src/ConsoleMode/Models/Models.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System.Text.Json;
using System.Text.Json.Serialization;
using ConsoleMode.Services;

Expand All @@ -7,6 +8,11 @@ public sealed class AppConfig
{
/// <summary>2 = monitor fields hold <see cref="MonitorInfo.StableId"/>; 0/1 = GDI names (\\.\DISPLAYn).</summary>
public int Version { get; set; }
/// <summary>
/// Settings this version doesn't have: the Legacy build's (which interface it shows, its tour) or a newer
/// version's. Kept as they came and saved back, so switching between builds loses nothing on either side.
/// </summary>
[JsonExtensionData] public Dictionary<string, JsonElement>? OtherSettings { get; set; }
/// <summary>Empty until the user (or the installer) picks one; the app then follows Windows.</summary>
public string AppLanguage { get; set; } = "";
public string FocusMonitor { get; set; } = "";
Expand Down
1 change: 1 addition & 0 deletions src/ConsoleMode/ViewModels/MainViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -875,6 +875,7 @@ private AppConfig BuildConfig()
var auto = audioId == ConsoleEngine.AudioOnConnectId;
var config = new AppConfig
{
OtherSettings = _loadedConfig.OtherSettings,
AppLanguage = SelectedLanguage?.Value ?? LocalizationService.Language,
// Listing failed: keep the saved screens instead of wiping them.
FocusMonitor = _loadedConfig.FocusMonitor,
Expand Down
23 changes: 23 additions & 0 deletions tests/ConsoleMode.Tests/AppConfigTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,29 @@ namespace ConsoleMode.Tests;

public class AppConfigTests
{
// The Legacy build (1.6.2's interfaces) shares config.json and has settings this version dropped.
[Fact]
public void Settings_of_another_build_survive_a_save()
{
var options = new System.Text.Json.JsonSerializerOptions
{
PropertyNamingPolicy = System.Text.Json.JsonNamingPolicy.CamelCase,
DefaultIgnoreCondition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingNull
};
var config = System.Text.Json.JsonSerializer.Deserialize<AppConfig>(
"""{ "version": 2, "uiMode": "desktop", "tourDone": true, "parkPointer": false }""", options)!;
Assert.False(config.ParkPointer);

config.HdrEnable = true;
using var saved = System.Text.Json.JsonDocument.Parse(System.Text.Json.JsonSerializer.Serialize(config, options));
Assert.Equal("desktop", saved.RootElement.GetProperty("uiMode").GetString());
Assert.True(saved.RootElement.GetProperty("tourDone").GetBoolean());
Assert.True(saved.RootElement.GetProperty("hdrEnable").GetBoolean());
// Nothing extra in a config of its own.
Assert.Null(new AppConfig().OtherSettings);
Assert.DoesNotContain("otherSettings", System.Text.Json.JsonSerializer.Serialize(new AppConfig(), options));
}

[Fact]
public void Copy_for_a_session_swaps_only_the_monitor_fields()
{
Expand Down
Loading