refactor: QuestionChecker to QuestionManager
This commit is contained in:
parent
b6404f6c70
commit
d3d77cb779
|
@ -29,7 +29,7 @@ public class Plugin : IDalamudPlugin {
|
|||
internal IFramework Framework { get; init; }
|
||||
|
||||
internal Configuration Config { get; }
|
||||
internal QuestionChecker Checker { get; }
|
||||
internal QuestionManager Manager { get; }
|
||||
internal PluginUi Ui { get; }
|
||||
private Commands Commands { get; }
|
||||
|
||||
|
@ -38,7 +38,7 @@ public class Plugin : IDalamudPlugin {
|
|||
|
||||
public Plugin() {
|
||||
this.Config = this.Interface.GetPluginConfig() as Configuration ?? new Configuration();
|
||||
this.Checker = new QuestionChecker(this);
|
||||
this.Manager = new QuestionManager(this);
|
||||
this.Ui = new PluginUi(this);
|
||||
this.Commands = new Commands(this);
|
||||
|
||||
|
@ -56,7 +56,7 @@ public class Plugin : IDalamudPlugin {
|
|||
|
||||
this.Commands.Dispose();
|
||||
this.Ui.Dispose();
|
||||
this.Checker.Dispose();
|
||||
this.Manager.Dispose();
|
||||
}
|
||||
|
||||
internal void SaveConfig() {
|
||||
|
@ -71,10 +71,10 @@ public class Plugin : IDalamudPlugin {
|
|||
this._checkNow = false;
|
||||
this.Stopwatch.Restart();
|
||||
|
||||
Task.Run(async () => await this.Checker.Check());
|
||||
Task.Run(async () => await this.Manager.Check());
|
||||
}
|
||||
|
||||
private void Login() {
|
||||
this.Checker.OpenIfNew();
|
||||
this.Manager.OpenIfNew();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -122,7 +122,7 @@ internal class PluginUi : IDisposable {
|
|||
private void DrawMain() {
|
||||
ImGuiHelpers.CenteredText("Active question");
|
||||
|
||||
var active = this.Plugin.Checker.FirstOrDefault(q => q.Active);
|
||||
var active = this.Plugin.Manager.FirstOrDefault(q => q.Active);
|
||||
if (active == null) {
|
||||
ImGui.TextUnformatted("There is no active question at the moment.");
|
||||
} else {
|
||||
|
@ -149,7 +149,7 @@ internal class PluginUi : IDisposable {
|
|||
var answer = i;
|
||||
Task.Run(async () => {
|
||||
try {
|
||||
await this.Plugin.Checker.Vote(active.Id, (ushort) answer);
|
||||
await this.Plugin.Manager.Vote(active.Id, (ushort) answer);
|
||||
} finally {
|
||||
this._voting = false;
|
||||
}
|
||||
|
@ -165,7 +165,7 @@ internal class PluginUi : IDisposable {
|
|||
|
||||
ImGuiHelpers.CenteredText("Inactive questions");
|
||||
|
||||
foreach (var question in this.Plugin.Checker) {
|
||||
foreach (var question in this.Plugin.Manager) {
|
||||
if (question.Active || question is not FullQuestion full) {
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -4,19 +4,19 @@ using Newtonsoft.Json;
|
|||
|
||||
namespace EorzeaVotes;
|
||||
|
||||
internal class QuestionChecker : IDisposable, IEnumerable<IQuestion> {
|
||||
internal class QuestionManager : IDisposable, IEnumerable<IQuestion> {
|
||||
private Plugin Plugin { get; }
|
||||
private HttpClient Http { get; }
|
||||
|
||||
private List<IQuestion> _questions = new();
|
||||
private Guid _lastSeenActive = Guid.Empty;
|
||||
|
||||
internal QuestionChecker(Plugin plugin) {
|
||||
internal QuestionManager(Plugin plugin) {
|
||||
this.Plugin = plugin;
|
||||
this.Http = new HttpClient {
|
||||
DefaultRequestHeaders = {
|
||||
UserAgent = {
|
||||
new ProductInfoHeaderValue("EorzeaVotes", typeof(QuestionChecker).Assembly.GetName().Version?.ToString(3) ?? "???"),
|
||||
new ProductInfoHeaderValue("EorzeaVotes", typeof(QuestionManager).Assembly.GetName().Version?.ToString(3) ?? "???"),
|
||||
},
|
||||
},
|
||||
};
|
Loading…
Reference in New Issue
Block a user