Skip to content

Commit 1efe333

Browse files
Merge pull request #91 from nullinside-development-group/feat/ws
feat: switch off using the clipboard for login
2 parents 25706f1 + 84a6144 commit 1efe333

14 files changed

+99
-198
lines changed

src/TwitchStreamingTools/App.axaml.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public override void Initialize() {
2929
/// Launches the main application window.
3030
/// </summary>
3131
public override void OnFrameworkInitializationCompleted() {
32-
TwitchClientProxy.Instance.TwitchOAuthToken = Configuration.Instance.OAuth?.Bearer;
32+
TwitchClientProxy.Instance.TwitchOAuthToken = Configuration.Instance.OAuth?.AccessToken;
3333
TwitchClientProxy.Instance.TwitchUsername = Configuration.Instance.TwitchUsername;
3434

3535
// Register all the services needed for the application to run

src/TwitchStreamingTools/Configuration.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public static Configuration Instance {
5858
/// <summary>
5959
/// The twitch OAuth token.
6060
/// </summary>
61-
public OAuthResponse? OAuth { get; set; }
61+
public TwitchAccessToken? OAuth { get; set; }
6262

6363
/// <summary>
6464
/// The twitch application configuration for getting OAuth tokens.
@@ -96,7 +96,7 @@ public bool WriteConfiguration() {
9696
if (Design.IsDesignMode) {
9797
return false;
9898
}
99-
99+
100100
try {
101101
Directory.CreateDirectory(Path.GetDirectoryName(CONFIG_LOCATION)!);
102102

src/TwitchStreamingTools/Constants.cs

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
using System.Collections.Generic;
22
using System.Reflection;
33

4-
using Avalonia.Input.Platform;
5-
64
namespace TwitchStreamingTools;
75

86
/// <summary>
@@ -18,7 +16,12 @@ public static class Constants {
1816
/// <summary>
1917
/// The domain that the api service is hosted at.
2018
/// </summary>
21-
public const string API_SITE_DOMAIN = "http://localhost:5036";
19+
public const string API_SITE_DOMAIN = $"http://{DOMAIN}";
20+
21+
/// <summary>
22+
/// The domain that the api service is hosted at.
23+
/// </summary>
24+
public const string DOMAIN = "localhost:5036";
2225
#else
2326
/// <summary>
2427
/// The twitch app client id.
@@ -28,7 +31,12 @@ public static class Constants {
2831
/// <summary>
2932
/// The domain that the api service is hosted at.
3033
/// </summary>
31-
public const string API_SITE_DOMAIN = "https://nullinside.com";
34+
public const string API_SITE_DOMAIN = "https://{DOMAIN}";
35+
36+
/// <summary>
37+
/// The domain that the api service is hosted at.
38+
/// </summary>
39+
public const string DOMAIN = "nullinside.com";
3240
#endif
3341

3442
/// <summary>
@@ -46,12 +54,6 @@ public static class Constants {
4654
/// </summary>
4755
public static readonly string? APP_VERSION = Assembly.GetEntryAssembly()?.GetName().Version?.ToString()[..^2];
4856

49-
/// <summary>
50-
/// The reference to the clipboard API.
51-
/// </summary>
52-
/// <remarks>This is a hack because it's hard to get to.</remarks>
53-
public static IClipboard? Clipboard;
54-
5557
/// <summary>
5658
/// The default bot list to populate when a user doesn't any have bots configured.
5759
/// </summary>

src/TwitchStreamingTools/IConfiguration.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public interface IConfiguration {
1818
/// <summary>
1919
/// The twitch OAuth token.
2020
/// </summary>
21-
OAuthResponse? OAuth { get; set; }
21+
TwitchAccessToken? OAuth { get; set; }
2222

2323
/// <summary>
2424
/// The twitch application configuration for getting OAuth tokens.

src/TwitchStreamingTools/Models/OAuthResponse.cs

Lines changed: 0 additions & 28 deletions
This file was deleted.

src/TwitchStreamingTools/Services/TwitchAccountService.cs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
using Nullinside.Api.Common.Twitch;
77

8-
using TwitchStreamingTools.Models;
98
using TwitchStreamingTools.Utilities;
109

1110
namespace TwitchStreamingTools.Services;
@@ -75,9 +74,9 @@ public async Task UpdateCredentials(string bearer, string refresh, DateTime expi
7574
// Do nothing
7675
}
7776

78-
_configuration.OAuth = new OAuthResponse {
79-
Bearer = bearer,
80-
Refresh = refresh,
77+
_configuration.OAuth = new TwitchAccessToken {
78+
AccessToken = bearer,
79+
RefreshToken = refresh,
8180
ExpiresUtc = expires
8281
};
8382

@@ -159,9 +158,9 @@ private async Task DoTokenRefreshIfNearExpiration() {
159158
await twitchApi.RefreshAccessToken();
160159

161160
// Update the configuration
162-
_configuration.OAuth = new OAuthResponse {
163-
Bearer = twitchApi.OAuth.AccessToken,
164-
Refresh = twitchApi.OAuth.RefreshToken,
161+
_configuration.OAuth = new TwitchAccessToken {
162+
AccessToken = twitchApi.OAuth.AccessToken,
163+
RefreshToken = twitchApi.OAuth.RefreshToken,
165164
ExpiresUtc = twitchApi.OAuth.ExpiresUtc ?? DateTime.MinValue
166165
};
167166
_configuration.WriteConfiguration();

src/TwitchStreamingTools/Services/TwitchTtsService.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,8 @@ private void Main() {
9797
private void ConnectChatsInConfig() {
9898
if (Design.IsDesignMode) {
9999
return;
100-
}
101-
100+
}
101+
102102
List<string?>? missing = _configuration.TwitchChats?
103103
.Select(c => c.TwitchChannel)
104104
.Except(_chats?.Select(c => c.ChatConfig?.TwitchChannel) ?? [])

src/TwitchStreamingTools/TwitchStreamingTools.csproj

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -46,21 +46,21 @@
4646
</ItemGroup>
4747

4848
<ItemGroup>
49-
<PackageReference Include="Avalonia" Version="11.3.2" />
50-
<PackageReference Include="Avalonia.Desktop" Version="11.3.2" />
51-
<PackageReference Include="Avalonia.Themes.Fluent" Version="11.3.2" />
52-
<PackageReference Include="Avalonia.Fonts.Inter" Version="11.3.2" />
49+
<PackageReference Include="Avalonia" Version="11.3.2"/>
50+
<PackageReference Include="Avalonia.Desktop" Version="11.3.2"/>
51+
<PackageReference Include="Avalonia.Themes.Fluent" Version="11.3.2"/>
52+
<PackageReference Include="Avalonia.Fonts.Inter" Version="11.3.2"/>
5353
<!--Condition below is needed to remove Avalonia.Diagnostics package from build output in Release configuration.-->
54-
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="11.3.2" />
55-
<PackageReference Include="Avalonia.ReactiveUI" Version="11.3.2" />
54+
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="11.3.2"/>
55+
<PackageReference Include="Avalonia.ReactiveUI" Version="11.3.2"/>
5656
<PackageReference Include="DynamicData" Version="9.4.1"/>
5757
<PackageReference Include="log4net" Version="3.1.0"/>
58-
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="9.0.7" />
58+
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="9.0.7"/>
5959
<PackageReference Include="NAudio.Wasapi" Version="2.2.1"/>
6060
<PackageReference Include="NAudio.WinMM" Version="2.2.1"/>
61-
<PackageReference Include="System.Speech" Version="9.0.7" />
62-
<PackageReference Include="Xaml.Behaviors.Avalonia" Version="11.3.2" />
63-
<PackageReference Include="Xaml.Behaviors.Interactivity" Version="11.3.2" />
61+
<PackageReference Include="System.Speech" Version="9.0.7"/>
62+
<PackageReference Include="Xaml.Behaviors.Avalonia" Version="11.3.2"/>
63+
<PackageReference Include="Xaml.Behaviors.Interactivity" Version="11.3.2"/>
6464
</ItemGroup>
6565

6666
<ItemGroup>

src/TwitchStreamingTools/Utilities/ClipboardPoller.cs

Lines changed: 0 additions & 84 deletions
This file was deleted.

src/TwitchStreamingTools/Utilities/IClipboardPoller.cs

Lines changed: 0 additions & 11 deletions
This file was deleted.

0 commit comments

Comments
 (0)