some room to breathe

This commit is contained in:
v 2024-09-18 22:20:12 +02:00 committed by GitHub
parent c274698b90
commit f7e7895453
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -137,6 +137,7 @@ export default definePlugin({
authors: [Devs.AGreenPig], authors: [Devs.AGreenPig],
dependencies: ["MessageAccessoriesAPI", "MessageUpdaterAPI",], dependencies: ["MessageAccessoriesAPI", "MessageUpdaterAPI",],
settings, settings,
patches: [ patches: [
{ {
find: "Messages.IMG_ALT_ATTACHMENT_FILE_TYPE.format", find: "Messages.IMG_ALT_ATTACHMENT_FILE_TYPE.format",
@ -146,6 +147,7 @@ export default definePlugin({
} }
} }
], ],
start() { start() {
addAccessory("pdfViewer", props => { addAccessory("pdfViewer", props => {
const pdfAttachments = props.message.attachments.filter(a => a.content_type === "application/pdf"); const pdfAttachments = props.message.attachments.filter(a => a.content_type === "application/pdf");
@ -160,12 +162,15 @@ export default definePlugin({
); );
}, -1); }, -1);
}, },
renderPreviewButton: ErrorBoundary.wrap(e => {
if (e.item.originalItem.content_type !== "application/pdf") return null;
return <PreviewButton attachment={e.item.originalItem} channelId={e.message.channel_id} messageId={e.message.id} />;
}),
stop() { stop() {
objectUrlsCache.clear(); objectUrlsCache.clear();
removeAccessory("pdfViewer"); removeAccessory("pdfViewer");
} }
renderPreviewButton: ErrorBoundary.wrap(e => {
if (e.item.originalItem.content_type !== "application/pdf") return null;
return <PreviewButton attachment={e.item.originalItem} channelId={e.message.channel_id} messageId={e.message.id} />;
}, { noop: true }),
}); });