Skip to content

Commit

Permalink
[SubscriptionTracker] Add proper error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
bitWolfy committed Feb 8, 2024
1 parent 76a097b commit 273ce5d
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 44 deletions.
2 changes: 0 additions & 2 deletions src/js/components/utility/Util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { UtilDOM } from "./UtilDOM";
import { UtilEvents } from "./UtilEvents";
import { UtilID } from "./UtilID";
import { UtilMath } from "./UtilMath";
import { UtilNetwork } from "./UtilNetwork";
import { UtilSize } from "./UtilSize";
import { UtilTime } from "./UtilTime";

Expand All @@ -15,7 +14,6 @@ export class Util {
public static Events = UtilEvents;
public static ID = UtilID;
public static Math = UtilMath;
public static Network = UtilNetwork;
public static Time = UtilTime;
public static Size = UtilSize;

Expand Down
25 changes: 0 additions & 25 deletions src/js/components/utility/UtilNetwork.ts

This file was deleted.

17 changes: 2 additions & 15 deletions src/js/modules/subscriptions/_SubscriptionManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ export class SubscriptionManager extends RE6Module {

cacheVersion: 0, // utility variable, cache is cleared if it does not match the hardcoded one

skipPreflightChecks: false, // suppresses the network status check before the update
loadLargeThumbs: false, // replaces the preview-sized thumbnails with (animated) sample sized ones

windowWidth: "37", // width of the notifications window, in REM
Expand Down Expand Up @@ -284,18 +283,6 @@ export class SubscriptionManager extends RE6Module {
}
),

Form.checkbox(
{
value: this.fetchSettings("skipPreflightChecks"),
label: "<b>Skip Preflight Checks</b><br />Disables the extra network checks before updating the subscriptions",
width: 2,
},
async (data) => {
await this.pushSettings("skipPreflightChecks", data);
}
),
Form.spacer(2, true),

Form.checkbox(
{
value: this.fetchSettings("loadLargeThumbs"),
Expand Down Expand Up @@ -437,8 +424,8 @@ export class SubscriptionManager extends RE6Module {
}

if (instance.isNetworkOffline()) {
$el.val("Network Offline")
.attr("title", "Unable to reach e621 servers.\nPlease, check your Internet connection.")
$el.val("Error")
.attr("title", "At least one update request failed to complete.")
.addClass("failed-attempt");
eventLock = false;
return;
Expand Down
6 changes: 4 additions & 2 deletions src/js/modules/subscriptions/_SubscriptionTracker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { XM } from "../../components/api/XM";
import { Page } from "../../components/data/Page";
import { ModuleController } from "../../components/ModuleController";
import { RE6Module, Settings } from "../../components/RE6Module";
import { ErrorHandler } from "../../components/utility/ErrorHandler";
import { Util } from "../../components/utility/Util";
import { SubscriptionCache, UpdateContent, UpdateData } from "./_SubscriptionCache";
import { SubscriptionList } from "./_SubscriptionList";
Expand Down Expand Up @@ -397,14 +398,15 @@ export class SubscriptionTracker extends RE6Module {
this.updateInProgress = true;
SubscriptionManager.trigger("inprogress." + this.trackerID, 0);

if (ModuleController.fetchSettings(SubscriptionManager, "skipPreflightChecks") || await Util.Network.isOnline()) {
try {
this.execPreUpdate();
await this.cache.fetch();
this.execPostUpdate();
this.networkOffline = false;
this.updateInProgress = false;
SubscriptionManager.trigger("inprogress." + this.trackerID, 2);
} else {
} catch(error) {
ErrorHandler.error(this, JSON.stringify(error), "update");
this.networkOffline = true;
this.updateInProgress = false;
SubscriptionManager.trigger("inprogress." + this.trackerID, 3);
Expand Down

0 comments on commit 273ce5d

Please sign in to comment.