Couple fixes for beta.
This commit is contained in:
@@ -127,6 +127,16 @@
|
||||
Text="{x:Bind ViewModel.SenderName, Mode=TwoWay}" />
|
||||
</controls:SettingsCard>
|
||||
|
||||
<controls:SettingsCard Header="{x:Bind domain:Translator.IMAPSetupDialog_MailAddress}">
|
||||
<controls:SettingsCard.HeaderIcon>
|
||||
<SymbolIcon Symbol="Mail" />
|
||||
</controls:SettingsCard.HeaderIcon>
|
||||
<TextBox
|
||||
Width="250"
|
||||
IsReadOnly="True"
|
||||
Text="{x:Bind ViewModel.Address, Mode=OneWay}" />
|
||||
</controls:SettingsCard>
|
||||
|
||||
<controls:SettingsCard
|
||||
HorizontalContentAlignment="Stretch"
|
||||
VerticalContentAlignment="Stretch"
|
||||
|
||||
@@ -22,12 +22,10 @@ using Wino.Core.Domain.Entities.Mail;
|
||||
using Wino.Core.Domain.Entities.Shared;
|
||||
using Wino.Core.Domain.Models.Reader;
|
||||
using Wino.Mail.ViewModels.Data;
|
||||
using Wino.Mail.ViewModels.Messages;
|
||||
using Wino.Mail.WinUI.Controls;
|
||||
using Wino.Mail.WinUI.Extensions;
|
||||
using Wino.Mail.WinUI.Interfaces;
|
||||
using Wino.Mail.WinUI.Models;
|
||||
using Wino.Messaging.Client.Mails;
|
||||
using Wino.Messaging.Client.Shell;
|
||||
using Wino.Views.Abstract;
|
||||
|
||||
@@ -42,6 +40,7 @@ public sealed partial class ComposePage : ComposePageAbstract,
|
||||
|
||||
private bool _isPoppedOut;
|
||||
private bool _isInitialFocusHandled;
|
||||
private readonly Dictionary<TokenizingTextBox, List<AccountContact>> _recipientSuggestions = [];
|
||||
|
||||
public bool SupportsPopOut => !_isPoppedOut;
|
||||
public event EventHandler<PopOutRequestedEventArgs>? PopOutRequested;
|
||||
@@ -132,12 +131,17 @@ public sealed partial class ComposePage : ComposePageAbstract,
|
||||
{
|
||||
_ = ViewModel.ExecuteUIThread(() =>
|
||||
{
|
||||
var addresses = x.Result;
|
||||
var addresses = x.Result ?? [];
|
||||
|
||||
_recipientSuggestions[box] = addresses;
|
||||
senderBox.ItemsSource = addresses;
|
||||
});
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
_recipientSuggestions[box] = [];
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -293,7 +297,7 @@ public sealed partial class ComposePage : ComposePageAbstract,
|
||||
{
|
||||
base.OnNavigatedTo(e);
|
||||
|
||||
FocusManager.GotFocus += GlobalFocusManagerGotFocus;
|
||||
// FocusManager.GotFocus += GlobalFocusManagerGotFocus;
|
||||
|
||||
var webView = GetWebView();
|
||||
|
||||
@@ -335,36 +339,60 @@ public sealed partial class ComposePage : ComposePageAbstract,
|
||||
|
||||
private async void TokenItemAdding(TokenizingTextBox sender, TokenItemAddingEventArgs args)
|
||||
{
|
||||
// Check is valid email.
|
||||
if (!EmailValidator.Validate(args.TokenText))
|
||||
{
|
||||
args.Cancel = true;
|
||||
ViewModel.NotifyInvalidEmail(args.TokenText);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
var deferral = args.GetDeferral();
|
||||
|
||||
var addedItem = (sender.Tag?.ToString()) switch
|
||||
try
|
||||
{
|
||||
"ToBox" => await ViewModel.GetAddressInformationAsync(args.TokenText, ViewModel.ToItems),
|
||||
"CCBox" => await ViewModel.GetAddressInformationAsync(args.TokenText, ViewModel.CCItems),
|
||||
"BCCBox" => await ViewModel.GetAddressInformationAsync(args.TokenText, ViewModel.BCCItems),
|
||||
_ => null
|
||||
};
|
||||
var suggestedContact = GetFirstSuggestedContact(sender);
|
||||
var tokenText = suggestedContact?.Address ?? args.TokenText;
|
||||
var addressCollection = sender.Tag?.ToString() switch
|
||||
{
|
||||
"ToBox" => ViewModel.ToItems,
|
||||
"CCBox" => ViewModel.CCItems,
|
||||
"BCCBox" => ViewModel.BCCItems,
|
||||
_ => null
|
||||
};
|
||||
|
||||
if (addedItem == null)
|
||||
{
|
||||
args.Cancel = true;
|
||||
ViewModel.NotifyAddressExists();
|
||||
if (suggestedContact == null && !EmailValidator.Validate(tokenText))
|
||||
{
|
||||
args.Cancel = true;
|
||||
ViewModel.NotifyInvalidEmail(args.TokenText);
|
||||
return;
|
||||
}
|
||||
|
||||
AccountContact? addedItem = null;
|
||||
|
||||
if (suggestedContact != null)
|
||||
{
|
||||
addedItem = addressCollection?.Any(a => string.Equals(a.Address, suggestedContact.Address, StringComparison.OrdinalIgnoreCase)) == true
|
||||
? null
|
||||
: suggestedContact;
|
||||
}
|
||||
else
|
||||
{
|
||||
addedItem = sender.Tag?.ToString() switch
|
||||
{
|
||||
"ToBox" => await ViewModel.GetAddressInformationAsync(tokenText, ViewModel.ToItems),
|
||||
"CCBox" => await ViewModel.GetAddressInformationAsync(tokenText, ViewModel.CCItems),
|
||||
"BCCBox" => await ViewModel.GetAddressInformationAsync(tokenText, ViewModel.BCCItems),
|
||||
_ => null
|
||||
};
|
||||
}
|
||||
|
||||
if (addedItem == null)
|
||||
{
|
||||
args.Cancel = true;
|
||||
ViewModel.NotifyAddressExists();
|
||||
}
|
||||
else
|
||||
{
|
||||
args.Item = addedItem;
|
||||
}
|
||||
}
|
||||
else
|
||||
finally
|
||||
{
|
||||
args.Item = addedItem;
|
||||
_recipientSuggestions[sender] = [];
|
||||
deferral.Complete();
|
||||
}
|
||||
|
||||
deferral.Complete();
|
||||
}
|
||||
|
||||
void IRecipient<ApplicationThemeChanged>.Receive(ApplicationThemeChanged message)
|
||||
@@ -438,6 +466,11 @@ public sealed partial class ComposePage : ComposePageAbstract,
|
||||
}
|
||||
}
|
||||
|
||||
private AccountContact? GetFirstSuggestedContact(TokenizingTextBox box)
|
||||
=> _recipientSuggestions.TryGetValue(box, out var suggestions)
|
||||
? suggestions.FirstOrDefault()
|
||||
: null;
|
||||
|
||||
private void ComposerLoaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (ShouldFocusRecipients())
|
||||
|
||||
@@ -5,6 +5,7 @@ using CommunityToolkit.Mvvm.Messaging;
|
||||
using Microsoft.UI.Xaml.Media.Animation;
|
||||
using Microsoft.UI.Xaml.Navigation;
|
||||
using Wino.Core.Domain;
|
||||
using Wino.Core.Domain.Entities.Shared;
|
||||
using Wino.Core.Domain.Enums;
|
||||
using Wino.Core.Domain.Models.Settings;
|
||||
using Wino.Helpers;
|
||||
@@ -162,7 +163,7 @@ public sealed partial class SettingsPage : SettingsPageAbstract,
|
||||
|
||||
DispatcherQueue.TryEnqueue(() =>
|
||||
{
|
||||
activePage.Title = message.Account.Name;
|
||||
activePage.Title = GetAccountDetailsTitle(message.Account);
|
||||
_ = RefreshCurrentPageStateAsync();
|
||||
UpdateWindowTitle();
|
||||
});
|
||||
@@ -249,6 +250,11 @@ public sealed partial class SettingsPage : SettingsPageAbstract,
|
||||
: activeTitle;
|
||||
}
|
||||
|
||||
private static string GetAccountDetailsTitle(MailAccount account)
|
||||
=> !string.IsNullOrWhiteSpace(account?.Address)
|
||||
? string.Format(Translator.SettingsAccountDetails_NavigationTitle, account.Address)
|
||||
: account?.Name ?? Translator.AccountDetailsPage_Title;
|
||||
|
||||
public Task OnTitleBarSearchTextChangedAsync()
|
||||
{
|
||||
SearchSuggestions.Clear();
|
||||
|
||||
Reference in New Issue
Block a user