Skip to content

Commit

Permalink
feat: improve splash screen and notification service
Browse files Browse the repository at this point in the history
  • Loading branch information
reyamir committed May 29, 2024
1 parent 32f3315 commit d2e5122
Show file tree
Hide file tree
Showing 20 changed files with 137 additions and 185 deletions.
Binary file removed apps/desktop2/public/heading-en.png
Binary file not shown.
Binary file removed apps/desktop2/public/[email protected]
Binary file not shown.
Binary file removed apps/desktop2/public/heading-fr.png
Binary file not shown.
Binary file removed apps/desktop2/public/[email protected]
Binary file not shown.
Binary file removed apps/desktop2/public/heading-ja.png
Binary file not shown.
Binary file removed apps/desktop2/public/[email protected]
Binary file not shown.
Binary file added apps/desktop2/public/icon.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed apps/desktop2/public/lock-screen.jpg
Binary file not shown.
Binary file removed apps/desktop2/public/[email protected]
Binary file not shown.
Binary file removed apps/desktop2/public/waifu.png
Binary file not shown.
Binary file removed apps/desktop2/public/[email protected]
Binary file not shown.
2 changes: 1 addition & 1 deletion apps/desktop2/src/routes/group.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export const Route = createFileRoute("/group")({
beforeLoad: async ({ search }) => {
const key = `lume_group_${search.label}`;
const groups = (await NostrQuery.getNstore(key)) as string[];
const settings = await NostrAccount.getAccounts();
const settings = await NostrQuery.getSettings();

if (!groups?.length) {
throw redirect({
Expand Down
44 changes: 13 additions & 31 deletions apps/desktop2/src/routes/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,22 @@ import { User } from "@/components/user";
import { checkForAppUpdates } from "@lume/utils";
import { Link } from "@tanstack/react-router";
import { createFileRoute, redirect } from "@tanstack/react-router";
import { invoke } from "@tauri-apps/api/core";
import { useState } from "react";
import { toast } from "sonner";
import { NostrAccount } from "@lume/system";

export const Route = createFileRoute("/")({
beforeLoad: async () => {
await checkForAppUpdates(true); // check for app updates
const accounts = await NostrAccount.getAccounts();

if (accounts.length < 1) {
throw redirect({
to: "/landing/",
to: "/landing",
replace: true,
});
}

await checkForAppUpdates(true); // check for app updates
await invoke("run_notification", { accounts }); // Run notification service

return { accounts };
},
component: Screen,
Expand Down Expand Up @@ -65,14 +62,16 @@ function Screen() {
return (
<div className="relative flex h-full w-full items-center justify-center">
<div className="relative z-20 flex flex-col items-center gap-16">
<div className="text-center text-white">
<h2 className="mb-1 text-2xl">{currentDate}</h2>
<div className="text-center">
<h2 className="text-xl text-neutral-700 dark:text-neutral-300">
{currentDate}
</h2>
<h2 className="text-2xl font-semibold">Welcome back!</h2>
</div>
<div className="flex flex-wrap px-3 items-center justify-center gap-6">
{loading ? (
<div className="inline-flex size-6 items-center justify-center">
<Spinner className="size-6 text-white" />
<Spinner className="size-6" />
</div>
) : (
<>
Expand All @@ -83,42 +82,25 @@ function Screen() {
onClick={() => select(account)}
>
<User.Provider pubkey={account}>
<User.Root className="flex h-36 w-32 flex-col items-center justify-center gap-4 rounded-2xl p-2 hover:bg-white/10 dark:hover:bg-black/10">
<User.Root className="flex h-36 w-32 flex-col items-center justify-center gap-3 rounded-2xl p-2 hover:bg-black/10 dark:hover:bg-white/10">
<User.Avatar className="size-20 rounded-full object-cover" />
<User.Name className="max-w-[5rem] truncate text-lg font-medium leading-tight text-white" />
<User.Name className="max-w-[6rem] truncate font-medium leading-tight" />
</User.Root>
</User.Provider>
</button>
))}
<Link to="/landing/">
<div className="flex h-36 w-32 flex-col items-center justify-center gap-4 rounded-2xl p-2 text-white hover:bg-white/10 dark:hover:bg-black/10">
<div className="flex size-20 items-center justify-center rounded-full bg-white/20 dark:bg-black/20">
<Link to="/landing">
<div className="flex h-36 w-32 flex-col items-center justify-center gap-3 rounded-2xl p-2 hover:bg-black/10 dark:hover:bg-white/10">
<div className="flex size-20 items-center justify-center rounded-full bg-black/5 dark:bg-white/5">
<PlusIcon className="size-8" />
</div>
<p className="text-lg font-medium leading-tight">Add</p>
<p className="font-medium leading-tight">Add</p>
</div>
</Link>
</>
)}
</div>
</div>
<div className="absolute z-10 h-full w-full bg-white/10 backdrop-blur-lg dark:bg-black/10" />
<div className="absolute inset-0 h-full w-full">
<img
src="/lock-screen.jpg"
srcSet="/[email protected] 2x"
alt="Lock Screen Background"
className="h-full w-full object-cover"
/>
<a
href="https://njump.me/nprofile1qqs9tuz9jpn57djg7nxunhyvuvk69g5zqaxdpvpqt9hwqv7395u9rpg6zq5uw"
target="_blank"
className="absolute bottom-3 right-3 z-50 rounded-md bg-white/20 px-2 py-1 text-xs font-medium text-white dark:bg-black/20"
rel="noreferrer"
>
Design by NoGood
</a>
</div>
</div>
);
}
62 changes: 62 additions & 0 deletions apps/desktop2/src/routes/landing.lazy.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import { KeyIcon, RemoteIcon } from "@lume/icons";
import { Link, createLazyFileRoute } from "@tanstack/react-router";

export const Route = createLazyFileRoute("/landing")({
component: Screen,
});

function Screen() {
return (
<div
data-tauri-drag-region
className="flex flex-col justify-center items-center h-screen w-screen"
>
<div className="mx-auto max-w-xs lg:max-w-md w-full">
<div className="flex w-full flex-col gap-2 bg-white rounded-xl shadow-primary backdrop-blur-lg dark:bg-white/20 dark:ring-1 ring-neutral-800/50 px-2">
<div className="h-20 flex items-center border-b border-neutral-100 dark:border-white/5">
<Link
to="/auth/new/profile"
className="h-14 w-full flex items-center justify-center gap-2 hover:bg-neutral-100 dark:hover:bg-white/10 rounded-lg px-2"
>
<div className="size-9 shrink-0 rounded-full inline-flex items-center justify-center">
<img
src="/icon.jpeg"
alt="App Icon"
className="size-9 object-cover rounded-full"
/>
</div>
<div className="flex-1 inline-flex flex-col">
<span className="leading-tight font-semibold">
Create new account
</span>
<span className="leading-tight text-sm text-neutral-500">
Use everywhere
</span>
</div>
</Link>
</div>
<div className="flex flex-col gap-1 pb-2.5">
<Link
to="/auth/privkey"
className="inline-flex h-11 w-full items-center gap-2 rounded-lg px-2 hover:bg-neutral-100 dark:hover:bg-white/10"
>
<div className="size-9 inline-flex items-center justify-center">
<KeyIcon className="size-5 text-neutral-600 dark:text-neutral-400" />
</div>
Login with Private Key
</Link>
<Link
to="/auth/remote"
className="inline-flex h-11 w-full items-center gap-2 rounded-lg px-2 hover:bg-neutral-100 dark:hover:bg-white/10"
>
<div className="size-9 inline-flex items-center justify-center">
<RemoteIcon className="size-5 text-neutral-600 dark:text-neutral-400" />
</div>
Nostr Connect
</Link>
</div>
</div>
</div>
</div>
);
}
85 changes: 0 additions & 85 deletions apps/desktop2/src/routes/landing/index.tsx

This file was deleted.

6 changes: 1 addition & 5 deletions packages/system/src/account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,7 @@ export class NostrAccount {
const query = await commands.getAccounts();

if (query.status === "ok") {
const accounts = query.data
.split(/\s+/)
.filter((v) => v.startsWith("npub1"));

return [...new Set(accounts)];
return query.data;
} else {
return [];
}
Expand Down
13 changes: 1 addition & 12 deletions packages/system/src/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export const commands = {
else return { status: "error", error: e as any };
}
},
async getAccounts(): Promise<Result<string, string>> {
async getAccounts(): Promise<Result<string[], string>> {
try {
return { status: "ok", data: await TAURI_INVOKE("get_accounts") };
} catch (e) {
Expand Down Expand Up @@ -150,17 +150,6 @@ export const commands = {
else return { status: "error", error: e as any };
}
},
async runNotification(accounts: string[]): Promise<Result<null, null>> {
try {
return {
status: "ok",
data: await TAURI_INVOKE("run_notification", { accounts }),
};
} catch (e) {
if (e instanceof Error) throw e;
else return { status: "error", error: e as any };
}
},
async getActivities(
account: string,
kind: string,
Expand Down
1 change: 0 additions & 1 deletion src-tauri/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ fn main() {
nostr::keys::user_to_bech32,
nostr::keys::to_npub,
nostr::keys::verify_nip05,
nostr::metadata::run_notification,
nostr::metadata::get_activities,
nostr::metadata::get_current_user_profile,
nostr::metadata::get_profile,
Expand Down
Loading

0 comments on commit d2e5122

Please sign in to comment.