diff --git a/src/content_scripts/protoots.js b/src/content_scripts/protoots.js index 6e329cc..b461ca6 100644 --- a/src/content_scripts/protoots.js +++ b/src/content_scripts/protoots.js @@ -318,11 +318,7 @@ async function addProplate(element) { // This allows us to pass incomplete nodes into this method, because // we only process them after we have all required information. - let tempType = "status"; - - if (location.href.endsWith("notifications")) tempType = "notification"; - - generateProPlate(statusId, accountName, nametagEl, tempType); + generateProPlate(statusId, accountName, nametagEl, "status"); } async function addToNotification(element) { @@ -337,7 +333,7 @@ async function addProplate(element) { let nametagEl = accountNameEl; element.setAttribute("protoots-checked", "true"); - generateProPlate(statusId, accountName, nametagEl, "notification"); //FIXME: change back to notification when done testing + generateProPlate(statusId, accountName, nametagEl, "notification"); } async function addToAccount(element) { @@ -350,11 +346,7 @@ async function addProplate(element) { element.setAttribute("protoots-checked", "true"); - let tempType = "account"; - - if (location.href.endsWith("notifications")) tempType = "notification"; - - generateProPlate(statusId, accountName, nametagEl, tempType); + generateProPlate(statusId, accountName, nametagEl, "account"); } async function addToConversation(element) { diff --git a/src/libs/fetchPronouns.js b/src/libs/fetchPronouns.js index 677fa04..a8d6675 100644 --- a/src/libs/fetchPronouns.js +++ b/src/libs/fetchPronouns.js @@ -1,4 +1,4 @@ -import { debug, error, info, warn } from "./logging"; +import { debug, error, info, log, warn } from "./logging"; import { cachePronouns, getPronouns } from "./caching"; import { normaliseAccountName } from "./protootshelpers"; @@ -60,6 +60,9 @@ export async function fetchPronouns(dataID, accountName, type) { status = await fetchStatus(dataID); } + log(`Fetching ${type} failed, trying notification instead.`); + if (!status) status = await fetchNotification(dataID); //fallback for glitch-soc notifications + const PronounField = getPronounField(status, accountName); if (PronounField == "null") { //TODO: if no field check bio @@ -86,6 +89,8 @@ async function fetchStatus(statusID) { let status = await response.json(); + if (!response.ok) return null; + //if status contains a reblog get that for further processing - we want the embedded post's author if (status.reblog) status = status.reblog; return status; @@ -128,6 +133,8 @@ async function fetchAccount(accountID) { }, ); + if (!response.ok) return null; + const account = await response.json(); return { account: account };