Extra misc fixes

This commit is contained in:
JustArchi
2018-07-24 20:43:00 +02:00
parent eb656f26f3
commit ae05e0ffab
2 changed files with 9 additions and 21 deletions

View File

@@ -84,19 +84,16 @@ namespace ArchiSteamFarm {
private static HttpListener HttpListener;
private static bool IsHandlingRequests;
internal static void OnNewHistoryTarget(HistoryTarget historyTarget) {
if (historyTarget == null) {
ASF.ArchiLogger.LogNullError(nameof(historyTarget));
return;
}
internal static void OnNewHistoryTarget(HistoryTarget historyTarget = null) {
if (HistoryTarget != null) {
HistoryTarget.NewHistoryEntry -= OnNewHistoryEntry;
HistoryTarget = null;
}
historyTarget.NewHistoryEntry += OnNewHistoryEntry;
HistoryTarget = historyTarget;
if (historyTarget != null) {
historyTarget.NewHistoryEntry += OnNewHistoryEntry;
HistoryTarget = historyTarget;
}
}
internal static void Start(HashSet<string> prefixes) {

View File

@@ -84,15 +84,9 @@ namespace ArchiSteamFarm {
return;
}
HistoryTarget historyTarget;
HistoryTarget historyTarget = LogManager.Configuration.AllTargets.OfType<HistoryTarget>().FirstOrDefault();
if (IsUsingCustomConfiguration) {
historyTarget = LogManager.Configuration.AllTargets.OfType<HistoryTarget>().FirstOrDefault();
if (historyTarget == null) {
return;
}
} else {
if ((historyTarget == null) && !IsUsingCustomConfiguration) {
// TODO: We could use some nice HTML layout for this
historyTarget = new HistoryTarget("History") {
Layout = GeneralLayout,
@@ -167,11 +161,8 @@ namespace ArchiSteamFarm {
OnUserInputStart();
}
HistoryTarget historyTarget = (HistoryTarget) LogManager.Configuration.AllTargets.FirstOrDefault(target => target is HistoryTarget);
if (historyTarget != null) {
IPC.OnNewHistoryTarget(historyTarget);
}
HistoryTarget historyTarget = LogManager.Configuration.AllTargets.OfType<HistoryTarget>().FirstOrDefault();
IPC.OnNewHistoryTarget(historyTarget);
}
}
}