Fix HomeTyping, MLE, DownloadAllAttachments

This commit is contained in:
thororen1234 2026-06-16 20:38:33 -04:00
parent 06f6caa1d8
commit 23aba0f6d1
No known key found for this signature in database
4 changed files with 17 additions and 31 deletions

View file

@ -15,15 +15,6 @@ import { ChannelStore, showToast, Toasts } from "@webpack/common";
const logger = new Logger("DownloadAllAttachments");
async function downloadAll(attachments: MessageAttachment[]) {
let dir: FileSystemDirectoryHandle;
try {
dir = await window.showDirectoryPicker({ mode: "readwrite" });
} catch (e) {
if (e instanceof DOMException && e.name === "AbortError") return;
logger.error("Failed to open directory picker:", e);
return;
}
const usedNames = new Map<string, number>();
function uniqueName(original: string): string {
@ -36,31 +27,21 @@ async function downloadAll(attachments: MessageAttachment[]) {
: `${original.slice(0, dot)}_${count}${original.slice(dot)}`;
}
const tasks = attachments.map(a => ({ attachment: a, filename: uniqueName(a.filename) }));
const results = await Promise.allSettled(tasks.map(async ({ attachment, filename }) => {
const results = await Promise.allSettled(attachments.map(async attachment => {
const filename = uniqueName(attachment.filename);
if (!attachment.proxy_url) throw new Error("Missing Proxy URL");
const res = await fetch(attachment.proxy_url);
if (!res.ok) throw new Error(`HTTP ${res.status}`);
if (!res.body) throw new Error("Response body is empty");
let fileHandle: FileSystemFileHandle | undefined;
try {
fileHandle = await dir.getFileHandle(filename, { create: true });
const writable = await fileHandle.createWritable();
try {
await res.body.pipeTo(writable);
} catch (e) {
await writable.abort();
throw e;
}
} catch (e) {
if (fileHandle) {
try { await dir.removeEntry(filename); } catch { }
}
throw e;
}
const blob = await res.blob();
const url = URL.createObjectURL(blob);
const a = document.createElement("a");
a.href = url;
a.download = filename;
a.click();
URL.revokeObjectURL(url);
}));
const failed = results.filter(r => {

View file

@ -4,6 +4,8 @@
* SPDX-License-Identifier: GPL-3.0-or-later
*/
import "./styles.css";
import { Devs } from "@utils/constants";
import { classNameFactory } from "@utils/css";
import definePlugin from "@utils/types";
@ -36,7 +38,7 @@ export default definePlugin({
replacement:
[
{
match: /(\(0,\i.jsxs?\)\(\i,{}\))/,
match: /(?<=BUTTON_HOME.{0,10}children:)(\(0,\i.jsxs?\)\(\i,{}\))/,
replace: "arguments[0].user == null ? null : (vcIsTyping ? $self.TypingIcon() : $1)"
},
// define isTyping earlier in the function so i dont bReAk ThE rUlEs Of HoOkS

View file

@ -0,0 +1,3 @@
.vc-home-typing-dots {
margin-right: 2px;
}

View file

@ -189,7 +189,7 @@ export const settings = definePluginSettings({
attachmentFileExtensions: {
default: "png,jpg,jpeg,gif,webp,mp4,webm,mp3,ogg,wav",
type: OptionType.STRING,
description: "Comma separated list of file extensions to save. Attachments with file extensions not in this list will not be saved. Leave empty to save all attachments.",
description: "Comma separated list of file extensions to save. Attachments with file extensions not in this list will not be saved.",
onChange: (value: string) => {
let processedValue = "";