Skip to content

Commit d18de93

Browse files
authored
Merge pull request #148 from luminous-devs/feat/improve-perf
Improve overall performance
2 parents 06674df + df15eb7 commit d18de93

File tree

14 files changed

+178
-271
lines changed

14 files changed

+178
-271
lines changed

apps/desktop/src/app.css

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
}
1515

1616
.shadow-toolbar {
17-
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)
17+
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)
1818
}
1919
}
2020

@@ -42,3 +42,7 @@ input::-ms-clear {
4242
.border {
4343
background-clip: padding-box;
4444
}
45+
46+
media-controller {
47+
@apply w-full;
48+
}

packages/ark/src/ark.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,6 @@ export class Ark {
145145
cacheUsage: NDKSubscriptionCacheUsage.CACHE_FIRST,
146146
});
147147

148-
if (!profile) return null;
149148
return profile;
150149
} catch {
151150
throw new Error("user not found");
@@ -167,8 +166,9 @@ export class Ark {
167166
(user) => user.pubkey,
168167
);
169168

170-
if (!pubkey || pubkey === this.account.pubkey)
169+
if (!pubkey || pubkey === this.account.pubkey) {
171170
this.account.contacts = contacts;
171+
}
172172

173173
return contacts;
174174
} catch (e) {

packages/ark/src/components/note/preview/video.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import {
55
MediaPlayButton,
66
MediaTimeDisplay,
77
MediaTimeRange,
8-
MediaVolumeRange,
98
} from "media-chrome/dist/react";
109

1110
export function VideoPreview({ url }: { url: string }) {
@@ -24,7 +23,6 @@ export function VideoPreview({ url }: { url: string }) {
2423
<MediaTimeRange />
2524
<MediaTimeDisplay showDuration />
2625
<MediaMuteButton />
27-
<MediaVolumeRange />
2826
</MediaControlBar>
2927
</MediaController>
3028
</div>

packages/ark/src/components/user/avatar.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,18 @@ export function UserAvatar({ className }: { className?: string }) {
3939
alt={user.pubkey}
4040
loading="eager"
4141
decoding="async"
42-
className={cn("bg-black dark:bg-white", className)}
42+
className={cn(
43+
"bg-black dark:bg-white ring-1 ring-black/5 dark:ring-white/5",
44+
className,
45+
)}
4346
/>
4447
) : (
4548
<Avatar.Image
4649
src={user.image}
4750
alt={user.pubkey}
4851
loading="eager"
4952
decoding="async"
50-
className={className}
53+
className={cn("ring-1 ring-black/5 dark:ring-white/5", className)}
5154
/>
5255
)}
5356
<Avatar.Fallback delayMs={120}>

packages/ark/src/components/user/followButton.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,15 @@ export function UserFollowButton({
1313
const [followed, setFollowed] = useState(false);
1414

1515
const toggleFollow = async () => {
16+
setLoading(true);
1617
if (!followed) {
1718
const add = await ark.createContact(target);
1819
if (add) setFollowed(true);
1920
} else {
2021
const remove = await ark.deleteContact(target);
2122
if (remove) setFollowed(false);
2223
}
24+
setLoading(false);
2325
};
2426

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

3941
return (
40-
<button type="button" onClick={toggleFollow} className={cn("", className)}>
42+
<button
43+
type="button"
44+
disabled={loading}
45+
onClick={toggleFollow}
46+
className={cn("", className)}
47+
>
4148
{loading ? (
4249
<LoaderIcon className="size-4 animate-spin" />
4350
) : followed ? (

packages/ark/src/components/user/name.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export function UserName({ className }: { className?: string }) {
88
return (
99
<div
1010
className={cn(
11-
"h-4 w-20 bg-black/20 dark:bg-white/20 rounded animate-pulse",
11+
"h-4 w-20 self-center bg-black/20 dark:bg-white/20 rounded animate-pulse",
1212
className,
1313
)}
1414
/>

packages/ark/src/hooks/useProfile.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
import { useQuery } from "@tanstack/react-query";
1+
import { useQuery, useQueryClient } from "@tanstack/react-query";
22
import { useArk } from "./useArk";
33

44
export function useProfile(pubkey: string) {
55
const ark = useArk();
6+
const queryClient = useQueryClient();
7+
68
const {
79
isLoading,
810
isError,
@@ -17,6 +19,9 @@ export function useProfile(pubkey: string) {
1719
);
1820
return profile;
1921
},
22+
initialData: () => {
23+
return queryClient.getQueryData(["user", pubkey]);
24+
},
2025
refetchOnMount: false,
2126
refetchOnWindowFocus: false,
2227
refetchOnReconnect: false,

0 commit comments

Comments
 (0)