pstream is dead; long live pstream taciturnaxolotl.github.io/pstream-ng/
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

improve fed setup status check

Pas 66d451af 96536c68

+43 -8
+2 -1
src/assets/locales/en.json
··· 950 950 }, 951 951 "status": { 952 952 "success": "success", 953 - "failure": "Failed to fetch a 'VIP' stream. Token is invalid or API is down!" 953 + "api_down": "Cannot reach FED API!", 954 + "invalid_token": "Failed to fetch a 'VIP' stream. Your token is invalid!" 954 955 } 955 956 }, 956 957 "watchParty": {
+2
src/pages/onboarding/Onboarding.tsx
··· 65 65 error: "error", 66 66 success: "success", 67 67 unset: "noresult", 68 + api_down: "error", 69 + invalid_token: "error", 68 70 }; 69 71 70 72 useEffect(() => {
+12
src/pages/parts/settings/ConnectionsPart.tsx
··· 235 235 error: "error", 236 236 success: "success", 237 237 unset: "noresult", 238 + api_down: "error", 239 + invalid_token: "error", 238 240 }; 239 241 240 242 useEffect(() => { ··· 337 339 {status === "error" && ( 338 340 <p className="text-type-danger mt-4"> 339 341 {t("fedapi.status.failure")} 342 + </p> 343 + )} 344 + {status === "api_down" && ( 345 + <p className="text-type-danger mt-4"> 346 + {t("fedapi.status.api_down")} 347 + </p> 348 + )} 349 + {status === "invalid_token" && ( 350 + <p className="text-type-danger mt-4"> 351 + {t("fedapi.status.invalid_token")} 340 352 </p> 341 353 )} 342 354 </>
+27 -7
src/pages/parts/settings/SetupPart.tsx
··· 61 61 }); 62 62 }; 63 63 64 - export type Status = "success" | "unset" | "error"; 64 + export type Status = 65 + | "success" 66 + | "unset" 67 + | "error" 68 + | "api_down" 69 + | "invalid_token"; 65 70 66 71 type SetupData = { 67 72 extension: Status; ··· 93 98 } 94 99 95 100 let attempts = 0; 96 - const maxAttempts = 3; 101 + const maxAttempts = 2; 97 102 98 103 while (attempts < maxAttempts) { 99 104 console.log( ··· 108 113 109 114 if (!response.ok) { 110 115 console.error("Febbox API test failed with status:", response.status); 116 + if (response.status === 503 || response.status === 502) { 117 + return "api_down"; 118 + } 111 119 attempts += 1; 112 120 if (attempts === maxAttempts) { 113 121 console.log("Max attempts reached, returning error"); 114 - return "error"; 122 + return "invalid_token"; 115 123 } 116 124 console.log("Retrying after failed response..."); 117 125 await sleep(3000); ··· 124 132 attempts += 1; 125 133 if (attempts === maxAttempts) { 126 134 console.log("Max attempts reached, returning error"); 127 - return "error"; 135 + return "invalid_token"; 128 136 } 129 137 console.log("Retrying after invalid response format..."); 130 138 await sleep(3000); ··· 147 155 attempts += 1; 148 156 if (attempts === maxAttempts) { 149 157 console.log("Max attempts reached, returning error"); 150 - return "error"; 158 + return "invalid_token"; 151 159 } 152 160 console.log("Retrying after no VIP link found..."); 153 161 await sleep(3000); ··· 156 164 attempts += 1; 157 165 if (attempts === maxAttempts) { 158 166 console.log("Max attempts reached, returning error"); 159 - return "error"; 167 + return "api_down"; 160 168 } 161 169 console.log("Retrying after error..."); 162 170 await sleep(3000); ··· 164 172 } 165 173 166 174 console.log("All attempts exhausted, returning error"); 167 - return "error"; 175 + return "api_down"; 168 176 } 169 177 170 178 function useIsSetup() { ··· 228 236 error: "error", 229 237 success: "success", 230 238 unset: "noresult", 239 + api_down: "error", 240 + invalid_token: "error", 231 241 }; 232 242 233 243 return ( ··· 293 303 title: "settings.connections.setup.unsetStatus.title", 294 304 desc: "settings.connections.setup.unsetStatus.description", 295 305 button: "settings.connections.setup.doSetup", 306 + }, 307 + api_down: { 308 + title: "settings.connections.setup.errorStatus.title", 309 + desc: "settings.connections.setup.errorStatus.description", 310 + button: "settings.connections.setup.redoSetup", 311 + }, 312 + invalid_token: { 313 + title: "settings.connections.setup.errorStatus.title", 314 + desc: "settings.connections.setup.errorStatus.description", 315 + button: "settings.connections.setup.redoSetup", 296 316 }, 297 317 }; 298 318