mirror of
https://github.com/J3vb/OwnCord.git
synced 2026-09-03 03:50:00 +03:00
- Replace 5x ToList().FindIndex() with direct for-loops in MainViewModel - UpdateUnreadCount now updates ChannelGroup in-place instead of full rebuild - Remove redundant RebuildChannelGroups() call in OnReady - Freeze all SolidColorBrush instances in converters for thread safety - EmojiPicker search shows empty state instead of fallback to all categories - MainViewModel implements IDisposable for _typingTimer cleanup - ApiMessage.Username changed to string? to match server reality
65 lines
1.8 KiB
C#
65 lines
1.8 KiB
C#
using System.Windows;
|
|
using System.Windows.Controls;
|
|
using System.Windows.Input;
|
|
using OwnCord.Client.Services;
|
|
|
|
namespace OwnCord.Client.Controls;
|
|
|
|
public partial class EmojiPickerControl : UserControl
|
|
{
|
|
public static readonly DependencyProperty EmojiSelectedCommandProperty =
|
|
DependencyProperty.Register(
|
|
nameof(EmojiSelectedCommand),
|
|
typeof(ICommand),
|
|
typeof(EmojiPickerControl),
|
|
new PropertyMetadata(null));
|
|
|
|
public static readonly DependencyProperty SearchTextProperty =
|
|
DependencyProperty.Register(
|
|
nameof(SearchText),
|
|
typeof(string),
|
|
typeof(EmojiPickerControl),
|
|
new PropertyMetadata(string.Empty, OnSearchTextChanged));
|
|
|
|
public EmojiPickerControl()
|
|
{
|
|
InitializeComponent();
|
|
RefreshCategories();
|
|
}
|
|
|
|
public ICommand EmojiSelectedCommand
|
|
{
|
|
get => (ICommand)GetValue(EmojiSelectedCommandProperty);
|
|
set => SetValue(EmojiSelectedCommandProperty, value);
|
|
}
|
|
|
|
public string SearchText
|
|
{
|
|
get => (string)GetValue(SearchTextProperty);
|
|
set => SetValue(SearchTextProperty, value);
|
|
}
|
|
|
|
private static void OnSearchTextChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
|
{
|
|
if (d is EmojiPickerControl picker)
|
|
picker.RefreshCategories();
|
|
}
|
|
|
|
private void RefreshCategories()
|
|
{
|
|
var query = SearchText?.Trim() ?? string.Empty;
|
|
|
|
if (string.IsNullOrEmpty(query))
|
|
{
|
|
CategoryList.ItemsSource = EmojiData.Categories;
|
|
return;
|
|
}
|
|
|
|
var filtered = EmojiData.Categories
|
|
.Where(c => c.Name.Contains(query, StringComparison.OrdinalIgnoreCase))
|
|
.ToList();
|
|
|
|
CategoryList.ItemsSource = filtered;
|
|
}
|
|
}
|