feat: Add initial Electron frontend package.json with dependencies, scripts, and build configuration.

This commit is contained in:
Bryan1029384756
2026-02-12 02:38:06 -06:00
parent 1952a1fedf
commit e790db7029
14 changed files with 95 additions and 29 deletions

View File

@@ -94,7 +94,7 @@ function createWindow() {
const isDev = process.env.npm_lifecycle_event === 'electron:dev';
if (isDev) {
mainWindow.loadURL('http://localhost:5173');
mainWindow.loadURL(process.env.VITE_DEV_URL || 'http://localhost:5173');
mainWindow.webContents.openDevTools();
} else {
// Production: Load the built file

View File

@@ -1,7 +1,7 @@
{
"name": "discord",
"private": true,
"version": "1.0.8",
"version": "1.0.9",
"description": "A Discord clone built with Convex, React, and Electron",
"author": "Moyettes",
"type": "module",

View File

@@ -28,6 +28,18 @@ import MessageItem, { getUserColor } from './MessageItem';
const metadataCache = new Map();
const attachmentCache = new Map();
const CONVEX_PUBLIC_URL = 'http://72.26.56.3:3210';
const rewriteStorageUrl = (url) => {
try {
const u = new URL(url);
const pub = new URL(CONVEX_PUBLIC_URL);
u.hostname = pub.hostname;
u.port = pub.port;
u.protocol = pub.protocol;
return u.toString();
} catch { return url; }
};
// Persistent global decryption cache (survives channel switches)
// Keyed by message _id, stores { content, isVerified, decryptedReply }
const messageDecryptionCache = new Map();
@@ -240,15 +252,16 @@ const LinkPreview = ({ url }) => {
};
const Attachment = ({ metadata, onLoad, onImageClick }) => {
const [url, setUrl] = useState(attachmentCache.get(metadata.url) || null);
const [loading, setLoading] = useState(!attachmentCache.has(metadata.url));
const fetchUrl = rewriteStorageUrl(metadata.url);
const [url, setUrl] = useState(attachmentCache.get(fetchUrl) || null);
const [loading, setLoading] = useState(!attachmentCache.has(fetchUrl));
const [error, setError] = useState(null);
const [showControls, setShowControls] = useState(false);
const videoRef = useRef(null);
useEffect(() => {
if (attachmentCache.has(metadata.url)) {
setUrl(attachmentCache.get(metadata.url));
if (attachmentCache.has(fetchUrl)) {
setUrl(attachmentCache.get(fetchUrl));
setLoading(false);
return;
}
@@ -256,7 +269,7 @@ const Attachment = ({ metadata, onLoad, onImageClick }) => {
let isMounted = true;
const decryptFile = async () => {
try {
const res = await fetch(metadata.url);
const res = await fetch(fetchUrl);
const blob = await res.blob();
const arrayBuffer = await blob.arrayBuffer();
const hexInput = toHexString(new Uint8Array(arrayBuffer));
@@ -272,7 +285,7 @@ const Attachment = ({ metadata, onLoad, onImageClick }) => {
const objectUrl = URL.createObjectURL(decryptedBlob);
if (isMounted) {
attachmentCache.set(metadata.url, objectUrl);
attachmentCache.set(fetchUrl, objectUrl);
setUrl(objectUrl);
setLoading(false);
}

View File

@@ -754,7 +754,8 @@ const Sidebar = ({ channels, categories, activeChannel, onSelectChannel, usernam
keyVersion: 1
});
const link = `http://localhost:5173/#/register?code=${inviteCode}&key=${inviteSecret}`;
const baseUrl = import.meta.env.VITE_APP_URL || window.location.origin;
const link = `${baseUrl}/#/register?code=${inviteCode}&key=${inviteSecret}`;
navigator.clipboard.writeText(link);
alert(`Invite Link Copied to Clipboard!\n\n${link}`);
} catch (e) {

View File

@@ -79,19 +79,19 @@ export const VoiceProvider = ({ children }) => {
setToken(lkToken);
const newRoom = new Room({
adaptiveStream: false,
dynacast: false,
adaptiveStream: true,
dynacast: true,
autoSubscribe: true,
audioCaptureDefaults: {
autoGainControl: true,
echoCancellation: true,
noiseSuppression: true,
channelCount: 2,
noiseSuppression: false,
channelCount: 1,
sampleRate: 48000,
},
publishDefaults: {
audioPreset: { maxBitrate: 384_000 },
dtx: true,
audioPreset: { maxBitrate: 96_000 },
dtx: false,
red: true,
screenShareEncoding: {
maxBitrate: 10_000_000,