mirror of
https://github.com/streetwriters/notesnook.git
synced 2025-12-23 23:19:40 +01:00
fix: handle "failed to fetch" errors better
This commit is contained in:
@@ -17,17 +17,18 @@ class Monographs {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async init() {
|
async init() {
|
||||||
const user = await this._db.user.getUser();
|
|
||||||
const token = await this._db.user.tokenManager.getAccessToken();
|
|
||||||
if (!user || !token || !user.isEmailConfirmed) return;
|
|
||||||
let monographs = await this._db.storage.read("monographs", true);
|
|
||||||
try {
|
try {
|
||||||
|
const user = await this._db.user.getUser();
|
||||||
|
const token = await this._db.user.tokenManager.getAccessToken();
|
||||||
|
if (!user || !token || !user.isEmailConfirmed) return;
|
||||||
|
let monographs = await this._db.storage.read("monographs", true);
|
||||||
monographs = await http.get(`${Constants.API_HOST}/monographs`, token);
|
monographs = await http.get(`${Constants.API_HOST}/monographs`, token);
|
||||||
await this._db.storage.write("monographs", monographs);
|
await this._db.storage.write("monographs", monographs);
|
||||||
|
|
||||||
|
if (monographs) this.monographs = monographs;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(e);
|
console.error(e);
|
||||||
}
|
}
|
||||||
if (monographs) this.monographs = monographs;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -206,7 +206,7 @@ class UserManager {
|
|||||||
return await this.getUser();
|
return await this.getUser();
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(e);
|
console.error("Error fetching user", e);
|
||||||
return await this.getUser();
|
return await this.getUser();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,6 +34,5 @@ export const getServerNameFromHost = (host) => {
|
|||||||
"Subscriptions Management Server",
|
"Subscriptions Management Server",
|
||||||
[extractHostname(hosts.ISSUES_HOST)]: "Bug Reporting Server",
|
[extractHostname(hosts.ISSUES_HOST)]: "Bug Reporting Server",
|
||||||
};
|
};
|
||||||
console.log(names, host);
|
|
||||||
return names[host];
|
return names[host];
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user