Skip to content

Commit

Permalink
perf(view): ⚡ do not re-create background fetches when searching for …
Browse files Browse the repository at this point in the history
…span
  • Loading branch information
JamesNZL committed May 17, 2023
1 parent 8dee4b4 commit 04d0b70
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/TogglTrack.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1415,18 +1415,21 @@ internal async ValueTask<List<Result>> RequestViewReports(CancellationToken toke
Grouping = 2,
};

/*
* Report span selection --- tgl view [day | week | month | year]
*/
if (query.SearchTerms.Length == ArgumentIndices.Span || !Settings.ViewSpanArguments.Exists(span => span.Argument == query.SearchTerms[ArgumentIndices.Span]))
if (query.SearchTerms.Length == ArgumentIndices.Span)
{
// Start fetch for running time entries asynchronously in the backgroundd
// Start fetch for running time entries asynchronously in the background
_ = Task.Run(() =>
{
// TODO: this does too many fetches
_ = this._GetRunningTimeEntry(true);
});
}

/*
* Report span selection --- tgl view [day | week | month | year]
*/

if (query.SearchTerms.Length == ArgumentIndices.Span || !Settings.ViewSpanArguments.Exists(span => span.Argument == query.SearchTerms[ArgumentIndices.Span]))
{
var spans = Settings.ViewSpanArguments.ConvertAll(span =>
{
return new Result
Expand Down

0 comments on commit 04d0b70

Please sign in to comment.