activity: pseudo links work on refresh
This commit is contained in:
+19
-6
@@ -1680,14 +1680,25 @@ export class accountsList {
|
||||
this._addUserProfile.innerHTML = innerHTML;
|
||||
}
|
||||
|
||||
public static readonly _accountURLEvent = "account-url";
|
||||
registerURLListener = () => document.addEventListener(accountsList._accountURLEvent, (event: CustomEvent) => {
|
||||
const userID = event.detail;
|
||||
focusAccount = (userID: string) => {
|
||||
console.log("focusing user", userID);
|
||||
this._searchBox.value = `id:"${userID}"`;
|
||||
this._search.onSearchBoxChange();
|
||||
this._users[userID].focus();
|
||||
if (userID in this._users) this._users[userID].focus();
|
||||
}
|
||||
|
||||
public static readonly _accountURLEvent = "account-url";
|
||||
registerURLListener = () => document.addEventListener(accountsList._accountURLEvent, (event: CustomEvent) => {
|
||||
this.focusAccount(event.detail);
|
||||
});
|
||||
|
||||
isAccountURL = () => { return window.location.pathname.startsWith(window.URLBase + "/accounts/user/"); }
|
||||
|
||||
loadAccountURL = () => {
|
||||
let userID = window.location.pathname.split(window.URLBase + "/accounts/user/")[1].split("?lang")[0];
|
||||
this.focusAccount(userID);
|
||||
}
|
||||
|
||||
constructor() {
|
||||
this._populateNumbers();
|
||||
this._users = {};
|
||||
@@ -1695,7 +1706,7 @@ export class accountsList {
|
||||
this._selectAll.onchange = () => {
|
||||
this.selectAll = this._selectAll.checked;
|
||||
};
|
||||
document.addEventListener("accounts-reload", this.reload);
|
||||
document.addEventListener("accounts-reload", () => this.reload());
|
||||
document.addEventListener("accountCheckEvent", () => { this._checkCount++; this._checkCheckCount(); });
|
||||
document.addEventListener("accountUncheckEvent", () => { this._checkCount--; this._checkCheckCount(); });
|
||||
this._addUserButton.onclick = () => {
|
||||
@@ -1899,7 +1910,7 @@ export class accountsList {
|
||||
this.registerURLListener();
|
||||
}
|
||||
|
||||
reload = () => {
|
||||
reload = (callback?: () => void) => {
|
||||
_get("/users", null, (req: XMLHttpRequest) => {
|
||||
if (req.readyState == 4 && req.status == 200) {
|
||||
// same method as inviteList.reload()
|
||||
@@ -1933,6 +1944,8 @@ export class accountsList {
|
||||
this.setVisibility(results, true);
|
||||
}
|
||||
this._checkCheckCount();
|
||||
|
||||
if (callback) callback();
|
||||
}
|
||||
});
|
||||
this.loadTemplates();
|
||||
|
||||
@@ -597,6 +597,7 @@ export class activityList {
|
||||
}
|
||||
|
||||
detectScroll = () => {
|
||||
if (!this._hasLoaded) return;
|
||||
// console.log(window.innerHeight + document.documentElement.scrollTop, document.scrollingElement.scrollHeight);
|
||||
if (Math.abs(window.innerHeight + document.documentElement.scrollTop - document.scrollingElement.scrollHeight) < 50) {
|
||||
// window.notifications.customSuccess("scroll", "Reached bottom.");
|
||||
|
||||
+17
-5
@@ -425,16 +425,26 @@ export class inviteList implements inviteList {
|
||||
|
||||
invites: { [code: string]: DOMInvite };
|
||||
|
||||
public static readonly _inviteURLEvent = "invite-url";
|
||||
registerURLListener = () => document.addEventListener(inviteList._inviteURLEvent, (event: CustomEvent) => {
|
||||
const inviteCode = event.detail;
|
||||
focusInvite = (inviteCode: string, errorMsg: string = window.lang.notif("errorInviteNoLongerExists")) => {
|
||||
for (let code of Object.keys(this.invites)) {
|
||||
this.invites[code].expanded = code == inviteCode;
|
||||
}
|
||||
if (inviteCode in this.invites) this.invites[inviteCode].focus();
|
||||
else window.notifications.customError("inviteDoesntExistError", window.lang.notif("errorInviteDoesntExist"));
|
||||
else window.notifications.customError("inviteDoesntExistError", errorMsg);
|
||||
};
|
||||
|
||||
public static readonly _inviteURLEvent = "invite-url";
|
||||
registerURLListener = () => document.addEventListener(inviteList._inviteURLEvent, (event: CustomEvent) => {
|
||||
this.focusInvite(event.detail);
|
||||
})
|
||||
|
||||
isInviteURL = () => { return window.location.pathname.startsWith(window.URLBase + "/invites/"); }
|
||||
|
||||
loadInviteURL = () => {
|
||||
let inviteCode = window.location.pathname.split(window.URLBase + "/invites/")[1].split("?lang")[0];
|
||||
this.focusInvite(inviteCode, window.lang.notif("errorInviteNotFound"));
|
||||
}
|
||||
|
||||
constructor() {
|
||||
this._list = document.getElementById('invites') as HTMLDivElement;
|
||||
this.empty = true;
|
||||
@@ -482,7 +492,7 @@ export class inviteList implements inviteList {
|
||||
this._list.appendChild(domInv.asElement());
|
||||
}
|
||||
|
||||
reload = () => _get("/invites", null, (req: XMLHttpRequest) => {
|
||||
reload = (callback?: () => void) => _get("/invites", null, (req: XMLHttpRequest) => {
|
||||
if (req.readyState == 4) {
|
||||
let data = req.response;
|
||||
if (req.status == 200) {
|
||||
@@ -511,6 +521,8 @@ export class inviteList implements inviteList {
|
||||
this.invites[code].remove();
|
||||
delete this.invites[code];
|
||||
}
|
||||
|
||||
if (callback) callback();
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
+2
-2
@@ -20,7 +20,7 @@ export class Tabs implements Tabs {
|
||||
get current(): string { return this._current; }
|
||||
set current(tabID: string) { this.switch(tabID); }
|
||||
|
||||
switch = (tabID: string, noRun: boolean = false) => {
|
||||
switch = (tabID: string, noRun: boolean = false, keepURL: boolean = false) => {
|
||||
this._current = tabID;
|
||||
for (let t of this.tabs) {
|
||||
if (t.tabID == tabID) {
|
||||
@@ -28,7 +28,7 @@ export class Tabs implements Tabs {
|
||||
if (t.preFunc && !noRun) { t.preFunc(); }
|
||||
t.tabEl.classList.remove("unfocused");
|
||||
if (t.postFunc && !noRun) { t.postFunc(); }
|
||||
document.dispatchEvent(new CustomEvent("tab-change", { detail: tabID }));
|
||||
document.dispatchEvent(new CustomEvent("tab-change", { detail: keepURL ? "" : tabID }));
|
||||
} else {
|
||||
t.buttonEl.classList.remove("active");
|
||||
t.buttonEl.classList.remove("~urge");
|
||||
|
||||
Reference in New Issue
Block a user