gochan-org / gochan

async function should have await expression JS-0116
Bug risk
Minor
2 months ago2 years old
Found async function without any await expressions
191	});
192}
193
194export async function isLoggedIn() {195	return initStaff().then(info => {196		return info.rank > 0;197	});198}199
200export function banSelectedPost() {
201	const boardDirArr = location.pathname.split("/");
Found async function without any await expressions
178	});
179}
180
181export async function getPostInfo(id: number):Promise<PostInfo> {182	return $.ajax({183		method: "GET",184		url: `${webroot}manage/postinfo`,185		data: {186			postid: id187		},188		async: true,189		cache: true,190		dataType: "json"191	});192}193
194export async function isLoggedIn() {
195	return initStaff().then(info => {
Found async function without any await expressions
143}
144
145
146export async function initStaff() {147	if(staffInfo !== null || staffActions?.length > 0)148		// don't make multiple unnecessary AJAX requests149		return staffInfo;150151	return $.ajax({152		method: "GET",153		url: `${webroot}manage/staffinfo`,154		async: true,155		cache: false,156		dataType: "json",157		success: (result:string|StaffInfo) => {158			if(typeof result === "string") {159				try {160					staffInfo = JSON.parse(result);161				} catch(e) {162					// presumably not logged in163					staffActions = [];164				}165			} else if(typeof result === "object") {166				staffInfo = result;167			}168			staffActions = staffInfo.actions;169			return staffInfo;170		},171		error: (e: JQuery.jqXHR) => {172			console.error("Error getting actions list:", e);173		}174	}).then(() => {175		if(staffInfo.rank > 0)176			setupManagementEvents();177		return staffInfo;178	});179}180
181export async function getPostInfo(id: number):Promise<PostInfo> {
182	return $.ajax({
Found async function without any await expressions
 2
 3import $ from "jquery";
 4
 5export async function getThreadJSON(threadID: number, board: string) { 6	return $.ajax({ 7		url: `${webroot}${board}/res/${threadID}.json`, 8		cache: false, 9		dataType: "json",10	});11}
Found async function without any await expressions
22 * @param op The post number of the top post in the thread
23 * @param lock If true, the thread will be locked, otherwise it will be unlocked
24 */
25export async function updateThreadLock(board: string, op: number, lock: boolean) {26	const data: BoardLockJSON = {27		board: board,28		thread: op,29		json: 130	};31	if(lock) {32		data.lock = "Not locked";33	} else {34		data.unlock = "Locked";35	}36	$.post({37		url: webroot + "manage/threadattrs",38		data: data39	}).then((_data) => {40		alert("Thread " + (lock?"locked":"unlocked") + " successfully");41		const $lockOpt = $(`select#op${op} option`)42			.filter((_i, el) => el.textContent === "Lock thread" || el.textContent === "Unlock thread");43		if(lock) {44			$(`div#op${op} span.status-icons`).append(45				$("<img/>").attr({46					class: "locked-icon",47					src: webroot + "static/lock.png",48					alt: "Thread locked",49					title: "Thread locked"50				})51			);52			$lockOpt.text("Unlock thread");53		} else {54			$(`div#op${op} img.locked-icon`).remove();55			$lockOpt.text("Lock thread");56		}57	}).catch((data: any, _status: any, xhr: any) => {58		if(data.responseJSON !== undefined && data.responseJSON.message !== undefined) {59			alert(`Error updating thread /${board}/${op} lock status: ${data.responseJSON.message}`);60		} else {61			alert("Unable to send request: " + xhr);62		}63	});64}