forked from Kieran/void.cat
Use logo as default avatar
This commit is contained in:
parent
9837d917b9
commit
097f97edc1
@ -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);
|
||||
|
@ -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 = {
|
||||
|
@ -1,5 +1,3 @@
|
||||
export const DefaultAvatar = "https://i.imgur.com/8A5Fu65.jpeg";
|
||||
|
||||
/**
|
||||
* @constant {number} - Size of 1 kiB
|
||||
*/
|
||||
|
@ -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,
|
||||
);
|
||||
}
|
||||
|
@ -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}`);
|
||||
|
@ -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 = {
|
||||
|
@ -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: {},
|
||||
});
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user