Use logo as default avatar

This commit is contained in:
Kieran 2023-12-25 18:56:26 +00:00
parent 9837d917b9
commit 097f97edc1
Signed by: Kieran
GPG Key ID: DE71CEB3925BE941
9 changed files with 217 additions and 214 deletions

View File

@ -34,7 +34,12 @@ const router = createBrowserRouter([
path: "/u/:id",
loader: async ({ params }: LoaderFunctionArgs) => {
const state = store.getState();
const api = new VoidApi(import.meta.env.VITE_API_HOST, state.login.jwt ? () => Promise.resolve(`Bearer ${state.login.jwt}`) : undefined);
const api = new VoidApi(
import.meta.env.VITE_API_HOST,
state.login.jwt
? () => Promise.resolve(`Bearer ${state.login.jwt}`)
: undefined,
);
if (params.id) {
try {
return await api.getUser(params.id);

View File

@ -3,8 +3,6 @@ import { CSSProperties } from "react";
import { Link } from "react-router-dom";
import { Profile } from "@void-cat/api";
import { DefaultAvatar } from "@/Const";
const DefaultSize = 64;
interface InlineProfileProps {
@ -24,8 +22,8 @@ export function InlineProfile({ profile, options }: InlineProfileProps) {
...options,
};
let avatarUrl = profile.avatar ?? DefaultAvatar;
if (!avatarUrl.startsWith("http")) {
let avatarUrl = profile.avatar ?? "/logo_256.jpg";
if (profile.avatar && !avatarUrl.startsWith("http")) {
avatarUrl = `/d/${avatarUrl}`;
}
let avatarStyles = {

View File

@ -1,5 +1,3 @@
export const DefaultAvatar = "https://i.imgur.com/8A5Fu65.jpeg";
/**
* @constant {number} - Size of 1 kiB
*/

View File

@ -5,5 +5,8 @@ import { RootState } from "@/Store";
export default function useApi() {
const auth = useSelector((s: RootState) => s.login.jwt);
return new VoidApi(import.meta.env.VITE_API_HOST, auth ? () => Promise.resolve(`Bearer ${auth}`) : undefined);
return new VoidApi(
import.meta.env.VITE_API_HOST,
auth ? () => Promise.resolve(`Bearer ${auth}`) : undefined,
);
}

View File

@ -248,7 +248,9 @@ export function FilePreview() {
useEffect(() => {
if (info) {
const fileLink = info.metadata?.url ?? `${import.meta.env.VITE_API_HOST ?? ""}/d/${info.id}`;
const fileLink =
info.metadata?.url ??
`${import.meta.env.VITE_API_HOST ?? ""}/d/${info.id}`;
setFileSize(info.metadata?.size ?? 0);
const order = window.localStorage.getItem(`payment-${info.id}`);

View File

@ -7,7 +7,6 @@ import { Profile } from "@void-cat/api";
import useApi from "@/Hooks/UseApi";
import { RootState } from "@/Store";
import { DefaultAvatar } from "@/Const";
import { logout, setProfile as setGlobalProfile } from "@/LoginState";
import { FileList } from "@/Components/Shared/FileList";
@ -173,9 +172,8 @@ export function ProfilePage() {
}
if (profile) {
let avatarUrl = profile.avatar ?? DefaultAvatar;
if (!avatarUrl.startsWith("http")) {
// assume void-cat hosted avatar
let avatarUrl = profile.avatar ?? "/logo_256.jpg";
if (profile.avatar && !avatarUrl.startsWith("http")) {
avatarUrl = `/d/${avatarUrl}`;
}
let avatarStyles = {

View File

@ -20,7 +20,7 @@ export default defineConfig({
],
assetsInclude: [],
build: {
outDir: "build"
outDir: "build",
},
base: "/",
clearScreen: false,
@ -29,6 +29,5 @@ export default defineConfig({
"@": "/src",
},
},
define: {}
define: {},
});