This repository has been archived on 2026-07-19. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
OutlookAddin/src/OutlookAddin.UI/ViewModels/FolderRowViewModel.cs
T
PointStar a05b8114d4 feat(folders): Task #6 — per-folder auto-sync with confidence gate
Host:
- FolderResolver: walks Outlook Stores/Folders by stored StoreId +
  backslash-separated FolderPath; RCWs released at each hop
- FolderWatcher: rooted Items references in a Subscription list
  (preventing the GC from silently dropping the COM event sink),
  HashSet<EntryID> dedup, marshals category stamping back to the WPF
  dispatcher. Per-folder mode: AutoFile when MatchingService returns a
  confident unique match AND confidence ≥ ConfidenceThreshold; otherwise
  stamps "Needs filing"
- FolderTreeBuilder: one-shot STA traversal (max depth 4, max 500 entries)
  into Core-side FolderTreeNode list

UI:
- FolderTreeNode in Core for cross-project transport
- FolderRowViewModel: per-row IsWatched / Mode / ConfidenceThreshold
- SettingsViewModel.LoadFolderTree(tree) merges existing
  AppSettings.WatchedFolders into the loaded list
- Save now writes WatchedFolders alongside URL/creds
- SettingsDialog: new "תיקיות" tab with a DataGrid (checkbox + mode combo
  per folder)

AddInHost:
- Builds FolderResolver + FolderWatcher inside TryInitializeCrm, applies
  Settings.WatchedFolders on startup and after Save
- LaunchSettings: invokes FolderTreeBuilder, passes the flat list to the
  ViewModel, and re-applies the watch list after the dialog closes

Core/UI/Tests green (38 tests).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-11 15:51:03 +03:00

43 lines
1.3 KiB
C#

using CommunityToolkit.Mvvm.ComponentModel;
using MarcusLaw.OutlookAddin.Core.Configuration;
using MarcusLaw.OutlookAddin.Core.Models;
namespace MarcusLaw.OutlookAddin.UI.ViewModels
{
/// <summary>
/// One row in the Folders tab of the Settings dialog. Wraps a
/// <see cref="FolderTreeNode"/> with three observable fields the user
/// can toggle: IsWatched, Mode, ConfidenceThreshold.
/// </summary>
public sealed partial class FolderRowViewModel : ObservableObject
{
public FolderTreeNode Node { get; }
[ObservableProperty]
private bool isWatched;
[ObservableProperty]
private WatchMode mode = WatchMode.NotifyOnly;
[ObservableProperty]
private double confidenceThreshold = 0.8;
public string DisplayLabel => new string(' ', Node.Depth * 2) + Node.DisplayName;
public string FullPath => Node.StoreDisplayName + Node.FolderPath;
public FolderRowViewModel(FolderTreeNode node)
{
Node = node;
}
public WatchedFolder ToWatchedFolder() => new WatchedFolder
{
StoreId = Node.StoreId,
FolderPath = Node.FolderPath,
Mode = Mode,
ConfidenceThreshold = ConfidenceThreshold
};
}
}