Skip to content

Commit

Permalink
Performance updates (#132)
Browse files Browse the repository at this point in the history
* Try use DataTemplates where possible

* Testing

* Fix message editing with DataTemplates

* Restore functionality of search/pins pages

* Move forum thread stuff to its own files

* Cleanup MessageControl

* Restyling, fix #131, fix #130
  • Loading branch information
WamWooWam authored Oct 12, 2024
1 parent eb525c5 commit 74c7bc4
Show file tree
Hide file tree
Showing 85 changed files with 2,478 additions and 2,167 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ public async void Run(IBackgroundTaskInstance taskInstance)
var toastNotifier = ToastNotificationManager.CreateToastNotifier();

var restClient = new DiscordRestClient(new DiscordConfiguration() { Token = token, TokenType = TokenType.User });
await restClient.InitializeAsync();

var mentions = await restClient.GetUserMentionsAsync(25, true, true);

foreach (var mention in mentions)
Expand Down
2 changes: 1 addition & 1 deletion Unicord.Universal.Package/Package.appxmanifest
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
xmlns:desktop="http://schemas.microsoft.com/appx/manifest/desktop/windows10"
xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest"
IgnorableNamespaces="uap mp uap2 uap3 uap4 uap5 rescap">
<Identity Name="24101WamWooWamRD.Unicord" Publisher="CN=0F22111D-EDF0-42F0-B58D-26C4C5C5054B" Version="2.0.34.0" />
<Identity Name="24101WamWooWamRD.Unicord" Publisher="CN=0F22111D-EDF0-42F0-B58D-26C4C5C5054B" Version="2.0.43.0" />
<mp:PhoneIdentity PhoneProductId="5783aabf-3049-421f-ae1d-e88bd89018f2" PhonePublisherId="00000000-0000-0000-0000-000000000000" />
<Properties>
<DisplayName>ms-resource:AppDisplayName</DisplayName>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@
<EntryPointProjectUniqueName>..\Unicord.Universal\Unicord.Universal.csproj</EntryPointProjectUniqueName>
<AppxOSMinVersionReplaceManifestVersion>false</AppxOSMinVersionReplaceManifestVersion>
<AppxOSMaxVersionTestedReplaceManifestVersion>false</AppxOSMaxVersionTestedReplaceManifestVersion>
<PackageCertificateThumbprint>2C5F1F6080F0648BF786147323B846D8D0BA1638</PackageCertificateThumbprint>
<GenerateAppInstallerFile>False</GenerateAppInstallerFile>
<AppxPackageSigningTimestampDigestAlgorithm>SHA256</AppxPackageSigningTimestampDigestAlgorithm>
<AppxAutoIncrementPackageRevision>False</AppxAutoIncrementPackageRevision>
Expand All @@ -69,6 +68,7 @@
<AppInstallerUri>https://wamwoowam.co.uk/unicord/download</AppInstallerUri>
<!-- lol, lmao -->
<SkipMicrosoftUIXamlCheckTargetPlatformVersion>true</SkipMicrosoftUIXamlCheckTargetPlatformVersion>
<PackageCertificateThumbprint>2C5F1F6080F0648BF786147323B846D8D0BA1638</PackageCertificateThumbprint>
</PropertyGroup>
<ItemGroup>
<AppxManifest Include="Package.appxmanifest">
Expand Down
2 changes: 1 addition & 1 deletion Unicord.Universal.Shared/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ internal static partial class Constants

public const string GIF_AUTOPLAY = "AutoPlayGifs";
public const string SAVE_CAPTURED_PHOTOS = "SavedPhotos";
public const string TIMESTAMP_STYLE = "TimestampStyle1";
public const string TIMESTAMP_STYLE = "TimestampStyle_1";

public const string BACKGROUND_NOTIFICATIONS = "BackgroundNotifications";

Expand Down
4 changes: 3 additions & 1 deletion Unicord.Universal.Shared/MutedExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ public static bool IsMuted(this DiscordGuild guild)

public static bool IsUnread(this DiscordChannel channel)
{
var discord = (DiscordClient)channel.Discord;
if (!(channel.Discord is DiscordClient discord))
return false;

var readState = channel.ReadState;

// this shit should never happen but apparently it does sometimes, don't question it
Expand Down
4 changes: 2 additions & 2 deletions Unicord.Universal.Shared/NotificationUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public static bool WillShowToast(BaseDiscordClient client, DiscordMessage messag
if (client is DiscordClient discord && discord.UserSettings?.Status == "dnd")
return false;

if (message.Channel.IsMuted() || (message.Channel.Guild != null && message.Channel.Guild.IsMuted()) || !message.Channel.IsUnread())
if (message.Channel.IsMuted() || (message.Channel.Guild != null && message.Channel.Guild.IsMuted()))
return false;

bool willNotify = false;
Expand Down Expand Up @@ -136,7 +136,7 @@ public static string GetChannelHeaderName(DiscordChannel channel)
{
if (dmChannel.Type == ChannelType.Private)
{
if (dmChannel.Recipients.Count == 0)
if (dmChannel.Recipients == null || dmChannel.Recipients.Count == 0)
return "Invalid DM channel";

return $"@{dmChannel.Recipients[0].DisplayName}";
Expand Down
72 changes: 36 additions & 36 deletions Unicord.Universal/Controls/Channels/ChannelPageHeaderControl.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,50 +61,50 @@
</Grid>

<users:AvatarControl x:Name="UserImage"
x:Load="{x:Bind ViewModel.IsDM}"
Source="{Binding ChannelIconUrl}"
Grid.Column="1"
Width="24"
Height="24"
Margin="12,0,0,0"
VerticalAlignment="Center"/>
x:Load="{x:Bind ViewModel.IsDM}"
Source="{Binding ChannelIconUrl}"
Grid.Column="1"
Width="24"
Height="24"
Margin="12,0,0,0"
VerticalAlignment="Center"/>

<TextBlock x:Name="Icon"
x:Load="{x:Bind ViewModel.IsNotDM}"
Grid.Column="1"
Foreground="{ThemeResource SystemControlForegroundBaseMediumBrush}"
Text="{x:Bind ViewModel.Channel, Converter={StaticResource ChannelSymbolConverter}}"
FontFamily="{StaticResource FluentSystemIcons}"
VerticalAlignment="Center"
Margin="16,0,8,0"
FontSize="20"/>
x:Load="{x:Bind ViewModel.IsNotDM}"
Grid.Column="1"
Foreground="{ThemeResource SystemControlForegroundBaseMediumBrush}"
Text="{x:Bind ViewModel.Channel, Converter={StaticResource ChannelSymbolConverter}}"
FontFamily="{StaticResource FluentSystemIcons}"
VerticalAlignment="Center"
Margin="16,0,8,0"
FontSize="20"/>

<TextBlock x:Name="Header"
Grid.Column="2"
Margin="8,0,8,0"
VerticalAlignment="Center"
FontSize="15"
FontWeight="Bold"
Foreground="{ThemeResource SystemControlForegroundBaseHighBrush}"
TextTrimming="Clip"
TextWrapping="NoWrap"
Text="{x:Bind ViewModel.DisplayName}"/>
Grid.Column="2"
Margin="8,0,8,0"
VerticalAlignment="Center"
FontSize="15"
FontWeight="Bold"
Foreground="{ThemeResource SystemControlForegroundBaseHighBrush}"
TextTrimming="Clip"
TextWrapping="NoWrap"
Text="{x:Bind ViewModel.DisplayName}"/>

<presence:StatusIndicator x:Name="RecipientStatusIndicator"
x:Load="{x:Bind ViewModel.IsDM}"
Grid.Column="3"
Width="10"
Height="10"
Margin="-4,0,8,0"
Presence="{x:Bind ViewModel.Recipient.Presence}"/>
x:Load="{x:Bind ViewModel.IsDM}"
Grid.Column="3"
Width="10"
Height="10"
Margin="-4,0,8,0"
Presence="{x:Bind ViewModel.Recipient.Presence}"/>

<controls:MarkdownTextBlock x:Name="TopicText"
Grid.Column="4"
HorizontalAlignment="Stretch"
VerticalAlignment="Center"
Channel="{x:Bind ViewModel.Channel}"
Text="{x:Bind ViewModel.Topic}"
TextWrapping="NoWrap" />
Grid.Column="4"
HorizontalAlignment="Stretch"
VerticalAlignment="Center"
Channel="{x:Bind ViewModel.Channel}"
Text="{x:Bind ViewModel.Topic}"
TextWrapping="NoWrap" />
</StackPanel>
</Grid>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ public ChannelPageHeaderControl()
private void OnLoaded(object sender, RoutedEventArgs e)
{
var windowHandle = WindowingService.Current.GetHandle(this);
if (AnalyticsInfo.VersionInfo.DeviceFamily == "Windows.Phone")
WindowingService.Current.HandleTitleBarForControl(TopGrid);
//if (SystemPlatform.Mobile)
// WindowingService.Current.HandleTitleBarForControl(TopGrid);

if (!WindowingService.Current.IsMainWindow(windowHandle))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
</AppBarButton>

<AppBarButton Label="Edit"
Click="EditFlyoutItem_Click"
Command="{Binding EditCommand}"
IsEnabled="{Binding Author.IsCurrent}">
<AppBarButton.Icon>
<FontIcon FontFamily="{StaticResource SymbolThemeFontFamily}" Glyph="&#xe70f;" />
Expand Down
16 changes: 0 additions & 16 deletions Unicord.Universal/Controls/Flyouts/MessageContextFlyout.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,28 +20,12 @@ namespace Unicord.Universal.Controls.Flyouts
{
public sealed partial class MessageContextFlyout : MUXC.CommandBarFlyout
{
public MessageControl Parent
{
get => (MessageControl)GetValue(ParentProperty);
set => SetValue(ParentProperty, value);
}

public static readonly DependencyProperty ParentProperty =
DependencyProperty.Register("Parent", typeof(MessageControl), typeof(MessageContextFlyout), new PropertyMetadata(null));

public MessageContextFlyout()
{
this.InitializeComponent();
}

// todo: is there a less shit way of doing this?
private void EditFlyoutItem_Click(object sender, RoutedEventArgs e)
{
this.Hide();
this.Target.FindParent<MessageControl>().BeginEdit();
}

// ditto
private void AddReactionButton_Click(object sender, RoutedEventArgs e)
{
this.Hide();
Expand Down
14 changes: 2 additions & 12 deletions Unicord.Universal/Controls/Messages/AttachmentMediaControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,19 +86,9 @@ private void OnAttachmentChanged(DependencyPropertyChangedEventArgs e)
//}
}

private async void OnFullWindowRequested(object sender, EventArgs e)
private void OnFullWindowRequested(object sender, EventArgs e)
{
var service = FullscreenService.GetForCurrentView();
if (_mediaPlayerElement.IsFullWindow)
{
_mediaPlayerElement.IsFullWindow = false;
await service.LeaveFullscreenAsync(_mediaPlayerElement, _mediaPlayerBorder);
}
else
{
await service.EnterFullscreenAsync(_mediaPlayerElement, _mediaPlayerBorder);
_mediaPlayerElement.IsFullWindow = true;
}
_mediaPlayerElement.IsFullWindow = !_mediaPlayerElement.IsFullWindow;
}
}
}
Loading

0 comments on commit 74c7bc4

Please sign in to comment.