mirror of
https://github.com/urbit/shrub.git
synced 2024-12-19 16:51:42 +03:00
interface: add utilities, fix useLazyScroll
This commit is contained in:
parent
86552306c2
commit
08028efcd7
@ -41,6 +41,12 @@ export function useLazyScroll(
|
||||
}
|
||||
}, [count]);
|
||||
|
||||
useEffect(() => {
|
||||
if(!ready) {
|
||||
setIsDone(false);
|
||||
}
|
||||
}, [ready]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!ref.current || isDone || !ready) {
|
||||
return;
|
||||
@ -58,7 +64,7 @@ export function useLazyScroll(
|
||||
return () => {
|
||||
ref.current?.removeEventListener('scroll', onScroll);
|
||||
};
|
||||
}, [ref?.current, count, ready]);
|
||||
}, [ref?.current, ready, isDone]);
|
||||
|
||||
return { isDone, isLoading };
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ export function useRunIO<I, O>(
|
||||
io: (i: I) => Promise<O>,
|
||||
after: (o: O) => void,
|
||||
key: string
|
||||
) {
|
||||
): () => Promise<void> {
|
||||
const [resolve, setResolve] = useState<() => void>(() => () => {});
|
||||
const [reject, setReject] = useState<(e: any) => void>(() => () => {});
|
||||
const [output, setOutput] = useState<O | null>(null);
|
||||
|
@ -63,6 +63,16 @@ export function unixToDa(unix: number) {
|
||||
return DA_UNIX_EPOCH.add(timeSinceEpoch);
|
||||
}
|
||||
|
||||
export function dmCounterparty(resource: string) {
|
||||
const [,,ship,name] = resource.split('/');
|
||||
return ship === `~${window.ship}` ? `~${name.slice(4)}` : ship;
|
||||
}
|
||||
|
||||
export function isDm(resource: string) {
|
||||
const [,,,name] = resource.split('/');
|
||||
return name.startsWith('dm--');
|
||||
}
|
||||
|
||||
export function makePatDa(patda: string) {
|
||||
return bigInt(udToDec(patda));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user