Add prettier formatting (#214)
* chore: add prettier * chore: format codebase
This commit is contained in:
@ -16,7 +16,7 @@ function useHorizontalScroll() {
|
||||
return () => el.removeEventListener("wheel", onWheel);
|
||||
}
|
||||
}, []);
|
||||
return elRef as LegacyRef<HTMLDivElement> | undefined
|
||||
return elRef as LegacyRef<HTMLDivElement> | undefined;
|
||||
}
|
||||
|
||||
export default useHorizontalScroll;
|
||||
|
@ -5,74 +5,93 @@ import { HexKey } from "Nostr";
|
||||
import useEventPublisher from "Feed/EventPublisher";
|
||||
import { setMuted, setBlocked } from "State/Login";
|
||||
|
||||
|
||||
export default function useModeration() {
|
||||
const dispatch = useDispatch()
|
||||
const { blocked, muted } = useSelector((s: RootState) => s.login)
|
||||
const publisher = useEventPublisher()
|
||||
const dispatch = useDispatch();
|
||||
const { blocked, muted } = useSelector((s: RootState) => s.login);
|
||||
const publisher = useEventPublisher();
|
||||
|
||||
async function setMutedList(pub: HexKey[], priv: HexKey[]) {
|
||||
try {
|
||||
const ev = await publisher.muted(pub, priv)
|
||||
const ev = await publisher.muted(pub, priv);
|
||||
console.debug(ev);
|
||||
publisher.broadcast(ev)
|
||||
publisher.broadcast(ev);
|
||||
} catch (error) {
|
||||
console.debug("Couldn't change mute list")
|
||||
console.debug("Couldn't change mute list");
|
||||
}
|
||||
}
|
||||
|
||||
function isMuted(id: HexKey) {
|
||||
return muted.includes(id) || blocked.includes(id)
|
||||
return muted.includes(id) || blocked.includes(id);
|
||||
}
|
||||
|
||||
function isBlocked(id: HexKey) {
|
||||
return blocked.includes(id)
|
||||
return blocked.includes(id);
|
||||
}
|
||||
|
||||
function unmute(id: HexKey) {
|
||||
const newMuted = muted.filter(p => p !== id)
|
||||
dispatch(setMuted({
|
||||
createdAt: new Date().getTime(),
|
||||
keys: newMuted
|
||||
}))
|
||||
setMutedList(newMuted, blocked)
|
||||
const newMuted = muted.filter((p) => p !== id);
|
||||
dispatch(
|
||||
setMuted({
|
||||
createdAt: new Date().getTime(),
|
||||
keys: newMuted,
|
||||
})
|
||||
);
|
||||
setMutedList(newMuted, blocked);
|
||||
}
|
||||
|
||||
function unblock(id: HexKey) {
|
||||
const newBlocked = blocked.filter(p => p !== id)
|
||||
dispatch(setBlocked({
|
||||
createdAt: new Date().getTime(),
|
||||
keys: newBlocked
|
||||
}))
|
||||
setMutedList(muted, newBlocked)
|
||||
const newBlocked = blocked.filter((p) => p !== id);
|
||||
dispatch(
|
||||
setBlocked({
|
||||
createdAt: new Date().getTime(),
|
||||
keys: newBlocked,
|
||||
})
|
||||
);
|
||||
setMutedList(muted, newBlocked);
|
||||
}
|
||||
|
||||
function mute(id: HexKey) {
|
||||
const newMuted = muted.includes(id) ? muted : muted.concat([id])
|
||||
setMutedList(newMuted, blocked)
|
||||
dispatch(setMuted({
|
||||
createdAt: new Date().getTime(),
|
||||
keys: newMuted
|
||||
}))
|
||||
const newMuted = muted.includes(id) ? muted : muted.concat([id]);
|
||||
setMutedList(newMuted, blocked);
|
||||
dispatch(
|
||||
setMuted({
|
||||
createdAt: new Date().getTime(),
|
||||
keys: newMuted,
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
function block(id: HexKey) {
|
||||
const newBlocked = blocked.includes(id) ? blocked : blocked.concat([id])
|
||||
setMutedList(muted, newBlocked)
|
||||
dispatch(setBlocked({
|
||||
createdAt: new Date().getTime(),
|
||||
keys: newBlocked
|
||||
}))
|
||||
const newBlocked = blocked.includes(id) ? blocked : blocked.concat([id]);
|
||||
setMutedList(muted, newBlocked);
|
||||
dispatch(
|
||||
setBlocked({
|
||||
createdAt: new Date().getTime(),
|
||||
keys: newBlocked,
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
function muteAll(ids: HexKey[]) {
|
||||
const newMuted = Array.from(new Set(muted.concat(ids)))
|
||||
setMutedList(newMuted, blocked)
|
||||
dispatch(setMuted({
|
||||
createdAt: new Date().getTime(),
|
||||
keys: newMuted
|
||||
}))
|
||||
const newMuted = Array.from(new Set(muted.concat(ids)));
|
||||
setMutedList(newMuted, blocked);
|
||||
dispatch(
|
||||
setMuted({
|
||||
createdAt: new Date().getTime(),
|
||||
keys: newMuted,
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
return { muted, mute, muteAll, unmute, isMuted, blocked, block, unblock, isBlocked }
|
||||
return {
|
||||
muted,
|
||||
mute,
|
||||
muteAll,
|
||||
unmute,
|
||||
isMuted,
|
||||
blocked,
|
||||
block,
|
||||
unblock,
|
||||
isBlocked,
|
||||
};
|
||||
}
|
||||
|
@ -1,25 +1,25 @@
|
||||
import { useEffect } from "react";
|
||||
|
||||
declare global {
|
||||
interface Window {
|
||||
webln?: {
|
||||
enabled: boolean,
|
||||
enable: () => Promise<void>,
|
||||
sendPayment: (pr: string) => Promise<any>
|
||||
}
|
||||
}
|
||||
interface Window {
|
||||
webln?: {
|
||||
enabled: boolean;
|
||||
enable: () => Promise<void>;
|
||||
sendPayment: (pr: string) => Promise<any>;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export default function useWebln(enable = true) {
|
||||
const maybeWebLn = "webln" in window ? window.webln : null
|
||||
const maybeWebLn = "webln" in window ? window.webln : null;
|
||||
|
||||
useEffect(() => {
|
||||
if (maybeWebLn && !maybeWebLn.enabled && enable) {
|
||||
maybeWebLn.enable().catch((error) => {
|
||||
console.debug("Couldn't enable WebLN")
|
||||
})
|
||||
console.debug("Couldn't enable WebLN");
|
||||
});
|
||||
}
|
||||
}, [maybeWebLn, enable])
|
||||
}, [maybeWebLn, enable]);
|
||||
|
||||
return maybeWebLn
|
||||
return maybeWebLn;
|
||||
}
|
||||
|
Reference in New Issue
Block a user