• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

thorstenalpers / CleanMyPosts / 15181658063

22 May 2025 08:20AM UTC coverage: 23.225% (+9.2%) from 14.069%
15181658063

push

github

thorstenalpers
Merge VersionInfo into Helper

86 of 356 branches covered (24.16%)

Branch coverage included in aggregate %.

3 of 3 new or added lines in 1 file covered. (100.0%)

102 existing lines in 7 files now uncovered.

277 of 1207 relevant lines covered (22.95%)

0.63 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

44.23
/src/UI/ViewModels/SettingsViewModel.cs
1
using System.Diagnostics;
2
using CleanMyPosts.UI.Contracts.Services;
3
using CleanMyPosts.UI.Contracts.ViewModels;
4
using CleanMyPosts.UI.Helpers;
5
using CleanMyPosts.UI.Models;
6
using CommunityToolkit.Mvvm.ComponentModel;
7
using CommunityToolkit.Mvvm.Input;
8
using Microsoft.Extensions.Logging;
9

10
namespace CleanMyPosts.UI.ViewModels;
11

12
public partial class SettingsViewModel(ILogger<SettingsViewModel> logger,
2✔
13
    IUserSettingsService userSettingsService,
2✔
14
    IUpdateService updateService) : ObservableObject, INavigationAware
2✔
15
{
16
    private readonly ILogger<SettingsViewModel> _logger = logger ?? throw new ArgumentNullException(nameof(logger));
2!
17
    private readonly IUserSettingsService _userSettingsService = userSettingsService ?? throw new ArgumentNullException(nameof(userSettingsService));
2!
18
    private readonly IUpdateService _updateService = updateService ?? throw new ArgumentNullException(nameof(updateService));
2!
19

20
    [ObservableProperty]
21
    private string _versionDescription;
22

23
    [ObservableProperty]
24
    private AppTheme _theme;
25

26
    [ObservableProperty]
27
    private bool _showLogs;
28

29
    [ObservableProperty]
30
    private bool _confirmDeletion;
31

32
    [ObservableProperty]
33
    private int _waitBeforeTryClickDelete;
34

35
    [ObservableProperty]
36
    private int _waitBetweenTryClickDeleteAttempts;
37

38
    [RelayCommand]
39
    private void SetTheme(string themeName)
40
    {
41
        if (Enum.TryParse<AppTheme>(themeName, out var theme))
1✔
42
        {
43
            _userSettingsService.SetTheme(theme);
1✔
44
        }
45
    }
1✔
46

47
    [RelayCommand]
48
    private void OpenLicense()
49
    {
50
        Process.Start(new ProcessStartInfo
×
51
        {
×
UNCOV
52
            FileName = "license.txt",
×
UNCOV
53
            UseShellExecute = true
×
UNCOV
54
        });
×
55
    }
×
56

57
    [RelayCommand]
58
    private void OpenHomepage()
59
    {
UNCOV
60
        Process.Start(new ProcessStartInfo
×
UNCOV
61
        {
×
UNCOV
62
            FileName = "https://github.com/thorstenalpers/CleanMyPosts/blob/main/THIRD_PARTY_LICENSES.txt",
×
UNCOV
63
            UseShellExecute = true
×
UNCOV
64
        });
×
UNCOV
65
    }
×
66

67
    [RelayCommand]
68
    private async Task CheckUpdatesAsync()
69
    {
70
        try
71
        {
UNCOV
72
            await _updateService.CheckForUpdatesAsync();
×
UNCOV
73
        }
×
UNCOV
74
        catch (Exception ex)
×
75
        {
UNCOV
76
            _logger.LogError(ex, "Check for updates failed.");
×
UNCOV
77
        }
×
UNCOV
78
    }
×
79
    partial void OnThemeChanged(AppTheme value)
80
    {
81
        _userSettingsService.SetTheme(value);
1✔
82
    }
1✔
83

84
    partial void OnShowLogsChanged(bool value)
85
    {
UNCOV
86
        _userSettingsService.SetShowLogs(value);
×
UNCOV
87
    }
×
88

89
    partial void OnConfirmDeletionChanged(bool value)
90
    {
UNCOV
91
        _userSettingsService.SetConfirmDeletion(value);
×
UNCOV
92
    }
×
93

94
    partial void OnWaitBeforeTryClickDeleteChanged(int value)
95
    {
UNCOV
96
        _userSettingsService.SetSetting(nameof(WaitBeforeTryClickDelete), WaitBeforeTryClickDelete);
×
UNCOV
97
    }
×
98

99
    partial void OnWaitBetweenTryClickDeleteAttemptsChanged(int value)
100
    {
UNCOV
101
        _userSettingsService.SetSetting(nameof(WaitBetweenTryClickDeleteAttempts), WaitBetweenTryClickDeleteAttempts);
×
UNCOV
102
    }
×
103

104
    public void OnNavigatedTo(object parameter)
105
    {
106
        VersionDescription = $"{Properties.Resources.AppDisplayName} - {Helper.GetVersion()}";
1✔
107
        Theme = _userSettingsService.GetCurrentTheme();
1✔
108
        ShowLogs = _userSettingsService.GetShowLogs();
1✔
109
        ConfirmDeletion = _userSettingsService.GetConfirmDeletion();
1✔
110

111
        // Ensure property setters are used so On*Changed partials are called
112
        WaitBeforeTryClickDelete = _userSettingsService.GetWaitBeforeTryClickDelete();
1✔
113
        WaitBetweenTryClickDeleteAttempts = _userSettingsService.GetWaitBetweenTryClickDeleteAttempts();
1✔
114
    }
1✔
115
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc