mirror of
https://github.com/ppy/osu.git
synced 2025-03-21 23:07:45 +08:00
Move token saving logic to APIAccess
This commit is contained in:
parent
afc3646450
commit
83cd2fd317
@ -16,7 +16,7 @@ using osu.Game.Users;
|
||||
|
||||
namespace osu.Game.Online.API
|
||||
{
|
||||
public class APIAccess : IAPIProvider
|
||||
public class APIAccess : IAPIProvider, IDisposable
|
||||
{
|
||||
private readonly OsuConfigManager config;
|
||||
private readonly OAuth authentication;
|
||||
@ -27,7 +27,7 @@ namespace osu.Game.Online.API
|
||||
|
||||
private ConcurrentQueue<APIRequest> queue = new ConcurrentQueue<APIRequest>();
|
||||
|
||||
public Scheduler Scheduler = new Scheduler();
|
||||
public readonly Scheduler Scheduler = new Scheduler();
|
||||
|
||||
/// <summary>
|
||||
/// The username/email provided by the user when initiating a login.
|
||||
@ -310,6 +310,23 @@ namespace osu.Game.Online.API
|
||||
{
|
||||
Scheduler.Update();
|
||||
}
|
||||
|
||||
private void dispose()
|
||||
{
|
||||
config.Set(OsuSetting.Token, config.Get<bool>(OsuSetting.SavePassword) ? Token : string.Empty);
|
||||
config.Save();
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
dispose();
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
~APIAccess()
|
||||
{
|
||||
dispose();
|
||||
}
|
||||
}
|
||||
|
||||
public enum APIState
|
||||
|
@ -245,14 +245,8 @@ namespace osu.Game
|
||||
|
||||
protected override void Dispose(bool isDisposing)
|
||||
{
|
||||
//refresh token may have changed.
|
||||
if (LocalConfig != null && API != null)
|
||||
{
|
||||
LocalConfig.Set(OsuSetting.Token, LocalConfig.Get<bool>(OsuSetting.SavePassword) ? API.Token : string.Empty);
|
||||
LocalConfig.Save();
|
||||
}
|
||||
|
||||
base.Dispose(isDisposing);
|
||||
API.Dispose();
|
||||
}
|
||||
|
||||
private readonly List<ICanAcceptFiles> fileImporters = new List<ICanAcceptFiles>();
|
||||
|
Loading…
x
Reference in New Issue
Block a user