From 2c3ee300c5b921ba137806953e3fe0cf5b34e294 Mon Sep 17 00:00:00 2001 From: Lea Date: Thu, 27 Jul 2023 18:09:13 +0200 Subject: [PATCH] feat: make some values configurable --- app/panel/inspect/page.tsx | 3 ++- components/cards/ChannelCard.tsx | 3 ++- components/cards/CompactMessage.tsx | 9 +++++---- components/cards/ServerCard.tsx | 3 ++- components/cards/UserCard.tsx | 5 +++-- lib/constants.ts | 4 +++- 6 files changed, 17 insertions(+), 10 deletions(-) diff --git a/app/panel/inspect/page.tsx b/app/panel/inspect/page.tsx index 3163663..263a9d3 100644 --- a/app/panel/inspect/page.tsx +++ b/app/panel/inspect/page.tsx @@ -2,6 +2,7 @@ import { Button } from "@/components/ui/button"; import { Input } from "@/components/ui/input"; +import { API_URL } from "@/lib/constants"; import { useRouter } from "next/navigation"; import { useState } from "react"; @@ -45,7 +46,7 @@ export default function Inspect() { className="flex-1" variant="outline" onClick={() => - fetch("https://api.revolt.chat/invites/" + id) + fetch(API_URL + "/invites/" + id) .then((res) => res.json()) .then((invite) => router.push(`/panel/inspect/server/${invite.server_id}`) diff --git a/components/cards/ChannelCard.tsx b/components/cards/ChannelCard.tsx index d09783c..af69067 100644 --- a/components/cards/ChannelCard.tsx +++ b/components/cards/ChannelCard.tsx @@ -2,6 +2,7 @@ import { Channel } from "revolt-api"; import { Card, CardDescription, CardHeader, CardTitle } from "../ui/card"; import { Avatar, AvatarFallback, AvatarImage } from "../ui/avatar"; import Link from "next/link"; +import { AUTUMN_URL } from "@/lib/constants"; export function ChannelCard({ channel, @@ -23,7 +24,7 @@ export function ChannelCard({ {channel.channel_type !== "DirectMessage" && ( )} diff --git a/components/cards/CompactMessage.tsx b/components/cards/CompactMessage.tsx index c51a8a8..a70452e 100644 --- a/components/cards/CompactMessage.tsx +++ b/components/cards/CompactMessage.tsx @@ -19,6 +19,7 @@ import { decodeTime } from "ulid"; import calendarPlugin from "dayjs/plugin/calendar"; import Link from "next/link"; +import { AUTUMN_URL } from "@/lib/constants"; dayjs.extend(calendarPlugin); export function CompactMessage({ @@ -56,7 +57,7 @@ export function CompactMessage({ {user?.avatar && ( )} @@ -80,7 +81,7 @@ export function CompactMessage({ {user?.avatar && ( )}{" "} @@ -94,11 +95,11 @@ export function CompactMessage({ target="_blank" className="w-fit" key={attachment._id} - href={`https://autumn.revolt.chat/attachments/${attachment._id}`} + href={`${AUTUMN_URL}/attachments/${attachment._id}`} > ) : ( diff --git a/components/cards/ServerCard.tsx b/components/cards/ServerCard.tsx index ac3e69c..9ce85bd 100644 --- a/components/cards/ServerCard.tsx +++ b/components/cards/ServerCard.tsx @@ -2,6 +2,7 @@ import { Server } from "revolt-api"; import { Card, CardDescription, CardHeader, CardTitle } from "../ui/card"; import { Avatar, AvatarFallback, AvatarImage } from "../ui/avatar"; import Link from "next/link"; +import { AUTUMN_URL } from "@/lib/constants"; export function ServerCard({ server, @@ -16,7 +17,7 @@ export function ServerCard({ {server.name diff --git a/components/cards/UserCard.tsx b/components/cards/UserCard.tsx index b331688..d347dea 100644 --- a/components/cards/UserCard.tsx +++ b/components/cards/UserCard.tsx @@ -2,6 +2,7 @@ import { User } from "revolt-api"; import { Card, CardDescription, CardHeader, CardTitle } from "../ui/card"; import { Avatar, AvatarFallback, AvatarImage } from "../ui/avatar"; import { Badge } from "../ui/badge"; +import { AUTUMN_URL } from "@/lib/constants"; export function UserCard({ user, subtitle }: { user: User; subtitle: string }) { return ( @@ -9,7 +10,7 @@ export function UserCard({ user, subtitle }: { user: User; subtitle: string }) { className="shadow-none bg-no-repeat bg-right text-left" style={{ backgroundImage: user.profile?.background - ? `linear-gradient(to right, white, rgba(255,0,0,0)), url('https://autumn.revolt.chat/backgrounds/${user.profile.background._id}')` + ? `linear-gradient(to right, white, rgba(255,0,0,0)), url('${AUTUMN_URL}/backgrounds/${user.profile.background._id}')` : "", backgroundSize: "75%", }} @@ -18,7 +19,7 @@ export function UserCard({ user, subtitle }: { user: User; subtitle: string }) { {(user.display_name ?? user.username) diff --git a/lib/constants.ts b/lib/constants.ts index 4bac3b0..afbed6f 100644 --- a/lib/constants.ts +++ b/lib/constants.ts @@ -1 +1,3 @@ -export const PLATFORM_MOD_ID = "01FC17E1WTM2BGE4F3ARN3FDAF"; +export const PLATFORM_MOD_ID = process.env.PLATFORM_MOD_ID || "01FC17E1WTM2BGE4F3ARN3FDAF"; +export const AUTUMN_URL = process.env.AUTUMN_URL || "https://autumn.revolt.chat"; +export const API_URL = process.env.API_URL || "https://api.revolt.chat";