Skip to content

Commit

Permalink
feat: polish on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
reyamir committed Jan 27, 2024
1 parent b11e2a4 commit 8295625
Show file tree
Hide file tree
Showing 11 changed files with 48 additions and 178 deletions.
6 changes: 5 additions & 1 deletion apps/desktop/src/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
}

.shadow-toolbar {
box-shadow: 0 0 #0000,0 0 #0000,0 8px 24px 0 rgba(0,0,0,.2),0 2px 8px 0 rgba(0,0,0,.08),inset 0 0 0 1px rgba(0,0,0,.2),inset 0 0 0 2px hsla(0,0%,100%,.14)
box-shadow: 0 0 #0000, 0 0 #0000, 0 8px 24px 0 rgba(0, 0, 0, .2), 0 2px 8px 0 rgba(0, 0, 0, .08), inset 0 0 0 1px rgba(0, 0, 0, .2), inset 0 0 0 2px hsla(0, 0%, 100%, .14)
}
}

Expand Down Expand Up @@ -42,3 +42,7 @@ input::-ms-clear {
.border {
background-clip: padding-box;
}

media-controller {
@apply w-full;
}
2 changes: 0 additions & 2 deletions packages/ark/src/components/note/preview/video.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import {
MediaPlayButton,
MediaTimeDisplay,
MediaTimeRange,
MediaVolumeRange,
} from "media-chrome/dist/react";

export function VideoPreview({ url }: { url: string }) {
Expand All @@ -24,7 +23,6 @@ export function VideoPreview({ url }: { url: string }) {
<MediaTimeRange />
<MediaTimeDisplay showDuration />
<MediaMuteButton />
<MediaVolumeRange />
</MediaControlBar>
</MediaController>
</div>
Expand Down
9 changes: 8 additions & 1 deletion packages/ark/src/components/user/followButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,15 @@ export function UserFollowButton({
const [followed, setFollowed] = useState(false);

const toggleFollow = async () => {
setLoading(true);
if (!followed) {
const add = await ark.createContact(target);
if (add) setFollowed(true);
} else {
const remove = await ark.deleteContact(target);
if (remove) setFollowed(false);
}
setLoading(false);
};

useEffect(() => {
Expand All @@ -37,7 +39,12 @@ export function UserFollowButton({
}, []);

return (
<button type="button" onClick={toggleFollow} className={cn("", className)}>
<button
type="button"
disabled={loading}
onClick={toggleFollow}
className={cn("", className)}
>
{loading ? (
<LoaderIcon className="size-4 animate-spin" />
) : followed ? (
Expand Down
2 changes: 1 addition & 1 deletion packages/ark/src/components/user/name.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export function UserName({ className }: { className?: string }) {
return (
<div
className={cn(
"h-4 w-20 bg-black/20 dark:bg-white/20 rounded animate-pulse",
"h-4 w-20 self-center bg-black/20 dark:bg-white/20 rounded animate-pulse",
className,
)}
/>
Expand Down
3 changes: 2 additions & 1 deletion packages/ark/src/provider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ export const LumeProvider = ({ children }: PropsWithChildren<object>) => {
const explicitRelayUrls = normalizeRelayUrlSet([
"wss://nostr.mutinywallet.com/",
"wss://bostr.nokotaro.com/",
"wss://purplepag.es/",
]);

const outboxRelayUrls = normalizeRelayUrlSet(["wss://purplepag.es/"]);
Expand Down Expand Up @@ -227,7 +228,7 @@ export const LumeProvider = ({ children }: PropsWithChildren<object>) => {
return (
<div
data-tauri-drag-region
className="relative flex items-center justify-center w-screen h-screen bg-neutral-50 dark:bg-neutral-950"
className="relative flex items-center justify-center w-screen h-screen"
>
<div className="flex flex-col items-start max-w-2xl gap-1">
<h5 className="font-semibold uppercase">TIP:</h5>
Expand Down
22 changes: 11 additions & 11 deletions packages/lume-column-timeline/src/home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,18 +50,7 @@ export function HomeRoute({ colKey }: { colKey: string }) {
if (!lastEvent) return;
return lastEvent.created_at - 1;
},
initialData: () => {
const queryCacheData = queryClient.getQueryState([colKey])
?.data as NDKEvent[];
if (queryCacheData) {
return {
pageParams: [undefined, 1],
pages: [queryCacheData],
};
}
},
select: (data) => data?.pages.flatMap((page) => page),
staleTime: 120 * 1000,
refetchOnWindowFocus: false,
refetchOnMount: false,
});
Expand Down Expand Up @@ -115,6 +104,17 @@ export function HomeRoute({ colKey }: { colKey: string }) {
<div className="w-full flex h-16 items-center justify-center gap-2 px-3 py-1.5">
<LoaderIcon className="size-5 animate-spin" />
</div>
) : !data.length ? (
<div className="px-3 mt-3">
<EmptyFeed />
<Link
to="/suggest"
className="mt-3 w-full gap-2 inline-flex items-center justify-center text-sm font-medium rounded-lg h-9 bg-blue-500 hover:bg-blue-600 text-white"
>
<SearchIcon className="size-5" />
Find accounts to follow
</Link>
</div>
) : (
data.map((item) => renderItem(item))
)}
Expand Down
8 changes: 5 additions & 3 deletions packages/ui/src/onboarding/finish.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { useArk } from "@lume/ark";
import { CheckIcon, LoaderIcon } from "@lume/icons";
import { useStorage } from "@lume/storage";
import { onboardingAtom } from "@lume/utils";
import { useQueryClient } from "@tanstack/react-query";
import { motion } from "framer-motion";
import { useSetAtom } from "jotai";
import { useState } from "react";

export function OnboardingFinishScreen() {
const storage = useStorage();
const queryClient = useQueryClient();
const setOnboarding = useSetAtom(onboardingAtom);

Expand All @@ -15,8 +16,9 @@ export function OnboardingFinishScreen() {
const finish = async () => {
setLoading(true);

await queryClient.refetchQueries({ queryKey: ["timeline-9999"] });
await queryClient.refetchQueries({ queryKey: ["foryou-9998"] });
if (storage.interests) {
await queryClient.invalidateQueries({ queryKey: ["foryou-9998"] });
}

setLoading(false);
setOnboarding({ open: false, newUser: false });
Expand Down
7 changes: 4 additions & 3 deletions packages/ui/src/onboarding/interest.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,10 @@ export function OnboardingInterestScreen() {
JSON.stringify({ hashtags }),
);

setLoading(false);

if (save) return navigate("/finish");
if (save) {
storage.interests = { hashtags, users: [], words: [] };
return navigate("/finish");
}
} catch (e) {
setLoading(false);
toast.error(String(e));
Expand Down
80 changes: 11 additions & 69 deletions packages/ui/src/routes/suggest.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,6 @@
import { User, useArk } from "@lume/ark";
import {
ArrowLeftIcon,
ArrowRightIcon,
CancelIcon,
LoaderIcon,
PlusIcon,
} from "@lume/icons";
import { cn } from "@lume/utils";
import { User } from "@lume/ark";
import { ArrowLeftIcon, ArrowRightIcon, LoaderIcon } from "@lume/icons";
import { useQuery, useQueryClient } from "@tanstack/react-query";
import { nip19 } from "nostr-tools";
import { useState } from "react";
import { useNavigate } from "react-router-dom";
import { toast } from "sonner";
import { WindowVirtualizer } from "virtua";
Expand All @@ -34,7 +25,6 @@ const LUME_USERS = [
];

export function SuggestRoute({ queryKey }: { queryKey: string[] }) {
const ark = useArk();
const queryClient = useQueryClient();
const navigate = useNavigate();

Expand All @@ -51,40 +41,11 @@ export function SuggestRoute({ queryKey }: { queryKey: string[] }) {
},
});

const [loading, setLoading] = useState(false);
const [follows, setFollows] = useState<string[]>([]);

// toggle follow state
const toggleFollow = (pubkey: string) => {
const arr = follows.includes(pubkey)
? follows.filter((i) => i !== pubkey)
: [...follows, pubkey];
setFollows(arr);
};

const submit = async () => {
try {
setLoading(true);

if (!follows.length) return navigate("/");

const publish = await ark.newContactList({
tags: follows.map((item) => {
if (item.startsWith("npub1"))
return ["p", nip19.decode(item).data as string];
return ["p", item];
}),
});

if (publish) {
await queryClient.refetchQueries({ queryKey: ["timeline-9999"] });
}

setLoading(false);

return navigate("/");
await queryClient.refetchQueries({ queryKey });
return navigate("/", { replace: true });
} catch (e) {
setLoading(false);
toast.error(String(e));
}
};
Expand Down Expand Up @@ -135,30 +96,12 @@ export function SuggestRoute({ queryKey }: { queryKey: string[] }) {
<User.Avatar className="size-10 shrink-0 rounded-lg" />
<User.Name className="max-w-[15rem] truncate font-semibold leadning-tight" />
</div>
<button
type="button"
onClick={() => toggleFollow(item.pubkey)}
className={cn(
"inline-flex h-8 shrink-0 pl-2 pr-2.5 items-center justify-center gap-1 rounded-lg text-sm font-medium",
follows.includes(item.pubkey)
? "text-red-500 bg-red-100 hover:text-white hover:bg-red-500"
: "text-blue-500 bg-blue-100 hover:text-white hover:bg-blue-500",
)}
>
{follows.includes(item.pubkey) ? (
<>
<CancelIcon className="size-4" />
Unfollow
</>
) : (
<>
<PlusIcon className="size-4" />
Follow
</>
)}
</button>
<User.Button
target={item.pubkey}
className="w-20 h-8 text-sm font-medium bg-neutral-100 dark:bg-neutral-900 hover:bg-neutral-200 dark:hover:bg-neutral-800 rounded-lg inline-flex items-center justify-center"
/>
</div>
<User.About className="break-p text-neutral-800 dark:text-neutral-400 max-w-none select-text whitespace-pre-line" />
<User.About className="mt-1 line-clamp-3 text-neutral-800 dark:text-neutral-400 max-w-none select-text" />
</div>
</User.Root>
</User.Provider>
Expand All @@ -170,10 +113,9 @@ export function SuggestRoute({ queryKey }: { queryKey: string[] }) {
<button
type="button"
onClick={submit}
disabled={loading}
className="inline-flex items-center justify-center gap-2 px-6 font-medium shadow-xl shadow-neutral-500/50 text-white transform bg-blue-500 rounded-full active:translate-y-1 w-36 h-11 hover:bg-blue-600 focus:outline-none disabled:cursor-not-allowed"
className="inline-flex items-center justify-center gap-2 px-6 font-medium shadow-xl dark:shadow-none shadow-neutral-500/50 text-white transform bg-blue-500 rounded-full active:translate-y-1 w-44 h-11 hover:bg-blue-600 focus:outline-none disabled:cursor-not-allowed"
>
Save & Go Back
Save & Go back
</button>
</div>
</div>
Expand Down
35 changes: 1 addition & 34 deletions packages/utils/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export const NOSTR_EVENTS = [
"Nostr:nevent1",
];

// const BITCOINS = ['lnbc', 'bc1p', 'bc1q'];
export const BITCOINS = ['lnbc', 'bc1p', 'bc1q'];

export const IMAGES = ["jpg", "jpeg", "gif", "png", "webp", "avif", "tiff"];

Expand All @@ -45,37 +45,6 @@ export const VIDEOS = [

export const AUDIOS = ["mp3", "ogg", "wav"];

export const HASHTAGS = [
{ hashtag: "#food" },
{ hashtag: "#gaming" },
{ hashtag: "#nsfw" },
{ hashtag: "#bitcoin" },
{ hashtag: "#nostr" },
{ hashtag: "#nostrdesign" },
{ hashtag: "#security" },
{ hashtag: "#zap" },
{ hashtag: "#LFG" },
{ hashtag: "#zapchain" },
{ hashtag: "#shitcoin" },
{ hashtag: "#plebchain" },
{ hashtag: "#nodes" },
{ hashtag: "#hodl" },
{ hashtag: "#stacksats" },
{ hashtag: "#nokyc" },
{ hashtag: "#meme" },
{ hashtag: "#memes" },
{ hashtag: "#memestr" },
{ hashtag: "#nostriches" },
{ hashtag: "#dev" },
{ hashtag: "#anime" },
{ hashtag: "#waifu" },
{ hashtag: "#manga" },
{ hashtag: "#lume" },
{ hashtag: "#snort" },
{ hashtag: "#damus" },
{ hashtag: "#primal" },
];

export const COL_TYPES = {
default: 0,
user: 1,
Expand Down Expand Up @@ -173,7 +142,6 @@ export const TOPICS = [
"#pcgaming",
"#nintendo",
"#switch",
"#pubg",
"#esports",
"#gameoftheyear",
"#darksoul",
Expand Down Expand Up @@ -326,7 +294,6 @@ export const TOPICS = [
"#fashion",
"#travel",
"#photoshoot",
"#nature",
"#naturephotography",
"#smile",
"#style",
Expand Down
Loading

0 comments on commit 8295625

Please sign in to comment.