Skip to content

Commit 77e8b71

Browse files
committed
Fix idle status enabled not saving
1 parent 49fc73f commit 77e8b71

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

src/PlexRichPresence.UI.Avalonia/App.axaml.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -160,10 +160,7 @@ private void Exit_Onclick(object? _, EventArgs e)
160160
?? throw new InvalidOperationException("Can't get storage service from DI");
161161
PlexActivityPageViewModel viewModel = serviceProvider.GetService<PlexActivityPageViewModel>()
162162
?? throw new InvalidOperationException("Can't get storage service from DI");
163-
if (!viewModel.EnableIdleStatus)
164-
{
165-
storageService.PutAsync("enableIdleStatus", bool.FalseString);
166-
}
163+
storageService.PutAsync("enableIdleStatus", viewModel.EnableIdleStatus.ToString());
167164
}
168165
desktop.Shutdown();
169166
}

test/PlexRichPresence.ViewModels.Test/ViewModels/PlexActivityPageViewModelTests.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -178,8 +178,10 @@ public async Task IsOwner_IdleEnabled_DontPostDiscordStatus()
178178
plexActivityService.CurrentUserToken.Should().Be(fakePlexToken);
179179
}
180180

181-
[Fact]
182-
public async Task InitStrategy_IdleEnabledInStorage_LoadsIdleEnabled()
181+
[Theory]
182+
[InlineData(true)]
183+
[InlineData(false)]
184+
public async Task InitStrategy_IdleEnabledRetrievedFromStorage(bool idleEnabled)
183185
{
184186
// Given
185187
const string fakePlexToken = "fake plex token";
@@ -193,7 +195,7 @@ public async Task InitStrategy_IdleEnabledInStorage_LoadsIdleEnabled()
193195
["isServerOwned"] = bool.TrueString,
194196
["plex_token"] = fakePlexToken,
195197
["plexUserName"] = fakePlexUserName,
196-
["enableIdleStatus"] = "false",
198+
["enableIdleStatus"] = idleEnabled.ToString(),
197199
});
198200
var viewModel = new PlexActivityPageViewModel(
199201
new FakePlexActivityService(),
@@ -207,7 +209,7 @@ public async Task InitStrategy_IdleEnabledInStorage_LoadsIdleEnabled()
207209
await viewModel.InitStrategyCommand.ExecuteAsync(null);
208210

209211
// Then
210-
viewModel.EnableIdleStatus.Should().BeFalse();
212+
viewModel.EnableIdleStatus.Should().Be(idleEnabled);
211213

212214
}
213215

0 commit comments

Comments
 (0)