Skip to content

Commit 076027f

Browse files
committed
fix: don't attempt to load quests if not logged in
1 parent de4c74f commit 076027f

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/utils/quests.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import Quest, { getId } from '../structures/quests/Quest.js';
77
*/
88
const quests = new Map();
99
let fetching = false;
10+
let offline = true; // TODO: have underscript cache the user state
1011

1112
export function getQuests() {
1213
return [...quests.values()];
@@ -35,7 +36,7 @@ function update(data, { callback, event = true }) {
3536
}
3637

3738
export function fetch(callback, event = true) {
38-
if (fetching) return;
39+
if (fetching || offline || !window.$) return;
3940
fetching = true;
4041
axios.get('/Quests').then((response) => {
4142
fetching = false;
@@ -51,4 +52,8 @@ eventManager.on(':load:Quests', () => {
5152
update(document, { event: false });
5253
});
5354

55+
eventManager.on('login', () => {
56+
offline = false;
57+
});
58+
5459
eventManager.on('getVictory getDefeat', fetch);

0 commit comments

Comments
 (0)