Working send and updated account structure

This commit is contained in:
2026-08-20 11:24:59 +02:00
parent 9c448049bc
commit cce9756a1b
8 changed files with 28 additions and 16 deletions
+1
View File
@@ -5,6 +5,7 @@
"type": "module", "type": "module",
"scripts": { "scripts": {
"dev": "vite", "dev": "vite",
"typecheck": "tsc --noEmit",
"build": "tsc && vite build", "build": "tsc && vite build",
"preview": "vite preview", "preview": "vite preview",
"tauri": "tauri" "tauri": "tauri"
+3 -2
View File
@@ -2,11 +2,12 @@ use serde::{Deserialize, Serialize};
use std::fs; use std::fs;
use tauri::{AppHandle, Manager}; use tauri::{AppHandle, Manager};
use crate::protocol::ClientMeta;
#[derive(Debug, Clone, Serialize, Deserialize)] #[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
pub struct Account { pub struct Account {
pub display_name: String, pub meta: ClientMeta,
pub avatar: Option<String>,
pub private_key: String, pub private_key: String,
} }
+6 -1
View File
@@ -3,9 +3,14 @@ use std::borrow::Cow;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Serialize, Deserialize)] #[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ClientMeta {} #[serde(rename_all = "camelCase")]
pub struct ClientMeta {
pub display_name: String,
pub avatar: Option<String>,
}
#[derive(Debug, Clone, Serialize, Deserialize)] #[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ServerMeta { pub struct ServerMeta {
pub name: String, pub name: String,
pub description: String, pub description: String,
+6 -1
View File
@@ -62,8 +62,13 @@ export default class Enclave<P = Page> {
const timestamp = Date.now(); const timestamp = Date.now();
if (!this.server?.serverPublicKey) {
console.error("Server pubkey not initialized");
return;
}
const signature = new TextEncoder().encode( const signature = new TextEncoder().encode(
`${timestamp}@${this.server?.hostname}@${content}`, `${timestamp}@${base58.encode(this.server?.serverPublicKey)}@${content}`,
); );
this.server?.websocket?.send({ this.server?.websocket?.send({
+1 -1
View File
@@ -1,6 +1,6 @@
import Enclave from "@/app/app"; import Enclave from "@/app/app";
import ChannelPage from "./channel/ChannelPage"; import ChannelPage from "./channel/ChannelPage";
import { Channel } from "@/app/protocol"; import { Channel } from "@/lib/types";
export type ChannelPageProps = { export type ChannelPageProps = {
kind: "channel"; kind: "channel";
+3 -3
View File
@@ -20,8 +20,8 @@ export default function AccountCard({
<Card className="px-3 py-3 h-full w-full flex flex-row"> <Card className="px-3 py-3 h-full w-full flex flex-row">
<div className="flex gap-2.5 items-center w-full"> <div className="flex gap-2.5 items-center w-full">
<Avatar className="h-full w-auto aspect-square"> <Avatar className="h-full w-auto aspect-square">
<AvatarImage src={account.avatar} /> <AvatarImage src={account.meta.avatar} />
<AvatarFallback>{account.displayName[0]}</AvatarFallback> <AvatarFallback>{account.meta.displayName[0]}</AvatarFallback>
</Avatar> </Avatar>
<div className="flex flex-col w-full"> <div className="flex flex-col w-full">
<span <span
@@ -34,7 +34,7 @@ export default function AccountCard({
); );
}} }}
> >
<p>{account.displayName}</p> <p>{account.meta.displayName}</p>
<CopyIcon className="text-muted-foreground size-3" /> <CopyIcon className="text-muted-foreground size-3" />
</span> </span>
<span className="text-muted-foreground">Online</span> <span className="text-muted-foreground">Online</span>
+7 -7
View File
@@ -68,16 +68,16 @@ export function NewProfilePage({
const { secretKey } = ed.keygen(); const { secretKey } = ed.keygen();
const newAccount = {
displayName: name,
privateKey: base58.encode(secretKey),
avatar: avatar ?? undefined,
};
appRef.current.accounts.activeAccount = appRef.current.accounts.activeAccount =
appRef.current.accounts.accounts.length; appRef.current.accounts.accounts.length;
appRef.current.accounts.accounts.push(newAccount); appRef.current.accounts.accounts.push({
meta: {
displayName: name,
avatar: avatar ?? undefined,
},
privateKey: base58.encode(secretKey),
});
saveAccounts(appRef.current.accounts); saveAccounts(appRef.current.accounts);
} catch (e) { } catch (e) {
+1 -1
View File
@@ -1,5 +1,5 @@
import Enclave from "@/app/app"; import Enclave from "@/app/app";
import { Channel, ChannelKind } from "@/app/protocol"; import { Channel, ChannelKind } from "@/lib/types";
import { ChevronDown, ChevronUp, HashIcon } from "lucide-react"; import { ChevronDown, ChevronUp, HashIcon } from "lucide-react";
import { useState } from "react"; import { useState } from "react";
import AccountCard from "./AccountCard"; import AccountCard from "./AccountCard";