api: adjust a couple of URIs

adjusted some things, likke changing /newUser to /user/invite.
This commit is contained in:
Harvey Tindall
2024-08-21 20:35:08 +01:00
parent 2057823b7a
commit 7c808b56f7
11 changed files with 57 additions and 38 deletions
+2 -2
View File
@@ -6,7 +6,7 @@ import { inviteList, createInvite } from "./modules/invites.js";
import { accountsList } from "./modules/accounts.js";
import { settingsList } from "./modules/settings.js";
import { activityList } from "./modules/activity.js";
import { ProfileEditor } from "./modules/profiles.js";
import { ProfileEditor, reloadProfileNames } from "./modules/profiles.js";
import { _get, _post, notificationBox, whichAnimationEvent, bindManualDropdowns } from "./modules/common.js";
import { Updater } from "./modules/update.js";
import { Login } from "./modules/login.js";
@@ -187,7 +187,7 @@ login.onLogin = () => {
console.log("Logged in.");
window.updater = new Updater();
// FIXME: Decide whether to autoload activity or not
window.invites.reload()
reloadProfileNames();
setInterval(() => { window.invites.reload(); accounts.reload(); }, 30*1000);
const currentTab = window.tabs.current;
switch (currentTab) {
+1 -1
View File
@@ -289,7 +289,7 @@ const create = (event: SubmitEvent) => {
send.captcha_text = captcha.input.value;
}
}
_post("/newUser", send, (req: XMLHttpRequest) => {
_post("/user/invite", send, (req: XMLHttpRequest) => {
if (req.readyState != 4) return;
removeLoader(submitSpan);
let vals = req.response as ValidatorRespDTO;
+1 -1
View File
@@ -1128,7 +1128,7 @@ export class accountsList {
}
}
toggleLoader(button);
_post("/users", send, (req: XMLHttpRequest) => {
_post("/user", send, (req: XMLHttpRequest) => {
if (req.readyState == 4) {
toggleLoader(button);
if (req.status == 200 || (req.response["user"] as boolean)) {
+3 -7
View File
@@ -1,5 +1,6 @@
import { _get, _post, _delete, toClipboard, toggleLoader, toDateString } from "../modules/common.js";
import { DiscordUser, newDiscordSearch } from "../modules/discord.js";
import { reloadProfileNames } from "../modules/profiles.js";
class DOMInvite implements Invite {
updateNotify = (checkbox: HTMLInputElement) => {
@@ -431,7 +432,6 @@ export class inviteList implements inviteList {
private _list: HTMLDivElement;
private _empty: boolean;
// since invite reload sends profiles, this event it broadcast so the createInvite object can load them.
private _profileLoadEvent = new CustomEvent("profileLoadEvent");
invites: { [code: string]: DOMInvite };
@@ -502,13 +502,9 @@ export class inviteList implements inviteList {
this._list.appendChild(domInv.asElement());
}
reload = (callback?: () => void) => _get("/invites", null, (req: XMLHttpRequest) => {
reload = (callback?: () => void) => reloadProfileNames(() => _get("/invites", null, (req: XMLHttpRequest) => {
if (req.readyState == 4) {
let data = req.response;
if (req.status == 200) {
window.availableProfiles = data["profiles"];
document.dispatchEvent(this._profileLoadEvent);
}
if (data["invites"] === undefined || data["invites"] == null || data["invites"].length == 0) {
this.empty = true;
return;
@@ -534,7 +530,7 @@ export class inviteList implements inviteList {
if (callback) callback();
}
})
}));
}
export const inviteURLEvent = (id: string) => { return new CustomEvent(inviteList._inviteURLEvent, {"detail": id}) };
+8
View File
@@ -1,5 +1,13 @@
import { _get, _post, _delete, toggleLoader } from "../modules/common.js";
export const profileLoadEvent = new CustomEvent("profileLoadEvent");
export const reloadProfileNames = (then?: () => void) => _get("/profiles/names", null, (req: XMLHttpRequest) => {
if (req.readyState != 4) return;
window.availableProfiles = req.response["profiles"];
document.dispatchEvent(profileLoadEvent);
if (then) then();
});
interface Profile {
admin: boolean;
libraries: string;