Skip to content

Commit 6b1b4cb

Browse files
committed
comments and ModelMergeTest
1 parent c6d45ea commit 6b1b4cb

File tree

4 files changed

+409
-14
lines changed

4 files changed

+409
-14
lines changed

App/Utils/ModelMerge.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public static class ModelMerge
2929
/// to avoid excessive/unncessary UI updates.
3030
/// It's assumed that the target list is already sorted.
3131
/// </summary>
32-
public static void MergeLists<T>(IList<T> target, IList<T> update, Comparison<T> sorter)
32+
public static void MergeLists<T>(IList<T> target, IEnumerable<T> update, Comparison<T> sorter)
3333
where T : IModelMergeable<T>
3434
{
3535
var newItems = update.ToList();
@@ -54,7 +54,7 @@ public static void MergeLists<T>(IList<T> target, IList<T> update, Comparison<T>
5454

5555
// A merge couldn't occur, so we need to remove the old item and
5656
// decrement `i` for the next iteration.
57-
target.Remove(target[i]);
57+
target.RemoveAt(i);
5858
i--;
5959

6060
OuterLoopEnd: ;

App/ViewModels/AgentAppViewModel.cs

+2-11
Original file line numberDiff line numberDiff line change
@@ -40,16 +40,11 @@ public AgentAppViewModel Create(Uuid id, string name, Uri appUri, Uri? iconUrl)
4040

4141
public partial class AgentAppViewModel : ObservableObject, IModelMergeable<AgentAppViewModel>
4242
{
43-
// HACK: We need to set the icon size for SVGs otherwise they might get cut
44-
// off. These must be kept in sync with the XAML code.
45-
public const int IconWidth = 20;
46-
public const int IconHeight = 20;
47-
4843
private readonly ILogger<AgentAppViewModel> _logger;
4944

5045
public required Uuid Id { get; init; }
5146

52-
public required string Name { get; set; }
47+
[ObservableProperty] public required partial string Name { get; set; }
5348

5449
[ObservableProperty]
5550
[NotifyPropertyChangedFor(nameof(Details))]
@@ -82,11 +77,7 @@ public ImageSource ImageSource
8277
{
8378
// TODO: Some SVGs like `/icon/cursor.svg` contain PNG data and
8479
// don't render at all.
85-
var svg = new SvgImageSource(IconUrl)
86-
{
87-
RasterizePixelWidth = IconWidth,
88-
RasterizePixelHeight = IconHeight,
89-
};
80+
var svg = new SvgImageSource(IconUrl);
9081
svg.Opened += (_, _) => _logger.LogDebug("app icon opened (svg): {uri}", IconUrl);
9182
svg.OpenFailed += (_, args) =>
9283
_logger.LogDebug("app icon failed to open (svg): {uri}: {Status}", IconUrl, args.Status);

App/Views/Pages/TrayWindowMainPage.xaml

-1
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,6 @@
259259
ToolTipService.ToolTip="{x:Bind Details}">
260260

261261
<Grid HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
262-
<!-- Icon width and height need to be synced to the constants in the view model -->
263262
<Image
264263
Source="{x:Bind ImageSource}"
265264
ImageOpened="{x:Bind OnImageOpened}"

0 commit comments

Comments
 (0)