Clarify group-chat scraping and refresh puppet URLs via the core
This commit is contained in:
+19
-5
@@ -118,8 +118,10 @@
|
||||
document.querySelector("#scope-bot")?.classList.remove("active");
|
||||
}
|
||||
|
||||
async function loadChannels() {
|
||||
if (state.loadedChannels) return;
|
||||
async function loadChannels(force = false) {
|
||||
if (state.loadedChannels && !force) return;
|
||||
state.dmsError = null;
|
||||
|
||||
try {
|
||||
const data = await window.VK.api.get("/api/state");
|
||||
state.guilds = data?.guilds ?? [];
|
||||
@@ -150,14 +152,16 @@
|
||||
label: `${dm.name || names || "DM"} (${dm.type === 3 ? "group DM" : "DM"})`
|
||||
});
|
||||
}
|
||||
} catch {
|
||||
} catch (error) {
|
||||
state.dms = [];
|
||||
state.dmsError = error.message;
|
||||
}
|
||||
|
||||
state.loadedChannels = true;
|
||||
} catch {
|
||||
} catch (error) {
|
||||
state.guilds = [];
|
||||
state.channels = [];
|
||||
state.dmsError = error.message;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -844,6 +848,16 @@
|
||||
tree.replaceChildren();
|
||||
|
||||
if (scrapeTab === "group") {
|
||||
if (state.dmsError) {
|
||||
hint.textContent = `Group chats need the core client: ${state.dmsError}`;
|
||||
tree.append(
|
||||
button("Retry", () => {
|
||||
void loadChannels(true).then(renderScrapeTree);
|
||||
})
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
const groups = state.dms.filter(dm => dm.type === 3);
|
||||
hint.textContent = groups.length ? "Group chats use the puppet account." : "No cached group chats yet.";
|
||||
for (const dm of groups) {
|
||||
@@ -881,7 +895,7 @@
|
||||
function openScrapeModal() {
|
||||
renderScrapeTree();
|
||||
scrapeModal.hidden = false;
|
||||
void loadChannels().then(renderScrapeTree);
|
||||
void loadChannels(true).then(renderScrapeTree);
|
||||
}
|
||||
|
||||
for (const [tab, id] of [
|
||||
|
||||
Reference in New Issue
Block a user