forked from Kieran/void.cat
Use logo as default avatar
This commit is contained in:
parent
9837d917b9
commit
097f97edc1
@ -18,8 +18,8 @@ import {
|
|||||||
StateChangeHandler,
|
StateChangeHandler,
|
||||||
VoidUploader,
|
VoidUploader,
|
||||||
} from "./upload";
|
} from "./upload";
|
||||||
import {StreamUploader} from "./stream-uploader";
|
import { StreamUploader } from "./stream-uploader";
|
||||||
import {XHRUploader} from "./xhr-uploader";
|
import { XHRUploader } from "./xhr-uploader";
|
||||||
|
|
||||||
export type AuthHandler = (url: string, method: string) => Promise<string>;
|
export type AuthHandler = (url: string, method: string) => Promise<string>;
|
||||||
|
|
||||||
@ -147,7 +147,7 @@ export class VoidApi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
submitVerifyCode(uid: string, code: string) {
|
submitVerifyCode(uid: string, code: string) {
|
||||||
return this.#req<void>("POST", `/user/${uid}/verify`, {code});
|
return this.#req<void>("POST", `/user/${uid}/verify`, { code });
|
||||||
}
|
}
|
||||||
|
|
||||||
sendNewCode(uid: string) {
|
sendNewCode(uid: string) {
|
||||||
|
@ -1,18 +1,18 @@
|
|||||||
<!doctype html>
|
<!doctype html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8"/>
|
<meta charset="utf-8" />
|
||||||
<link rel="icon" href="/logo_32.png"/>
|
<link rel="icon" href="/logo_32.png" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1"/>
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||||
<meta name="theme-color" content="#000000"/>
|
<meta name="theme-color" content="#000000" />
|
||||||
<meta name="description" content="void.cat - free, simple file sharing."/>
|
<meta name="description" content="void.cat - free, simple file sharing." />
|
||||||
<link rel="apple-touch-icon" href="/logo_256.png"/>
|
<link rel="apple-touch-icon" href="/logo_256.png" />
|
||||||
<link rel="manifest" href="/manifest.json"/>
|
<link rel="manifest" href="/manifest.json" />
|
||||||
<title>void.cat</title>
|
<title>void.cat</title>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<noscript>You need to enable JavaScript to run this app.</noscript>
|
<noscript>You need to enable JavaScript to run this app.</noscript>
|
||||||
<div id="root"></div>
|
<div id="root"></div>
|
||||||
<script src="./src/index.tsx" type="module"></script>
|
<script src="./src/index.tsx" type="module"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
@ -34,7 +34,12 @@ const router = createBrowserRouter([
|
|||||||
path: "/u/:id",
|
path: "/u/:id",
|
||||||
loader: async ({ params }: LoaderFunctionArgs) => {
|
loader: async ({ params }: LoaderFunctionArgs) => {
|
||||||
const state = store.getState();
|
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) {
|
if (params.id) {
|
||||||
try {
|
try {
|
||||||
return await api.getUser(params.id);
|
return await api.getUser(params.id);
|
||||||
|
@ -3,8 +3,6 @@ import { CSSProperties } from "react";
|
|||||||
import { Link } from "react-router-dom";
|
import { Link } from "react-router-dom";
|
||||||
import { Profile } from "@void-cat/api";
|
import { Profile } from "@void-cat/api";
|
||||||
|
|
||||||
import { DefaultAvatar } from "@/Const";
|
|
||||||
|
|
||||||
const DefaultSize = 64;
|
const DefaultSize = 64;
|
||||||
|
|
||||||
interface InlineProfileProps {
|
interface InlineProfileProps {
|
||||||
@ -24,8 +22,8 @@ export function InlineProfile({ profile, options }: InlineProfileProps) {
|
|||||||
...options,
|
...options,
|
||||||
};
|
};
|
||||||
|
|
||||||
let avatarUrl = profile.avatar ?? DefaultAvatar;
|
let avatarUrl = profile.avatar ?? "/logo_256.jpg";
|
||||||
if (!avatarUrl.startsWith("http")) {
|
if (profile.avatar && !avatarUrl.startsWith("http")) {
|
||||||
avatarUrl = `/d/${avatarUrl}`;
|
avatarUrl = `/d/${avatarUrl}`;
|
||||||
}
|
}
|
||||||
let avatarStyles = {
|
let avatarStyles = {
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
export const DefaultAvatar = "https://i.imgur.com/8A5Fu65.jpeg";
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @constant {number} - Size of 1 kiB
|
* @constant {number} - Size of 1 kiB
|
||||||
*/
|
*/
|
||||||
|
@ -5,5 +5,8 @@ import { RootState } from "@/Store";
|
|||||||
|
|
||||||
export default function useApi() {
|
export default function useApi() {
|
||||||
const auth = useSelector((s: RootState) => s.login.jwt);
|
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(() => {
|
useEffect(() => {
|
||||||
if (info) {
|
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);
|
setFileSize(info.metadata?.size ?? 0);
|
||||||
|
|
||||||
const order = window.localStorage.getItem(`payment-${info.id}`);
|
const order = window.localStorage.getItem(`payment-${info.id}`);
|
||||||
|
@ -7,7 +7,6 @@ import { Profile } from "@void-cat/api";
|
|||||||
|
|
||||||
import useApi from "@/Hooks/UseApi";
|
import useApi from "@/Hooks/UseApi";
|
||||||
import { RootState } from "@/Store";
|
import { RootState } from "@/Store";
|
||||||
import { DefaultAvatar } from "@/Const";
|
|
||||||
|
|
||||||
import { logout, setProfile as setGlobalProfile } from "@/LoginState";
|
import { logout, setProfile as setGlobalProfile } from "@/LoginState";
|
||||||
import { FileList } from "@/Components/Shared/FileList";
|
import { FileList } from "@/Components/Shared/FileList";
|
||||||
@ -173,9 +172,8 @@ export function ProfilePage() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (profile) {
|
if (profile) {
|
||||||
let avatarUrl = profile.avatar ?? DefaultAvatar;
|
let avatarUrl = profile.avatar ?? "/logo_256.jpg";
|
||||||
if (!avatarUrl.startsWith("http")) {
|
if (profile.avatar && !avatarUrl.startsWith("http")) {
|
||||||
// assume void-cat hosted avatar
|
|
||||||
avatarUrl = `/d/${avatarUrl}`;
|
avatarUrl = `/d/${avatarUrl}`;
|
||||||
}
|
}
|
||||||
let avatarStyles = {
|
let avatarStyles = {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import react from "@vitejs/plugin-react";
|
import react from "@vitejs/plugin-react";
|
||||||
import {visualizer} from "rollup-plugin-visualizer";
|
import { visualizer } from "rollup-plugin-visualizer";
|
||||||
import {defineConfig} from "vite";
|
import { defineConfig } from "vite";
|
||||||
import {vitePluginVersionMark} from "vite-plugin-version-mark";
|
import { vitePluginVersionMark } from "vite-plugin-version-mark";
|
||||||
|
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
plugins: [
|
plugins: [
|
||||||
@ -20,7 +20,7 @@ export default defineConfig({
|
|||||||
],
|
],
|
||||||
assetsInclude: [],
|
assetsInclude: [],
|
||||||
build: {
|
build: {
|
||||||
outDir: "build"
|
outDir: "build",
|
||||||
},
|
},
|
||||||
base: "/",
|
base: "/",
|
||||||
clearScreen: false,
|
clearScreen: false,
|
||||||
@ -29,6 +29,5 @@ export default defineConfig({
|
|||||||
"@": "/src",
|
"@": "/src",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
define: {}
|
define: {},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user