Skip to content

Commit

Permalink
Fix patreon connection
Browse files Browse the repository at this point in the history
  • Loading branch information
C1rdec committed Dec 5, 2024
1 parent 11df0f2 commit 20864f6
Show file tree
Hide file tree
Showing 10 changed files with 85 additions and 55 deletions.
4 changes: 2 additions & 2 deletions src/PoeLurker.Core/Models/Collaboration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
namespace PoeLurker.Core.Models;

using System;
using System.Diagnostics;
using PoeLurker.Core.Extensions;

/// <summary>
/// Represents a collaboration.
Expand Down Expand Up @@ -51,7 +51,7 @@ public bool IsExpired()
/// </summary>
public void Open()
{
Process.Start(Url.ToString());
ProcessExtensions.OpenUrl(Url.ToString());
}

#endregion
Expand Down
45 changes: 25 additions & 20 deletions src/PoeLurker.Core/Models/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,33 @@ public Settings()
SoldMessage = DefaultSoldMessage;
BusyMessage = DefaultBusyMessage;
ThankYouMessage = DefaultThankYouMessage;

ShowWelcome = true;
IncomingTradeEnabled = true;
OutgoingTradeEnabled = true;
ToolTipEnabled = true;
ClipboardEnabled = true;
AutoKickEnabled = true;
HideInBackground = true;
HideoutEnabled = true;
BuildAutoClose = true;
ShowReleaseNote = true;
ShowStartupAnimation = true;
SoldDetection = true;
OutgoingDelayToClose = 100;
JoinHideoutVolume = 1;
AlertVolume = 1;
ItemAlertVolume = 0.5f;
TradebarScaling = 1;
LifeForeground = "#FFFFFFFF";
ToolTipDelay = 1000;
}

#region Properties

/// <summary>
/// Gets or sets a value indicating whether the welcome screen should be shown.
/// </summary>
[DefaultValue(true)]
public bool ShowWelcome { get; set; }

/// <summary>
Expand Down Expand Up @@ -68,13 +87,11 @@ public Settings()
/// <summary>
/// Gets or sets a value indicating whether [incoming trade enabled].
/// </summary>
[DefaultValue(true)]
public bool IncomingTradeEnabled { get; set; }

/// <summary>
/// Gets or sets a value indicating whether [outgoing trade enabled].
/// </summary>
[DefaultValue(true)]
public bool OutgoingTradeEnabled { get; set; }

/// <summary>
Expand Down Expand Up @@ -110,37 +127,31 @@ public Settings()
/// <summary>
/// Gets or sets the alert volume.
/// </summary>
[DefaultValue(1)]
public float AlertVolume { get; set; }

/// <summary>
/// Gets or sets the alert volume.
/// </summary>
[DefaultValue(0.5f)]
public float ItemAlertVolume { get; set; }

/// <summary>
/// Gets or sets the join hideout volume.
/// </summary>
[DefaultValue(1)]
public float JoinHideoutVolume { get; set; }

/// <summary>
/// Gets or sets a value indicating whether [tool tip enabled].
/// </summary>
[DefaultValue(true)]
public bool ToolTipEnabled { get; set; }

/// <summary>
/// Gets or sets a value indicating whether [clipboard enabled].
/// </summary>
[DefaultValue(true)]
public bool ClipboardEnabled { get; set; }

/// <summary>
/// Gets or sets a value indicating whether [automatic kick].
/// </summary>
[DefaultValue(true)]
public bool AutoKickEnabled { get; set; }

/// <summary>
Expand All @@ -161,13 +172,11 @@ public Settings()
/// <summary>
/// Gets or sets the tooltip delay.
/// </summary>
[DefaultValue(1000)]
public int ToolTipDelay { get; set; }

/// <summary>
/// Gets or sets a value indicating whether [hide in background].
/// </summary>
[DefaultValue(true)]
public bool HideInBackground { get; set; }

/// <summary>
Expand All @@ -178,19 +187,16 @@ public Settings()
/// <summary>
/// Gets or sets the life foreground.
/// </summary>
[DefaultValue("#FFFFFFFF")]
public string LifeForeground { get; set; }

/// <summary>
/// Gets or sets the trade bar scaling.
/// </summary>
[DefaultValue(1)]
public double TradebarScaling { get; set; }

