From 7484b0b08e3c21a5101b72aaabfdbcabbc7fe973 Mon Sep 17 00:00:00 2001 From: atsvirchkova Date: Thu, 24 Dec 2020 11:37:33 +0100 Subject: [PATCH] Use keepEndTimeFixed option everywhere in Timeline UI (win) --- src/ui/windows/TogglDesktop/TogglDesktop/Toggl.cs | 8 ++++++++ .../TogglDesktop/ui/ViewModels/TimelineBlockViewModel.cs | 4 ++-- .../TogglDesktop/ui/ViewModels/TimelineViewModel.cs | 4 ++-- .../TogglDesktop/TogglDesktop/utilities/TimelineUtils.cs | 2 +- 4 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/ui/windows/TogglDesktop/TogglDesktop/Toggl.cs b/src/ui/windows/TogglDesktop/TogglDesktop/Toggl.cs index d1aeea69c8..add2f8e8c6 100644 --- a/src/ui/windows/TogglDesktop/TogglDesktop/Toggl.cs +++ b/src/ui/windows/TogglDesktop/TogglDesktop/Toggl.cs @@ -460,6 +460,14 @@ public static bool SetTimeEntryStartTimeStamp(string guid, long timeStamp) } } + public static bool SetTimeEntryStartTimeStampWithOption(string guid, long timeStamp, bool keepEndTimeFixed) + { + using (Performance.Measure("changing time entry start time stamp")) + { + return toggl_set_time_entry_start_timestamp_with_option(ctx, guid, timeStamp, keepEndTimeFixed); + } + } + public static bool SetTimeEntryEndTimeStamp(string guid, long timeStamp) { using (Performance.Measure("changing time entry end time stamp")) diff --git a/src/ui/windows/TogglDesktop/TogglDesktop/ui/ViewModels/TimelineBlockViewModel.cs b/src/ui/windows/TogglDesktop/TogglDesktop/ui/ViewModels/TimelineBlockViewModel.cs index df81dea180..71488daf78 100644 --- a/src/ui/windows/TogglDesktop/TogglDesktop/ui/ViewModels/TimelineBlockViewModel.cs +++ b/src/ui/windows/TogglDesktop/TogglDesktop/ui/ViewModels/TimelineBlockViewModel.cs @@ -96,8 +96,8 @@ public TimeEntryBlock(Toggl.TogglTimeEntryView te, int hourHeight, DateTime date public void ChangeStartTime() { - Toggl.SetTimeEntryStartTimeStamp(TimeEntryId, - (long)TimelineUtils.ConvertOffsetToUnixTime(VerticalOffset, DateCreated, _hourHeight)); + Toggl.SetTimeEntryStartTimeStampWithOption(TimeEntryId, + (long)TimelineUtils.ConvertOffsetToUnixTime(VerticalOffset, DateCreated, _hourHeight), true); } public void ChangeEndTime() diff --git a/src/ui/windows/TogglDesktop/TogglDesktop/ui/ViewModels/TimelineViewModel.cs b/src/ui/windows/TogglDesktop/TogglDesktop/ui/ViewModels/TimelineViewModel.cs index 77dadc34a7..edfdf2825e 100644 --- a/src/ui/windows/TogglDesktop/TogglDesktop/ui/ViewModels/TimelineViewModel.cs +++ b/src/ui/windows/TogglDesktop/TogglDesktop/ui/ViewModels/TimelineViewModel.cs @@ -342,7 +342,7 @@ private static GapTimeEntryBlock GenerateRunningGapBlock(IEnumerable { var id = Toggl.Start("", "", 0, 0, "", ""); - Toggl.SetTimeEntryStartTimeStamp(id, (long)lastTimeEntry.Ended+1); + Toggl.SetTimeEntryStartTimeStampWithOption(id, (long)lastTimeEntry.Ended+1, true); return id; }) { @@ -374,7 +374,7 @@ public static void ChangeLastEntryStart(TimeEntryBlock item, List blocks) diff --git a/src/ui/windows/TogglDesktop/TogglDesktop/utilities/TimelineUtils.cs b/src/ui/windows/TogglDesktop/TogglDesktop/utilities/TimelineUtils.cs index be6f74c471..b0ba769258 100644 --- a/src/ui/windows/TogglDesktop/TogglDesktop/utilities/TimelineUtils.cs +++ b/src/ui/windows/TogglDesktop/TogglDesktop/utilities/TimelineUtils.cs @@ -24,7 +24,7 @@ public static DateTime ConvertOffsetToDateTime(double height, DateTime date, dou public static void CreateAndEditRunningTimeEntryFrom(ulong started) { var teId = Toggl.Start("", "", 0, 0, "", ""); - Toggl.SetTimeEntryStartTimeStamp(teId, (long)started); + Toggl.SetTimeEntryStartTimeStampWithOption(teId, (long)started, true); Toggl.Edit(teId, true, Toggl.Description); }