Skip to content

Commit

Permalink
feat: 슬롯에서 앱을 지우면 해당 앱의 기록은 초기화
Browse files Browse the repository at this point in the history
  • Loading branch information
potados99 committed Oct 14, 2023
1 parent 266d0b5 commit 69cefea
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
14 changes: 14 additions & 0 deletions FocusTimer/Features/Timer/Slot/AppItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,20 @@ public void Dispose()
}

public Domain.Entities.App App { get; }

public void ForceStartNewUsage()
{
this.GetLogger().Debug("강제로 새로운 AppUsage를 만들어줍니다.");

Usage = _appUsageService.CreateNewUsage(App);
Usage.IsConcentrated = IsCountedOnConcentrationCalculation;
Usage.OpenNewRunningUsage();
Usage.RunningUsage.OpenNewActiveUsage(); // 기존의 것을 또 건드리는 일을 막기 위해 일단 무지성으로 새로 만들어줍니다.

IsCountedOnConcentrationCalculation = Usage.IsConcentrated;

UpdateUsage();
}

private void RegisterEvents()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ public void ClearRegisteredApp()
{
this.GetLogger().Info($"현재 슬롯({SlotNumber}번)에 등록된 앱을 제거합니다.");

CurrentAppItem?.ForceStartNewUsage(); // 새 AppUsage를 시작합니다. 이렇게 하면 앱을 다시 불러왔을 때에 기록이 0인 상태로 시작하니, 리셋의 효과가 있습니다.
CurrentAppItem?.Dispose();
CurrentAppItem = null;

Expand Down

0 comments on commit 69cefea

Please sign in to comment.