feat: migrate frontend to new backend

This commit is contained in:
2024-02-08 21:24:08 +07:00
parent 17052aeeaa
commit ec78cf8bf7
34 changed files with 478 additions and 650 deletions

View File

@@ -29,7 +29,7 @@ export function ActiveAccount() {
<div className="relative">
<Avatar.Root>
<Avatar.Image
src={user?.picture || user?.image}
src={user?.picture}
alt={ark.account.pubkey}
loading="lazy"
decoding="async"

View File

@@ -4,6 +4,7 @@ import { useStorage } from "@lume/storage";
import { NDKCacheUserProfile } from "@lume/types";
import { COL_TYPES, cn, editorValueAtom } from "@lume/utils";
import { NDKEvent, NDKKind } from "@nostr-dev-kit/ndk";
import { invoke } from "@tauri-apps/api/core";
import { useAtom } from "jotai";
import { useEffect, useRef, useState } from "react";
import { useTranslation } from "react-i18next";
@@ -187,8 +188,6 @@ const Element = (props) => {
};
export function EditorForm() {
const ark = useArk();
const storage = useStorage();
const ref = useRef<HTMLDivElement | null>();
const [editorValue, setEditorValue] = useAtom(editorValueAtom);
@@ -202,7 +201,6 @@ export function EditorForm() {
);
const { t } = useTranslation();
const { addColumn } = useColumnContext();
const filters = contacts
?.filter((c) => c?.name?.toLowerCase().startsWith(search.toLowerCase()))
@@ -242,32 +240,24 @@ export function EditorForm() {
try {
setLoading(true);
const event = new NDKEvent(ark.ndk);
event.kind = NDKKind.Text;
event.content = serialize(editor.children);
const publish = await event.publish();
const content = serialize(editor.children);
const publish = await invoke("publish", { content });
if (publish) {
console.log(publish);
toast.success(t("editor.successMessage"));
// add current post as column thread
addColumn({
kind: COL_TYPES.thread,
content: event.id,
title: "Thread",
});
setLoading(false);
return reset();
}
setLoading(false);
} catch (e) {
setLoading(false);
toast.error(String(e));
}
};
/*
useEffect(() => {
async function loadContacts() {
const res = await storage.getAllCacheUsers();
@@ -276,6 +266,7 @@ export function EditorForm() {
loadContacts();
}, []);
*/
useEffect(() => {
if (target && filters.length > 0) {

View File

@@ -1,4 +1,4 @@
import { Note, User, useArk, useColumnContext } from "@lume/ark";
import { Note, User, useArk } from "@lume/ark";
import { LoaderIcon, SearchIcon } from "@lume/icons";
import { COL_TYPES, searchAtom } from "@lume/utils";
import { type NDKEvent, NDKKind } from "@nostr-dev-kit/ndk";
@@ -18,7 +18,6 @@ export function SearchDialog() {
const [value] = useDebounce(search, 1200);
const { t } = useTranslation();
const { vlistRef, columns, addColumn } = useColumnContext();
const searchEvents = async () => {
if (!value.length) return;