Overhaul Secrets implementation

This commit is contained in:
Jeddunk 2023-12-24 13:32:23 +01:00
parent dfd9f1a97b
commit 5e2833e068
3 changed files with 11 additions and 21 deletions

View File

@ -0,0 +1,8 @@
namespace auto_creamapi.Utils
{
public interface ISecrets
{
public string ForumUsername();
public string ForumPassword();
}
}

View File

@ -1,14 +0,0 @@
namespace auto_creamapi.Utils
{
/// <summary>
/// To use this:
/// Rename file Secrets.EXAMPLE.cs to Secrets.cs
/// Rename class Secrets_REMOVETHIS to Secrets
/// Enter the relevant info below
/// </summary>
public static class Secrets_REMOVETHIS
{
public const string ForumUsername = "Enter username here";
public const string ForumPassword = "Enter password here";
}
}

View File

@ -1,19 +1,16 @@
using System;
using System.Net.Http;
using System.Threading.Tasks;
using System.Windows;
using auto_creamapi.Messenger;
using auto_creamapi.Services;
using auto_creamapi.Utils;
using Microsoft.Extensions.Logging;
using MvvmCross.Logging;
using MvvmCross.Navigation;
using MvvmCross.Plugin.Messenger;
using MvvmCross.ViewModels;
namespace auto_creamapi.ViewModels
{
public class DownloadViewModel : MvxNavigationViewModel
{
private readonly IDownloadCreamApiService _download;
@ -25,6 +22,8 @@ namespace auto_creamapi.ViewModels
private string _info;
private double _progress;
private readonly Secrets _secrets = new();
public DownloadViewModel(ILoggerFactory loggerFactory, IMvxNavigationService navigationService,
IDownloadCreamApiService download, IMvxMessenger messenger) : base(loggerFactory, navigationService)
{
@ -80,10 +79,8 @@ namespace auto_creamapi.ViewModels
try
{
await base.Initialize().ConfigureAwait(false);
var download = _download.Download(Secrets.ForumUsername, Secrets.ForumPassword);
var download = _download.Download(_secrets.ForumUsername(), _secrets.ForumPassword());
var filename = await download.ConfigureAwait(false);
/*var extract = _download.Extract(filename);
await extract;*/
var extract = _download.Extract(filename);
await extract.ConfigureAwait(false);
_token.Dispose();
@ -102,7 +99,6 @@ namespace auto_creamapi.ViewModels
private void OnProgressMessage(ProgressMessage obj)
{
//MyLogger.Log.Debug($"{obj.Filename}: {obj.BytesTransferred}");
InfoLabel = obj.Info;
FilenameLabel = obj.Filename;
Progress = obj.PercentComplete;