-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Cleanup settings in themes - Light theme improvements - Move `DiscordClient` out of `App` class - Fast connect™️ - Improved logging - Improved reconnections - Fixed an issue with DMs with no members - Periodic background notifications test
- Loading branch information
Showing
81 changed files
with
2,825 additions
and
668 deletions.
There are no files selected for viewing
Submodule DSharpPlus
updated
3 files
+3 −0 | DSharpPlus.Rest/DiscordRestClient.cs | |
+7 −4 | DSharpPlus/Clients/DiscordClient.cs | |
+1 −3 | DSharpPlus/Net/Rest/DiscordApiClient.cs |
65 changes: 65 additions & 0 deletions
65
Unicord.Universal.Background.Tasks/PeriodicNotificationsTask.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using DSharpPlus; | ||
using Unicord.Universal.Shared; | ||
using Windows.ApplicationModel.Background; | ||
using Windows.Security.Credentials; | ||
using Windows.UI.Notifications; | ||
|
||
namespace Unicord.Universal.Background.Tasks | ||
{ | ||
public sealed class PeriodicNotificationsTask : IBackgroundTask | ||
{ | ||
public async void Run(IBackgroundTaskInstance taskInstance) | ||
{ | ||
var deferral = taskInstance.GetDeferral(); | ||
try | ||
{ | ||
if (!TryGetToken(out string token)) | ||
return; | ||
|
||
var tileUpdateManager = TileUpdateManager.CreateTileUpdaterForApplication(); | ||
var toastNotifier = ToastNotificationManager.CreateToastNotifier(); | ||
|
||
var restClient = new DiscordRestClient(new DiscordConfiguration() { Token = token, TokenType = TokenType.User }); | ||
var mentions = await restClient.GetUserMentionsAsync(25, true, true); | ||
|
||
foreach (var mention in mentions) | ||
{ | ||
if (!NotificationUtils.WillShowToast(restClient, mention)) | ||
continue; | ||
|
||
var tileNotification = NotificationUtils.CreateTileNotificationForMessage(restClient, mention); | ||
var toastNotification = NotificationUtils.CreateToastNotificationForMessage(restClient, mention); | ||
|
||
tileUpdateManager.Update(tileNotification); | ||
toastNotifier.Show(toastNotification); | ||
} | ||
} | ||
finally | ||
{ | ||
deferral.Complete(); | ||
} | ||
} | ||
|
||
internal static bool TryGetToken(out string token) | ||
{ | ||
try | ||
{ | ||
var passwordVault = new PasswordVault(); | ||
var credential = passwordVault.Retrieve(Constants.TOKEN_IDENTIFIER, "Default"); | ||
credential.RetrievePassword(); | ||
|
||
token = credential.Password; | ||
return true; | ||
} | ||
catch { } | ||
|
||
token = null; | ||
return false; | ||
} | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
Unicord.Universal.Background.Tasks/Properties/AssemblyInfo.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
using System.Reflection; | ||
using System.Runtime.CompilerServices; | ||
using System.Runtime.InteropServices; | ||
|
||
// General Information about an assembly is controlled through the following | ||
// set of attributes. Change these attribute values to modify the information | ||
// associated with an assembly. | ||
[assembly: AssemblyTitle("Unicord.Universal.Background.Tasks")] | ||
[assembly: AssemblyDescription("")] | ||
[assembly: AssemblyConfiguration("")] | ||
[assembly: AssemblyCompany("")] | ||
[assembly: AssemblyProduct("Unicord.Universal.Background.Tasks")] | ||
[assembly: AssemblyCopyright("Copyright © 2024")] | ||
[assembly: AssemblyTrademark("")] | ||
[assembly: AssemblyCulture("")] | ||
|
||
// Version information for an assembly consists of the following four values: | ||
// | ||
// Major Version | ||
// Minor Version | ||
// Build Number | ||
// Revision | ||
// | ||
[assembly: AssemblyVersion("1.0.0.0")] | ||
[assembly: AssemblyFileVersion("1.0.0.0")] | ||
[assembly: ComVisible(false)] |
167 changes: 167 additions & 0 deletions
167
Unicord.Universal.Background.Tasks/Unicord.Universal.Background.Tasks.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,167 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> | ||
<PropertyGroup> | ||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
<ProjectGuid>{69F44648-37CD-4B20-8814-2BAF85B4F624}</ProjectGuid> | ||
<OutputType>winmdobj</OutputType> | ||
<AppDesignerFolder>Properties</AppDesignerFolder> | ||
<RootNamespace>Unicord.Universal.Background.Tasks</RootNamespace> | ||
<AssemblyName>Unicord.Universal.Background.Tasks</AssemblyName> | ||
<DefaultLanguage>en-US</DefaultLanguage> | ||
<TargetPlatformIdentifier>UAP</TargetPlatformIdentifier> | ||
<TargetPlatformVersion Condition=" '$(TargetPlatformVersion)' == '' ">10.0.22000.0</TargetPlatformVersion> | ||
<TargetPlatformMinVersion>10.0.16299.0</TargetPlatformMinVersion> | ||
<MinimumVisualStudioVersion>14</MinimumVisualStudioVersion> | ||
<FileAlignment>512</FileAlignment> | ||
<ProjectTypeGuids>{A5A43C5B-DE2A-4C0C-9213-0A381AF9435A};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> | ||
<AllowCrossPlatformRetargeting>false</AllowCrossPlatformRetargeting> | ||
<LangVersion>9</LangVersion> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | ||
<PlatformTarget>AnyCPU</PlatformTarget> | ||
<DebugSymbols>true</DebugSymbols> | ||
<DebugType>full</DebugType> | ||
<Optimize>false</Optimize> | ||
<OutputPath>bin\Debug\</OutputPath> | ||
<DefineConstants>DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | ||
<PlatformTarget>AnyCPU</PlatformTarget> | ||
<DebugType>pdbonly</DebugType> | ||
<Optimize>true</Optimize> | ||
<OutputPath>bin\Release\</OutputPath> | ||
<DefineConstants>TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'"> | ||
<PlatformTarget>x86</PlatformTarget> | ||
<DebugSymbols>true</DebugSymbols> | ||
<OutputPath>bin\x86\Debug\</OutputPath> | ||
<DefineConstants>DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants> | ||
<NoWarn>;2008</NoWarn> | ||
<DebugType>full</DebugType> | ||
<UseVSHostingProcess>false</UseVSHostingProcess> | ||
<ErrorReport>prompt</ErrorReport> | ||
</PropertyGroup> | ||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'"> | ||
<PlatformTarget>x86</PlatformTarget> | ||
<OutputPath>bin\x86\Release\</OutputPath> | ||
<DefineConstants>TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants> | ||
<Optimize>true</Optimize> | ||
<NoWarn>;2008</NoWarn> | ||
<DebugType>pdbonly</DebugType> | ||
<UseVSHostingProcess>false</UseVSHostingProcess> | ||
<ErrorReport>prompt</ErrorReport> | ||
</PropertyGroup> | ||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|ARM'"> | ||
<PlatformTarget>ARM</PlatformTarget> | ||
<DebugSymbols>true</DebugSymbols> | ||
<OutputPath>bin\ARM\Debug\</OutputPath> | ||
<DefineConstants>DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants> | ||
<NoWarn>;2008</NoWarn> | ||
<DebugType>full</DebugType> | ||
<UseVSHostingProcess>false</UseVSHostingProcess> | ||
<ErrorReport>prompt</ErrorReport> | ||
</PropertyGroup> | ||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|ARM'"> | ||
<PlatformTarget>ARM</PlatformTarget> | ||
<OutputPath>bin\ARM\Release\</OutputPath> | ||
<DefineConstants>TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants> | ||
<Optimize>true</Optimize> | ||
<NoWarn>;2008</NoWarn> | ||
<DebugType>pdbonly</DebugType> | ||
<UseVSHostingProcess>false</UseVSHostingProcess> | ||
<ErrorReport>prompt</ErrorReport> | ||
</PropertyGroup> | ||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|ARM64'"> | ||
<PlatformTarget>ARM64</PlatformTarget> | ||
<DebugSymbols>true</DebugSymbols> | ||
<OutputPath>bin\ARM64\Debug\</OutputPath> | ||
<DefineConstants>DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants> | ||
<NoWarn>;2008</NoWarn> | ||
<DebugType>full</DebugType> | ||
<UseVSHostingProcess>false</UseVSHostingProcess> | ||
<ErrorReport>prompt</ErrorReport> | ||
</PropertyGroup> | ||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|ARM64'"> | ||
<PlatformTarget>ARM64</PlatformTarget> | ||
<OutputPath>bin\ARM64\Release\</OutputPath> | ||
<DefineConstants>TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants> | ||
<Optimize>true</Optimize> | ||
<NoWarn>;2008</NoWarn> | ||
<DebugType>pdbonly</DebugType> | ||
<UseVSHostingProcess>false</UseVSHostingProcess> | ||
<ErrorReport>prompt</ErrorReport> | ||
</PropertyGroup> | ||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'"> | ||
<PlatformTarget>x64</PlatformTarget> | ||
<DebugSymbols>true</DebugSymbols> | ||
<OutputPath>bin\x64\Debug\</OutputPath> | ||
<DefineConstants>DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants> | ||
<NoWarn>;2008</NoWarn> | ||
<DebugType>full</DebugType> | ||
<UseVSHostingProcess>false</UseVSHostingProcess> | ||
<ErrorReport>prompt</ErrorReport> | ||
</PropertyGroup> | ||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'"> | ||
<PlatformTarget>x64</PlatformTarget> | ||
<OutputPath>bin\x64\Release\</OutputPath> | ||
<DefineConstants>TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants> | ||
<Optimize>true</Optimize> | ||
<NoWarn>;2008</NoWarn> | ||
<DebugType>pdbonly</DebugType> | ||
<UseVSHostingProcess>false</UseVSHostingProcess> | ||
<ErrorReport>prompt</ErrorReport> | ||
</PropertyGroup> | ||
<PropertyGroup> | ||
<RestoreProjectStyle>PackageReference</RestoreProjectStyle> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Compile Include="PeriodicNotificationsTask.cs" /> | ||
<Compile Include="Properties\AssemblyInfo.cs" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<PackageReference Include="Microsoft.NETCore.UniversalWindowsPlatform"> | ||
<Version>6.2.14</Version> | ||
</PackageReference> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ProjectReference Include="..\Libraries\DSharpPlus\DSharpPlus.Rest\DSharpPlus.Rest.csproj"> | ||
<Project>{c01b8589-13fe-4a6d-b159-6644977f58de}</Project> | ||
<Name>DSharpPlus.Rest</Name> | ||
</ProjectReference> | ||
<ProjectReference Include="..\Libraries\DSharpPlus\DSharpPlus\DSharpPlus.csproj"> | ||
<Project>{0f4b3af7-9320-41ae-82d0-3737949499c7}</Project> | ||
<Name>DSharpPlus</Name> | ||
</ProjectReference> | ||
<ProjectReference Include="..\Libraries\MomentSharp\MomentSharp\MomentSharp.csproj"> | ||
<Project>{8a4a933c-c579-4c36-9133-7d6721f99aec}</Project> | ||
<Name>MomentSharp</Name> | ||
</ProjectReference> | ||
<ProjectReference Include="..\Libraries\WamWooWam.Core\WamWooWam.Core\WamWooWam.Core.csproj"> | ||
<Project>{6e8e3c2c-a7d2-4971-a97d-fa831e3ecf15}</Project> | ||
<Name>WamWooWam.Core</Name> | ||
</ProjectReference> | ||
<ProjectReference Include="..\Libraries\WindowsCommunityToolkit\Microsoft.Toolkit.Uwp.Notifications\Microsoft.Toolkit.Uwp.Notifications.csproj"> | ||
<Project>{921c4ba1-7a60-43a5-950f-0d72d5ed64e3}</Project> | ||
<Name>Microsoft.Toolkit.Uwp.Notifications</Name> | ||
</ProjectReference> | ||
</ItemGroup> | ||
<Import Project="..\Unicord.Universal.Shared\Unicord.Universal.Shared.projitems" Label="Shared" /> | ||
<PropertyGroup Condition=" '$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' < '14.0' "> | ||
<VisualStudioVersion>14.0</VisualStudioVersion> | ||
</PropertyGroup> | ||
<Import Project="$(MSBuildExtensionsPath)\Microsoft\WindowsXaml\v$(VisualStudioVersion)\Microsoft.Windows.UI.Xaml.CSharp.targets" /> | ||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. | ||
Other similar extension points exist, see Microsoft.Common.targets. | ||
<Target Name="BeforeBuild"> | ||
</Target> | ||
<Target Name="AfterBuild"> | ||
</Target> | ||
--> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.