refactored how avatars are being handled
This commit is contained in:
@@ -35,6 +35,7 @@ const addMemberToCollection = async (
|
||||
id: user.id,
|
||||
name: user.name,
|
||||
username: user.username,
|
||||
image: user.image,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
const avatarCache = new Map();
|
||||
|
||||
export default async function avatarExists(fileUrl: string): Promise<boolean> {
|
||||
if (avatarCache.has(fileUrl)) {
|
||||
return avatarCache.get(fileUrl);
|
||||
}
|
||||
|
||||
const response = await fetch(fileUrl, { method: "HEAD" });
|
||||
const exists = !(response.headers.get("content-type") === "text/html");
|
||||
|
||||
avatarCache.set(fileUrl, exists);
|
||||
return exists;
|
||||
}
|
||||
@@ -5,6 +5,8 @@ export default async function getPublicUserData(id: number | string) {
|
||||
|
||||
const data = await response.json();
|
||||
|
||||
console.log(data);
|
||||
|
||||
if (!response.ok) toast.error(data.response);
|
||||
|
||||
return data.response;
|
||||
|
||||
Reference in New Issue
Block a user