mirror of
https://github.com/Eggbertx/gochan.git
synced 2025-08-03 11:46:22 -07:00
Properly catch errors in thread API AJAX requests
This commit is contained in:
parent
692befd8c3
commit
245ba730eb
4 changed files with 20 additions and 16 deletions
17
frontend/js/api/threads.js
Normal file
17
frontend/js/api/threads.js
Normal file
|
@ -0,0 +1,17 @@
|
|||
/* global webroot */
|
||||
|
||||
import $ from "jquery";
|
||||
|
||||
export function getThreadJSON(threadID, board) {
|
||||
return $.ajax({
|
||||
url: `${webroot}${board}/res/${threadID}.json`,
|
||||
cache: false,
|
||||
dataType: "json",
|
||||
error: function(e, status, statusText) {
|
||||
// clearInterval(threadWatcherInterval);
|
||||
return {};
|
||||
}
|
||||
}).catch(e => {
|
||||
return {};
|
||||
});
|
||||
}
|
|
@ -12,6 +12,7 @@ import { getBooleanStorageVal, getNumberStorageVal } from "./storage";
|
|||
import { currentThread, getPageThread, insideOP } from "./postinfo";
|
||||
import { addPostDropdown } from "./dom/postdropdown";
|
||||
import { createPostElement } from "./dom/postelement";
|
||||
import { getThreadJSON } from "./api/threads"
|
||||
import { openQR } from "./dom/qr";
|
||||
|
||||
let doClickPreview = false;
|
||||
|
@ -28,8 +29,6 @@ let currentThreadJSON = {
|
|||
posts: []
|
||||
};
|
||||
|
||||
|
||||
|
||||
export function getUploadPostID(upload, container) {
|
||||
// if container, upload is div.upload-container
|
||||
// otherwise it's img or video
|
||||
|
@ -44,9 +43,6 @@ export function updateThreadJSON() {
|
|||
if(!(json.posts instanceof Array) || json.posts.length === 0)
|
||||
return;
|
||||
currentThreadJSON = json;
|
||||
}).catch(e => {
|
||||
console.error(`Failed updating current thread: ${e}`);
|
||||
clearInterval(threadWatcherInterval);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -244,15 +240,6 @@ export function quote(no) {
|
|||
}
|
||||
window.quote = quote;
|
||||
|
||||
|
||||
export function getThreadJSON(threadID, board) {
|
||||
return $.ajax({
|
||||
url: `${webroot}${board}/res/${threadID}.json`,
|
||||
cache: false,
|
||||
dataType: "json"
|
||||
});
|
||||
}
|
||||
|
||||
$(() => {
|
||||
let pageThread = getPageThread();
|
||||
if(pageThread.op >= 1) {
|
||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Loading…
Add table
Add a link
Reference in a new issue