From 5ab5d8f12f800c99152cc44381185b662d45c887 Mon Sep 17 00:00:00 2001 From: Dhravya Date: Tue, 11 Jun 2024 19:14:37 -0500 Subject: [PATCH] minor changes and improvements --- apps/web/app/(auth)/signin/page.tsx | 19 +-- apps/web/app/(canvas)/lib/createAssetUrl.ts | 149 +++++++++++--------- apps/web/app/(dash)/dynamicisland.tsx | 1 + apps/web/app/(editor)/components/topbar.tsx | 32 +---- apps/web/package.json | 3 +- apps/web/wrangler.toml | 4 +- 6 files changed, 104 insertions(+), 104 deletions(-) diff --git a/apps/web/app/(auth)/signin/page.tsx b/apps/web/app/(auth)/signin/page.tsx index 91cad757..ba84a94a 100644 --- a/apps/web/app/(auth)/signin/page.tsx +++ b/apps/web/app/(auth)/signin/page.tsx @@ -11,11 +11,7 @@ async function Signin() {
- SuperMemory logo + SuperMemory logo SuperMemory.ai
@@ -28,7 +24,7 @@ async function Signin() {

{ @@ -40,12 +36,10 @@ async function Signin() { > @@ -55,7 +49,8 @@ async function Signin() {
Terms of Service - | + {" "} + | {" "} Privacy Policy diff --git a/apps/web/app/(canvas)/lib/createAssetUrl.ts b/apps/web/app/(canvas)/lib/createAssetUrl.ts index be2999db..05c2baea 100644 --- a/apps/web/app/(canvas)/lib/createAssetUrl.ts +++ b/apps/web/app/(canvas)/lib/createAssetUrl.ts @@ -1,73 +1,94 @@ -import { AssetRecordType, TLAsset, getHashForString, truncateStringWithEllipsis } from 'tldraw' +import { + AssetRecordType, + TLAsset, + getHashForString, + truncateStringWithEllipsis, +} from "tldraw"; // import { BOOKMARK_ENDPOINT } from './config' interface ResponseBody { - title?: string - description?: string - image?: string + title?: string; + description?: string; + image?: string; } -export async function createAssetFromUrl({ url }: { type: 'url'; url: string }): Promise { - // try { - // // First, try to get the meta data from our endpoint - // const meta = (await ( - // await fetch(BOOKMARK_ENDPOINT, { - // method: 'POST', - // headers: { - // 'Content-Type': 'application/json', - // }, - // body: JSON.stringify({ - // url, - // }), - // }) - // ).json()) as ResponseBody +export async function createAssetFromUrl({ + url, +}: { + type: "url"; + url: string; +}): Promise { + // try { + // // First, try to get the meta data from our endpoint + // const meta = (await ( + // await fetch(BOOKMARK_ENDPOINT, { + // method: 'POST', + // headers: { + // 'Content-Type': 'application/json', + // }, + // body: JSON.stringify({ + // url, + // }), + // }) + // ).json()) as ResponseBody - // return { - // id: AssetRecordType.createId(getHashForString(url)), - // typeName: 'asset', - // type: 'bookmark', - // props: { - // src: url, - // description: meta.description ?? '', - // image: meta.image ?? '', - // title: meta.title ?? truncateStringWithEllipsis(url, 32), - // }, - // meta: {}, - // } - // } catch (error) { - // Otherwise, fallback to fetching data from the url + // return { + // id: AssetRecordType.createId(getHashForString(url)), + // typeName: 'asset', + // type: 'bookmark', + // props: { + // src: url, + // description: meta.description ?? '', + // image: meta.image ?? '', + // title: meta.title ?? truncateStringWithEllipsis(url, 32), + // }, + // meta: {}, + // } + // } catch (error) { + // Otherwise, fallback to fetching data from the url - let meta: { image: string; title: string; description: string } + let meta: { image: string; title: string; description: string }; - try { - const resp = await fetch(url, { method: 'GET', mode: 'no-cors' }) - const html = await resp.text() - const doc = new DOMParser().parseFromString(html, 'text/html') - meta = { - image: doc.head.querySelector('meta[property="og:image"]')?.getAttribute('content') ?? '', - title: - doc.head.querySelector('meta[property="og:title"]')?.getAttribute('content') ?? - truncateStringWithEllipsis(url, 32), - description: - doc.head.querySelector('meta[property="og:description"]')?.getAttribute('content') ?? '', - } - } catch (error) { - console.error(error) - meta = { image: '', title: truncateStringWithEllipsis(url, 32), description: '' } - } + try { + const resp = await fetch(url, { method: "GET", mode: "no-cors" }); + const html = await resp.text(); + const doc = new DOMParser().parseFromString(html, "text/html"); + meta = { + image: + doc.head + .querySelector('meta[property="og:image"]') + ?.getAttribute("content") ?? "", + title: + doc.head + .querySelector('meta[property="og:title"]') + ?.getAttribute("content") ?? truncateStringWithEllipsis(url, 32), + description: + doc.head + .querySelector('meta[property="og:description"]') + ?.getAttribute("content") ?? "", + }; + } catch (error) { + console.error(error); + meta = { + image: "", + title: truncateStringWithEllipsis(url, 32), + description: "", + }; + } - // Create the bookmark asset from the meta - return { - id: AssetRecordType.createId(getHashForString(url)), - typeName: 'asset', - type: 'bookmark', - props: { - src: url, - image: meta.image, - title: meta.title, - description: meta.description, - }, - meta: {}, - } - // } -} \ No newline at end of file + // Create the bookmark asset from the meta + return { + id: AssetRecordType.createId(getHashForString(url)), + typeName: "asset", + type: "bookmark", + props: { + src: url, + image: meta.image, + title: meta.title, + description: meta.description, + favicon: meta.image, + }, + meta: {}, + }; + // } +} diff --git a/apps/web/app/(dash)/dynamicisland.tsx b/apps/web/app/(dash)/dynamicisland.tsx index cfe799af..b703d55a 100644 --- a/apps/web/app/(dash)/dynamicisland.tsx +++ b/apps/web/app/(dash)/dynamicisland.tsx @@ -68,6 +68,7 @@ function DynamicIslandContent() { if (e.key === "Escape") { setshow(true); } + console.log(e.key, lastBtn.current); if (e.key === "a" && lastBtn.current === "Alt") { setshow(false); } diff --git a/apps/web/app/(editor)/components/topbar.tsx b/apps/web/app/(editor)/components/topbar.tsx index 1178f9a0..49b5179c 100644 --- a/apps/web/app/(editor)/components/topbar.tsx +++ b/apps/web/app/(editor)/components/topbar.tsx @@ -1,29 +1,5 @@ "use client"; - - - - - - - - - - - - - - - - - - - - - - - - import { AnimatePresence, useMotionValueEvent, @@ -32,7 +8,13 @@ import { } from "framer-motion"; import React, { useState } from "react"; -function Topbar({charsCount, saveStatus}: {charsCount: number | undefined; saveStatus: string}) { +function Topbar({ + charsCount, + saveStatus, +}: { + charsCount: number | undefined; + saveStatus: string; +}) { const [visible, setVisible] = useState(true); const { scrollYProgress } = useScroll(); diff --git a/apps/web/package.json b/apps/web/package.json index 0f25e203..324f5655 100644 --- a/apps/web/package.json +++ b/apps/web/package.json @@ -10,7 +10,8 @@ "cf-typegen": "wrangler types --env-interface CloudflareEnv env.d.ts", "pages:build": "bunx @cloudflare/next-on-pages", "preview": "bun pages:build && wrangler pages dev", - "deploy": "bun pages:build && wrangler pages deploy" + "deploy": "bun pages:build && wrangler pages deploy", + "schema-update": "bunx drizzle-orm" }, "dependencies": { "@million/lint": "^1.0.0-rc.11", diff --git a/apps/web/wrangler.toml b/apps/web/wrangler.toml index 18cd485f..e651069e 100644 --- a/apps/web/wrangler.toml +++ b/apps/web/wrangler.toml @@ -12,8 +12,8 @@ bucket_name = "dev-r2-anycontext" [[d1_databases]] binding = "DATABASE" -database_name = "prod-d1-tutorial" -database_id = "325fe40a-bdfc-43ec-837b-021bbcc570e8" +database_name = "dev-d1-anycontext" +database_id = "fc562605-157a-4f60-b439-2a24ffed5b4c" # [[unsafe.bindings]] # name = "RATELIMITER"