Skip to content
This repository has been archived by the owner on Feb 13, 2024. It is now read-only.

Commit

Permalink
Merge pull request #4716 from toggl-open-source/fix/timeline_ui/durat…
Browse files Browse the repository at this point in the history
…ion_running_te

Fix non-accurate duration for running TE
  • Loading branch information
skel35 authored Dec 1, 2020
2 parents 3f61d69 + 247995f commit 619086c
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public TimelineViewModel()
.Subscribe(h => CurrentTimeOffset = h);
this.WhenAnyValue(x => x.CurrentTimeOffset).Where(_ => RunningTimeEntryBlock != null)
.Select(off => Math.Max(TimelineConstants.MinTimeEntryBlockHeight,
CurrentTimeOffset - RunningTimeEntryBlock.VerticalOffset - 1))
CurrentTimeOffset - RunningTimeEntryBlock.VerticalOffset))
.Subscribe(h => RunningTimeEntryBlock.Height = h);
this.WhenAnyValue(x => x.TimeEntryBlocks, x => x.RunningTimeEntryBlock, x => x.IsTodaySelected,
(blocks, running, isToday) => blocks?.Any() == true || (running != null && isToday))
Expand Down Expand Up @@ -202,7 +202,7 @@ private static Dictionary<string, TimeEntryBlock> ConvertTimeEntriesToBlocks(Lis

var startTime = entry.StartTime();
var ended = entry.GUID == runningEntry?.GUID
? TimelineUtils.ConvertOffsetToUnixTime(currentTimeOffset - 1, selectedDate, TimelineConstants.ScaleModes[selectedScaleMode])
? TimelineUtils.ConvertOffsetToUnixTime(currentTimeOffset, selectedDate, TimelineConstants.ScaleModes[selectedScaleMode])
: entry.Ended;
var height = ConvertTimeIntervalToHeight(startTime, Toggl.DateTimeFromUnix(ended), selectedScaleMode);
var block = new TimeEntryBlock(entry.GUID, TimelineConstants.ScaleModes[selectedScaleMode], selectedDate)
Expand Down
40 changes: 21 additions & 19 deletions src/ui/windows/TogglDesktop/TogglDesktop/ui/views/Timeline.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,26 @@
</ItemsControl.ItemTemplate>
</ItemsControl>
<GridSplitter Grid.Column="1" Grid.Row="1" VerticalAlignment="Stretch" HorizontalAlignment="Left" Width="1" Background="{DynamicResource Toggl.TimelineSeparatorBrush}"/>
<Canvas Grid.Row="1" Grid.Column="2"
Background="Transparent"
MouseDown="OnTimeEntryCanvasMouseDown"
MouseMove="OnTimeEntryCanvasMouseMove"
MouseUp="OnTimeEntryCanvasMouseUp"/>
<Canvas Name="RunningTimeEntryCanvas" Grid.Row="1" Grid.Column="2" Margin="10 0 0 0" Visibility="{Binding RunningTimeEntryBlock, Converter={StaticResource NullToCollapsedConverter}}">
<togglDesktop:TimelineRunningTimeEntryBlock DataContext="{Binding RunningTimeEntryBlock}"
Canvas.Top="{Binding VerticalOffset}"
Canvas.Left="{Binding HorizontalOffset}">
<togglDesktop:TimelineRunningTimeEntryBlock.Style>
<Style TargetType="FrameworkElement">
<Style.Triggers>
<DataTrigger Binding="{Binding ShowDescription}" Value="True">
<Setter Property="Width" Value="{Binding ElementName=RunningTimeEntryCanvas, Path=ActualWidth}"/>
</DataTrigger>
</Style.Triggers>
</Style>
</togglDesktop:TimelineRunningTimeEntryBlock.Style>
</togglDesktop:TimelineRunningTimeEntryBlock>
</Canvas>
<Canvas Grid.Row="1" Grid.ColumnSpan="5" Grid.Column="0"
Visibility="{Binding IsTodaySelected, Converter={StaticResource BooleanToVisibilityConverter}}"
x:Name="CurrentTimeCanvas">
Expand All @@ -169,10 +189,7 @@
<ItemsControl Grid.Row="1" Grid.Column="2" ItemsSource="{Binding Path=TimeEntryBlocks}" Margin="10 0 0 0" Name="TimeEntryBlocks">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<Canvas Name="TimeEntryCanvas" Background="Transparent"
MouseDown="OnTimeEntryCanvasMouseDown"
MouseMove="OnTimeEntryCanvasMouseMove"
MouseUp="OnTimeEntryCanvasMouseUp"/>
<Canvas Name="TimeEntryCanvas"/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
Expand All @@ -199,21 +216,6 @@
</Style>
</ItemsControl.ItemContainerStyle>
</ItemsControl>
<Canvas Name="RunningTimeEntryCanvas" Grid.Row="1" Grid.Column="2" Margin="10 0 0 0" Visibility="{Binding RunningTimeEntryBlock, Converter={StaticResource NullToCollapsedConverter}}">
<togglDesktop:TimelineRunningTimeEntryBlock DataContext="{Binding RunningTimeEntryBlock}"
Canvas.Top="{Binding VerticalOffset}"
Canvas.Left="{Binding HorizontalOffset}">
<togglDesktop:TimelineRunningTimeEntryBlock.Style>
<Style TargetType="FrameworkElement">
<Style.Triggers>
<DataTrigger Binding="{Binding ShowDescription}" Value="True">
<Setter Property="Width" Value="{Binding ElementName=RunningTimeEntryCanvas, Path=ActualWidth}"/>
</DataTrigger>
</Style.Triggers>
</Style>
</togglDesktop:TimelineRunningTimeEntryBlock.Style>
</togglDesktop:TimelineRunningTimeEntryBlock>
</Canvas>
<ItemsControl Grid.Row="1" Grid.Column="2" ItemsSource="{Binding Path=GapTimeEntryBlocks}" Margin="10 0 0 0">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
Expand Down

0 comments on commit 619086c

Please sign in to comment.