/// <summary>
/// Gets or sets a value indicating whether [show startup animation].
/// </summary>
[DefaultValue(true)]
public bool ShowStartupAnimation { get; set; }

/// <summary>
Expand All @@ -206,13 +212,11 @@ public Settings()
/// <summary>
/// Gets or sets a value indicating whether [sold detection].
/// </summary>
[DefaultValue(true)]
public bool SoldDetection { get; set; }

/// <summary>
/// Gets or sets a value indicating whether [show release note].
/// </summary>
[DefaultValue(true)]
public bool ShowReleaseNote { get; set; }

/// <summary>
Expand All @@ -223,7 +227,6 @@ public Settings()
/// <summary>
/// Gets or sets a value indicating whether [build automatic close].
/// </summary>
[DefaultValue(true)]
public bool BuildAutoClose { get; set; }

/// <summary>
Expand All @@ -234,13 +237,11 @@ public Settings()
/// <summary>
/// Gets or sets a value indicating whether [synchronize build].
/// </summary>
[DefaultValue(true)]
public bool SyncBuild { get; set; }

/// <summary>
/// Gets or sets a value indicating whether [hideout enabled].
/// </summary>
[DefaultValue(true)]
public bool HideoutEnabled { get; set; }

/// <summary>
Expand All @@ -261,8 +262,12 @@ public Settings()
/// <summary>
/// Gets or sets a value indicating the delay to close outgoing trades.
/// </summary>
[DefaultValue(100)]
public double OutgoingDelayToClose { get; set; }

/// <summary>
/// Gets or sets a value indicating if the user tried to connect with patreon.
/// </summary>
public bool ConnectedToPatreon { get; set; }

#endregion
}
2 changes: 1 addition & 1 deletion src/PoeLurker.Core/PoeLurker.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<PackageReference Include="HtmlAgilityPack" Version="1.11.71" />
<PackageReference Include="NAudio" Version="2.2.1" />
<PackageReference Include="NLog" Version="5.3.4" />
<PackageReference Include="PoeLurker.Patreon" Version="8.0.11" />
<PackageReference Include="PoeLurker.Patreon" Version="8.0.13" />
<PackageReference Include="ProcessLurker" Version="8.0.0" />
<PackageReference Include="SharpClipboard" Version="3.5.2" />
<PackageReference Include="TextCopy" Version="6.2.1" />
Expand Down
13 changes: 13 additions & 0 deletions src/PoeLurker.Core/Services/SettingsService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -487,6 +487,19 @@ public bool ShowStartupAnimation
}
}

public bool ConnectedToPatreon
{
get
{
return _settings.Entity.ConnectedToPatreon;
}

set
{
_settings.Entity.ConnectedToPatreon = value;
}
}

/// <summary>
/// Gets or sets a value indicating whether [vulkan renderer].
/// </summary>
Expand Down
2 changes: 1 addition & 1 deletion src/PoeLurker.UI/PoeLurker.UI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@
<PackageReference Include="NLog" Version="5.3.4" />
<PackageReference Include="NLog.Extensions.Logging" Version="5.3.15" />
<PackageReference Include="PixiEditor.ColorPicker" Version="3.4.1" />
<PackageReference Include="PoeLurker.Patreon" Version="8.0.11" />
<PackageReference Include="PoeLurker.Patreon" Version="8.0.13" />
<PackageReference Include="System.Private.Uri" Version="4.3.2" />
<PackageReference Include="Velopack" Version="0.0.942" />
</ItemGroup>
Expand Down
4 changes: 2 additions & 2 deletions src/PoeLurker.UI/ViewModels/BuildViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ namespace PoeLurker.UI.ViewModels;

