Skip to content

Commit

Permalink
fix(ux): 🚸 fix missing edit usage tips if any flag present (#108)
Browse files Browse the repository at this point in the history
  • Loading branch information
JamesNZL committed Jul 7, 2023
1 parent ea60b68 commit 4ddf83c
Showing 1 changed file with 54 additions and 54 deletions.
108 changes: 54 additions & 54 deletions src/TogglTrack.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1867,6 +1867,60 @@ private async ValueTask<List<Result>> _GetEditResults(CancellationToken token, Q
bool hasTimeSpanEndFlag = query.SearchTerms.Contains(Settings.TimeSpanEndFlag);
bool hasResumeFlag = query.SearchTerms.Contains(Settings.ResumeFlag);

if (this._settings.ShowUsageTips)
{
if (!hasTimeSpanFlag)
{
results.Add(new Result
{
Title = Settings.UsageTipTitle,
SubTitle = $"Use {Settings.TimeSpanFlag} after the description to edit the start time",
IcoPath = "tip.png",
AutoCompleteText = $"{query.ActionKeyword} {query.Search} {Settings.TimeSpanFlag} ",
Score = 70,
Action = _ =>
{
this._context.API.ChangeQuery($"{query.ActionKeyword} {query.Search} {Settings.TimeSpanFlag} ");
return false;
}
});
}

if (!hasTimeSpanEndFlag && !hasResumeFlag)
{
results.Add(new Result
{
Title = Settings.UsageTipTitle,
SubTitle = $"Use {Settings.TimeSpanEndFlag} after the description to edit the stop time",
IcoPath = "tip.png",
AutoCompleteText = $"{query.ActionKeyword} {query.Search} {Settings.TimeSpanEndFlag} ",
Score = 50,
Action = _ =>
{
this._context.API.ChangeQuery($"{query.ActionKeyword} {query.Search} {Settings.TimeSpanEndFlag} ");
return false;
}
});
}

if (!timeEntry.IsRunning && !hasResumeFlag && !hasTimeSpanEndFlag)
{
results.Add(new Result
{
Title = Settings.UsageTipTitle,
SubTitle = $"Use {Settings.ResumeFlag} to resume this time entry",
IcoPath = "tip.png",
AutoCompleteText = $"{query.ActionKeyword} {query.Search} {Settings.ResumeFlag} ",
Score = 30,
Action = _ =>
{
this._context.API.ChangeQuery($"{query.ActionKeyword} {query.Search} {Settings.ResumeFlag} ");
return false;
}
});
}
}

if (!hasTimeSpanFlag && !hasTimeSpanEndFlag && !hasResumeFlag)
{
results.Add(new Result
Expand Down Expand Up @@ -1994,60 +2048,6 @@ private async ValueTask<List<Result>> _GetEditResults(CancellationToken token, Q
});
}));
}

if (this._settings.ShowUsageTips)
{
if (!hasTimeSpanFlag)
{
results.Add(new Result
{
Title = Settings.UsageTipTitle,
SubTitle = $"Use {Settings.TimeSpanFlag} after the description to edit the start time",
IcoPath = "tip.png",
AutoCompleteText = $"{query.ActionKeyword} {query.Search} {Settings.TimeSpanFlag} ",
Score = 70,
Action = _ =>
{
this._context.API.ChangeQuery($"{query.ActionKeyword} {query.Search} {Settings.TimeSpanFlag} ");
return false;
}
});
}

if (!hasTimeSpanEndFlag)
{
results.Add(new Result
{
Title = Settings.UsageTipTitle,
SubTitle = $"Use {Settings.TimeSpanEndFlag} after the description to edit the stop time",
IcoPath = "tip.png",
AutoCompleteText = $"{query.ActionKeyword} {query.Search} {Settings.TimeSpanEndFlag} ",
Score = 50,
Action = _ =>
{
this._context.API.ChangeQuery($"{query.ActionKeyword} {query.Search} {Settings.TimeSpanEndFlag} ");
return false;
}
});
}

if (!timeEntry.IsRunning && !hasResumeFlag)
{
results.Add(new Result
{
Title = Settings.UsageTipTitle,
SubTitle = $"Use {Settings.ResumeFlag} to resume this time entry",
IcoPath = "tip.png",
AutoCompleteText = $"{query.ActionKeyword} {query.Search} {Settings.ResumeFlag} ",
Score = 30,
Action = _ =>
{
this._context.API.ChangeQuery($"{query.ActionKeyword} {query.Search} {Settings.ResumeFlag} ");
return false;
}
});
}
}
}
else
{
Expand Down

0 comments on commit 4ddf83c

Please sign in to comment.