Fix ZipPreview & Contrib Badge Size

This commit is contained in:
thororen1234 2025-10-10 09:22:22 -04:00
parent 5b9e899c57
commit aea7b5a904
No known key found for this signature in database
4 changed files with 23 additions and 22 deletions

View file

@ -114,18 +114,17 @@ const blobCache = new Map<string, Blob>();
// Component to render inside each zip attachment
function ZipAttachmentPreview({ attachment }: { attachment: any; }) {
const key = attachment?.id || attachment?.url || attachment?.proxy_url;
const ext = attachment.fileName.match(/\.tar\.\w+$|(\.\w+)$/)?.[0] ?? "";
if (ext !== ".zip") return;
const [blob, setBlob] = useState<Blob | null>(() => blobCache.get(attachment.id) || null);
const [blob, setBlob] = useState<Blob | null>(() => blobCache.get(key) || null);
const [error, setError] = useState<string | null>(null);
const [expanded, setExpanded] = useState<boolean>(() => {
try { return expandedState.get(attachment.id) ?? false; } catch { return false; }
});
const [expanded, setExpanded] = useState<boolean>(() => expandedState.get(key) ?? false);
useEffect(() => {
// If already cached, skip fetch
if (blobCache.has(attachment.id)) return;
if (blobCache.has(key)) return;
let mounted = true;
(async () => {
@ -143,14 +142,15 @@ function ZipAttachmentPreview({ attachment }: { attachment: any; }) {
}
if (mounted) {
setBlob(b);
blobCache.set(attachment.id, b);
blobCache.set(key, b);
}
} catch (err) {
} catch {
if (mounted) setError("Failed to fetch archive");
}
})();
return () => { mounted = false; };
}, [attachment.id]);
}, [key]);
if (error) return <div className="zp-error">{error}</div>;
if (!blob) return <div className="zp-loading">Loading preview…</div>;
@ -161,7 +161,10 @@ function ZipAttachmentPreview({ attachment }: { attachment: any; }) {
blob={blob}
name={attachment.filename || attachment.name || "archive.zip"}
expanded={expanded}
onExpandedChange={v => { setExpanded(v); expandedState.set(attachment.id, v); }}
onExpandedChange={v => {
setExpanded(v);
expandedState.set(key, v);
}}
/>
</div>
);

View file

@ -48,7 +48,13 @@ const EquicordContributorBadge: ProfileBadge = {
image: EQUICORD_CONTRIBUTOR_BADGE,
position: BadgePosition.START,
shouldShow: ({ userId }) => shouldShowEquicordContributorBadge(userId),
onClick: (_, { userId }) => openContributorModal(UserStore.getUser(userId))
onClick: (_, { userId }) => openContributorModal(UserStore.getUser(userId)),
props: {
style: {
borderRadius: "50%",
transform: "scale(0.9)"
}
},
};
const EquicordDonorBadge: ProfileBadge = {

View file

@ -85,9 +85,9 @@ export default definePlugin({
}
},
{
find: ".SIDEBAR,shouldShowTooltip:",
find: '"UserProfileSidebar"',
replacement: {
match: /children:\[(?=[^[]+?shouldShowTooltip:)/,
match: /children:\[(?=[^[]+?\.SIDEBAR)/,
replace: "$&$self.BiteSizeReviewsButton({user:arguments[0].user}),"
}
}

View file

@ -19,7 +19,7 @@
import { FormSwitchCompat } from "@components/FormSwitch";
import { LazyComponent } from "@utils/lazyReact";
import * as t from "@vencord/discord-types";
import { filters, find, LazyComponentWebpack, mapMangledModuleLazy, waitFor } from "@webpack";
import { filters, mapMangledModuleLazy, waitFor } from "@webpack";
import { FormText } from "./FormText";
import { waitForComponent } from "./internal";
@ -56,15 +56,7 @@ export const TextInput = waitForComponent<t.TextInput>("TextInput", filters.comp
export const TextArea = waitForComponent<t.TextArea>("TextArea", filters.componentByCode("this.getPaddingRight()},id:"));
export const Text = waitForComponent<t.Text>("Text", filters.componentByCode('case"always-white"'));
export const Heading = waitForComponent<t.Heading>("Heading", filters.componentByCode(">6?{", "variant:"));
export const Select: t.Select = LazyComponentWebpack(() => {
const oldFilter = filters.componentByCode('="bottom",', ".select,", '"Escape"===');
const newFilter = filters.componentByCode('"Select"', ".newOptionLabel");
const res = find(oldFilter) ?? find(newFilter);
if (res) return res;
throw new Error("Vencord failed to find the Select component");
});
export const Select = waitForComponent<t.Select>("Select", filters.componentByCode('"Select"', ".newOptionLabel"));
export const SearchableSelect = waitForComponent<t.SearchableSelect>("SearchableSelect", filters.componentByCode('"SearchableSelect"'));
export const Slider = waitForComponent<t.Slider>("Slider", filters.componentByCode('"markDash".concat('));
export const Popout = waitForComponent<t.Popout>("Popout", filters.componentByCode("ref:this.ref,", "renderPopout:this.renderPopout,"));