using System;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.Linq;
using System.Net.Http;
using System.Threading.Tasks;
using Caliburn.Micro;
using PoeLurker.Core;
using PoeLurker.Core.Extensions;
using PoeLurker.Core.Helpers;
using PoeLurker.Core.Models;
using PoeLurker.Core.Services;
Expand Down Expand Up @@ -491,7 +491,7 @@ public void OpenSelectedTree()
{
if (SelectedSkillTreeInformation != null && !string.IsNullOrEmpty(SelectedSkillTreeInformation.Url))
{
Process.Start(SelectedSkillTreeInformation.Url);
ProcessExtensions.OpenUrl(SelectedSkillTreeInformation.Url);
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/PoeLurker.UI/ViewModels/PushoverViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

namespace PoeLurker.UI.ViewModels;

using System.Diagnostics;
using PoeLurker.Core.Extensions;
using PoeLurker.Patreon.Services;

/// <summary>
Expand Down Expand Up @@ -121,15 +121,15 @@ public async void Test()
/// </summary>
public void NewAccount()
{
Process.Start("https://pushover.net/signup");
ProcessExtensions.OpenUrl("https://pushover.net/signup");
}

/// <summary>
/// Open the info.md.
/// </summary>
public void Info()
{
Process.Start("https://github.com/C1rdec/Poe-Lurker/blob/main/assets/Pushover.md");
ProcessExtensions.OpenUrl("https://github.com/C1rdec/Poe-Lurker/blob/main/assets/Pushover.md");
}

#endregion
Expand Down
51 changes: 31 additions & 20 deletions src/PoeLurker.UI/ViewModels/SettingsViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -437,14 +437,14 @@ public bool NotConnected
{
get
{
return !new TokenService().Connected;
return !_settingService.ConnectedToPatreon;
}
}

/// <summary>
/// Gets the patreon identifier.
/// </summary>
public string PatreonId => new TokenService().PatreonId;
public string PatreonId => _currentPatreonService.PatreonId;

/// <summary>
/// Gets or sets a value indicating whether this <see cref="SettingsViewModel"/> is pledging.
Expand Down Expand Up @@ -1049,7 +1049,7 @@ public void OpenLogs()

if (Directory.Exists(folderName))
{
Process.Start(folderName);
ProcessExtensions.OpenUrl(folderName);
}
}

Expand Down Expand Up @@ -1308,6 +1308,9 @@ public async Task LoginToPatreon()
SearchEnabled = true;
MapEnabled = true;
DashboardEnabled = true;
_settingService.ConnectedToPatreon = true;
SaveSettings();
NotifyOfPropertyChange(() => NotConnected);
}
}

Expand Down Expand Up @@ -1383,28 +1386,36 @@ protected override async Task OnActivateAsync(CancellationToken token)
{
HasCustomTradeSound = _soundService.HasCustomTradeAlert();
HasCustomItemSound = _soundService.HasCustomItemAlert();
AlertVolume = (int)(_settingService.AlertVolume * 100);
ItemAlertVolume = (int)(_settingService.ItemAlertVolume * 100);
JoinHideoutVolume = (int)(_settingService.JoinHideoutVolume * 100);
CheckForUpdate();

_ = _currentPatreonService.CheckPledgeStatus().ContinueWith(t =>
if (_settingService.ConnectedToPatreon)
{
Pledging = _currentPatreonService.Pledging;
if (Pledging)
{
BlessingText = "A blessing I can’t deny";
}
else
_ = _currentPatreonService.CheckPledgeStatus().ContinueWith(t =>
{
SearchEnabled = false;
DashboardEnabled = false;
MapEnabled = false;
}
Pledging = _currentPatreonService.Pledging;
if (Pledging)
{
BlessingText = "A blessing I can’t deny";
}
else
{
SearchEnabled = false;
DashboardEnabled = false;
MapEnabled = false;
_settingService.ConnectedToPatreon = false;
_settingService.Save();
}

_activated = true;
});
}
else
{
_activated = true;
});

AlertVolume = (int)(_settingService.AlertVolume * 100);
ItemAlertVolume = (int)(_settingService.ItemAlertVolume * 100);
JoinHideoutVolume = (int)(_settingService.JoinHideoutVolume * 100);
CheckForUpdate();
}

await base.OnActivateAsync(token);
}
Expand Down
3 changes: 2 additions & 1 deletion src/PoeLurker.UI/ViewModels/ShellViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ namespace PoeLurker.UI.ViewModels;
using System.Windows;
using Caliburn.Micro;
using PoeLurker.Core;
using PoeLurker.Core.Extensions;
using PoeLurker.Core.Helpers;
using PoeLurker.Core.Models;
using PoeLurker.Core.Services;
Expand Down Expand Up @@ -127,7 +128,7 @@ public ShellViewModel(

if (settingsService.ShowReleaseNote)
{
Process.Start("https://github.com/C1rdec/Poe-Lurker/releases/latest");
ProcessExtensions.OpenUrl("https://github.com/C1rdec/Poe-Lurker/releases/latest");
}
}

Expand Down
Loading

0 comments on commit 20864f6

Please sign in to comment.