-
+
{availabilityResponse.quote?.data.type}
@@ -238,10 +216,7 @@ export default function Nip5Service(props: Nip05ServiceProps) {
{" "}
- {mapError(
- availabilityResponse.why,
- availabilityResponse.reasonTag || null
- )}
+ {mapError(availabilityResponse.why, availabilityResponse.reasonTag || null)}
)}
diff --git a/src/Element/Note.tsx b/src/Element/Note.tsx
index 9818dcff..7a02a892 100644
--- a/src/Element/Note.tsx
+++ b/src/Element/Note.tsx
@@ -1,11 +1,5 @@
import "./Note.css";
-import {
- useCallback,
- useMemo,
- useState,
- useLayoutEffect,
- ReactNode,
-} from "react";
+import { useCallback, useMemo, useState, useLayoutEffect, ReactNode } from "react";
import { useNavigate, Link } from "react-router-dom";
import { useInView } from "react-intersection-observer";
import { useIntl, FormattedMessage } from "react-intl";
@@ -58,21 +52,11 @@ const HiddenNote = ({ children }: { children: React.ReactNode }) => {
export default function Note(props: NoteProps) {
const navigate = useNavigate();
- const {
- data,
- related,
- highlight,
- options: opt,
- ["data-ev"]: parsedEvent,
- ignoreModeration = false,
- } = props;
+ const { data, related, highlight, options: opt, ["data-ev"]: parsedEvent, ignoreModeration = false } = props;
const ev = useMemo(() => parsedEvent ?? new NEvent(data), [data]);
const pubKeys = useMemo(() => ev.Thread?.PubKeys || [], [ev]);
const users = useUserProfiles(pubKeys);
- const deletions = useMemo(
- () => getReactions(related, ev.Id, EventKind.Deletion),
- [related]
- );
+ const deletions = useMemo(() => getReactions(related, ev.Id, EventKind.Deletion), [related]);
const { isMuted } = useModeration();
const isOpMuted = isMuted(ev.PubKey);
const { ref, inView, entry } = useInView({ triggerOnce: true });
@@ -99,14 +83,7 @@ export default function Note(props: NoteProps) {
);
}
- return (
-
- );
+ return
;
}, [ev]);
useLayoutEffect(() => {
@@ -139,9 +116,7 @@ export default function Note(props: NoteProps) {
mentions.push({
pk,
name: u.name ?? shortNpub,
- link: (
-
{u.name ? `@${u.name}` : shortNpub}
- ),
+ link:
{u.name ? `@${u.name}` : shortNpub},
});
} else {
mentions.push({
@@ -151,7 +126,7 @@ export default function Note(props: NoteProps) {
});
}
}
- mentions.sort((a) => (a.name.startsWith("npub") ? 1 : -1));
+ mentions.sort(a => (a.name.startsWith("npub") ? 1 : -1));
const othersLength = mentions.length - maxMentions;
const renderMention = (m: { link: React.ReactNode }, idx: number) => {
return (
@@ -162,13 +137,8 @@ export default function Note(props: NoteProps) {
);
};
const pubMentions =
- mentions.length > maxMentions
- ? mentions?.slice(0, maxMentions).map(renderMention)
- : mentions?.map(renderMention);
- const others =
- mentions.length > maxMentions
- ? formatMessage(messages.Others, { n: othersLength })
- : "";
+ mentions.length > maxMentions ? mentions?.slice(0, maxMentions).map(renderMention) : mentions?.map(renderMention);
+ const others = mentions.length > maxMentions ? formatMessage(messages.Others, { n: othersLength }) : "";
return (
re:
@@ -178,11 +148,7 @@ export default function Note(props: NoteProps) {
{others}
>
) : (
- replyId && (
-
- {hexToBech32("note", replyId)?.substring(0, 12)}
-
- )
+ replyId && {hexToBech32("note", replyId)?.substring(0, 12)}
)}
);
@@ -192,10 +158,7 @@ export default function Note(props: NoteProps) {
return (
<>
-
+
{JSON.stringify(ev.ToObject(), undefined, " ")}
>
@@ -207,10 +170,7 @@ export default function Note(props: NoteProps) {
return (
<>
-
+
{translated.text}
>
@@ -230,10 +190,7 @@ export default function Note(props: NoteProps) {
<>
{options.showHeader && (
-
+
{options.showTime && (
@@ -241,43 +198,27 @@ export default function Note(props: NoteProps) {
)}
)}
-
goToEvent(e, ev.Id)}>
+
goToEvent(e, ev.Id)}>
{transformBody()}
{translation()}
{extendable && !showMore && (
-
setShowMore(true)}
- >
+ setShowMore(true)}>
)}
- {options.showFooter && (
- setTranslated(t)}
- />
- )}
+ {options.showFooter && setTranslated(t)} />}
>
);
}
const note = (
+ className={`${baseClassName}${highlight ? " active " : " "}${extendable && !showMore ? " note-expand" : ""}`}
+ ref={ref}>
{content()}
);
- return !ignoreModeration && isOpMuted ? (
- {note}
- ) : (
- note
- );
+ return !ignoreModeration && isOpMuted ? {note} : note;
}
diff --git a/src/Element/NoteCreator.tsx b/src/Element/NoteCreator.tsx
index b8ee1e80..b28cbdbe 100644
--- a/src/Element/NoteCreator.tsx
+++ b/src/Element/NoteCreator.tsx
@@ -48,9 +48,7 @@ export function NoteCreator(props: NoteCreatorProps) {
async function sendNote() {
if (note) {
- const ev = replyTo
- ? await publisher.reply(replyTo, note)
- : await publisher.note(note);
+ const ev = replyTo ? await publisher.reply(replyTo, note) : await publisher.note(note);
console.debug("Sending note: ", ev);
publisher.broadcast(ev);
setNote("");
@@ -68,7 +66,7 @@ export function NoteCreator(props: NoteCreatorProps) {
if (file) {
const rx = await uploader.upload(file, file.name);
if (rx.url) {
- setNote((n) => `${n ? `${n}\n` : ""}${rx.url}`);
+ setNote(n => `${n ? `${n}\n` : ""}${rx.url}`);
} else if (rx?.error) {
setError(rx.error);
}
@@ -125,11 +123,7 @@ export function NoteCreator(props: NoteCreatorProps) {
diff --git a/src/Element/NoteFooter.tsx b/src/Element/NoteFooter.tsx
index 519d82f3..610835ac 100644
--- a/src/Element/NoteFooter.tsx
+++ b/src/Element/NoteFooter.tsx
@@ -21,13 +21,7 @@ import Zap from "Icons/Zap";
import Reply from "Icons/Reply";
import { formatShort } from "Number";
import useEventPublisher from "Feed/EventPublisher";
-import {
- getReactions,
- dedupeByPubkey,
- hexToBech32,
- normalizeReaction,
- Reaction,
-} from "Util";
+import { getReactions, dedupeByPubkey, hexToBech32, normalizeReaction, Reaction } from "Util";
import { NoteCreator } from "Element/NoteCreator";
import Reactions from "Element/Reactions";
import SendSats from "Element/SendSats";
@@ -58,13 +52,9 @@ export interface NoteFooterProps {
export default function NoteFooter(props: NoteFooterProps) {
const { related, ev } = props;
const { formatMessage } = useIntl();
- const login = useSelector
(
- (s) => s.login.publicKey
- );
+ const login = useSelector(s => s.login.publicKey);
const { mute, block } = useModeration();
- const prefs = useSelector(
- (s) => s.login.preferences
- );
+ const prefs = useSelector(s => s.login.preferences);
const author = useUserProfile(ev.RootPubKey);
const publisher = useEventPublisher();
const [reply, setReply] = useState(false);
@@ -75,29 +65,23 @@ export default function NoteFooter(props: NoteFooterProps) {
const langNames = new Intl.DisplayNames([...window.navigator.languages], {
type: "language",
});
- const reactions = useMemo(
- () => getReactions(related, ev.Id, EventKind.Reaction),
- [related, ev]
- );
- const reposts = useMemo(
- () => dedupeByPubkey(getReactions(related, ev.Id, EventKind.Repost)),
- [related, ev]
- );
+ const reactions = useMemo(() => getReactions(related, ev.Id, EventKind.Reaction), [related, ev]);
+ const reposts = useMemo(() => dedupeByPubkey(getReactions(related, ev.Id, EventKind.Repost)), [related, ev]);
const zaps = useMemo(() => {
const sortedZaps = getReactions(related, ev.Id, EventKind.ZapReceipt)
.map(parseZap)
- .filter((z) => z.valid && z.zapper !== ev.PubKey);
+ .filter(z => z.valid && z.zapper !== ev.PubKey);
sortedZaps.sort((a, b) => b.amount - a.amount);
return sortedZaps;
}, [related]);
const zapTotal = zaps.reduce((acc, z) => acc + z.amount, 0);
- const didZap = zaps.some((a) => a.zapper === login);
+ const didZap = zaps.some(a => a.zapper === login);
const groupReactions = useMemo(() => {
const result = reactions?.reduce(
(acc, reaction) => {
const kind = normalizeReaction(reaction.content);
const rs = acc[kind] || [];
- if (rs.map((e) => e.pubkey).includes(reaction.pubkey)) {
+ if (rs.map(e => e.pubkey).includes(reaction.pubkey)) {
return acc;
}
return { ...acc, [kind]: [...rs, reaction] };
@@ -116,14 +100,11 @@ export default function NoteFooter(props: NoteFooterProps) {
const negative = groupReactions[Reaction.Negative];
function hasReacted(emoji: string) {
- return reactions?.some(
- ({ pubkey, content }) =>
- normalizeReaction(content) === emoji && pubkey === login
- );
+ return reactions?.some(({ pubkey, content }) => normalizeReaction(content) === emoji && pubkey === login);
}
function hasReposted() {
- return reposts.some((a) => a.pubkey === login);
+ return reposts.some(a => a.pubkey === login);
}
async function react(content: string) {
@@ -134,11 +115,7 @@ export default function NoteFooter(props: NoteFooterProps) {
}
async function deleteEvent() {
- if (
- window.confirm(
- formatMessage(messages.ConfirmDeletion, { id: ev.Id.substring(0, 8) })
- )
- ) {
+ if (window.confirm(formatMessage(messages.ConfirmDeletion, { id: ev.Id.substring(0, 8) }))) {
const evDelete = await publisher.delete(ev.Id);
publisher.broadcast(evDelete);
}
@@ -146,10 +123,7 @@ export default function NoteFooter(props: NoteFooterProps) {
async function repost() {
if (!hasReposted()) {
- if (
- !prefs.confirmReposts ||
- window.confirm(formatMessage(messages.ConfirmRepost, { id: ev.Id }))
- ) {
+ if (!prefs.confirmReposts || window.confirm(formatMessage(messages.ConfirmRepost, { id: ev.Id }))) {
const evRepost = await publisher.repost(ev);
publisher.broadcast(evRepost);
}
@@ -161,18 +135,11 @@ export default function NoteFooter(props: NoteFooterProps) {
if (service) {
return (
<>
- setTip(true)}
- >
+
setTip(true)}>
- {zapTotal > 0 && (
-
- {formatShort(zapTotal)}
-
- )}
+ {zapTotal > 0 &&
{formatShort(zapTotal)}
}
>
);
@@ -182,18 +149,11 @@ export default function NoteFooter(props: NoteFooterProps) {
function repostIcon() {
return (
-
repost()}
- >
+
repost()}>
- {reposts.length > 0 && (
-
- {formatShort(reposts.length)}
-
- )}
+ {reposts.length > 0 &&
{formatShort(reposts.length)}
}
);
}
@@ -204,16 +164,11 @@ export default function NoteFooter(props: NoteFooterProps) {
}
return (
<>
-
react("+")}
- >
+
react("+")}>
-
- {formatShort(positive.length)}
-
+
{formatShort(positive.length)}
{repostIcon()}
>
@@ -221,9 +176,7 @@ export default function NoteFooter(props: NoteFooterProps) {
}
async function share() {
- const url = `${window.location.protocol}//${
- window.location.host
- }/e/${hexToBech32("note", ev.Id)}`;
+ const url = `${window.location.protocol}//${window.location.host}/e/${hexToBech32("note", ev.Id)}`;
if ("share" in window.navigator) {
await window.navigator.share({
title: "Snort",
@@ -262,9 +215,7 @@ export default function NoteFooter(props: NoteFooterProps) {
}
async function copyEvent() {
- await navigator.clipboard.writeText(
- JSON.stringify(ev.Original, undefined, " ")
- );
+ await navigator.clipboard.writeText(JSON.stringify(ev.Original, undefined, " "));
}
function menuItems() {
@@ -291,10 +242,7 @@ export default function NoteFooter(props: NoteFooterProps) {
{prefs.enableReactions && (
)}
{prefs.showDebugMenus && (
diff --git a/src/Element/NoteTime.tsx b/src/Element/NoteTime.tsx
index 42ce88a7..26d1bcba 100644
--- a/src/Element/NoteTime.tsx
+++ b/src/Element/NoteTime.tsx
@@ -31,10 +31,7 @@ export default function NoteTime(props: NoteTimeProps) {
weekday: "short",
});
} else if (absAgo > HourInMs) {
- return `${fromDate.getHours().toString().padStart(2, "0")}:${fromDate
- .getMinutes()
- .toString()
- .padStart(2, "0")}`;
+ return `${fromDate.getHours().toString().padStart(2, "0")}:${fromDate.getMinutes().toString().padStart(2, "0")}`;
} else if (absAgo < MinuteInMs) {
return fallback;
} else {
@@ -49,7 +46,7 @@ export default function NoteTime(props: NoteTimeProps) {
useEffect(() => {
setTime(calcTime());
const t = setInterval(() => {
- setTime((s) => {
+ setTime(s => {
const newTime = calcTime();
if (newTime !== s) {
return newTime;
diff --git a/src/Element/NoteToSelf.tsx b/src/Element/NoteToSelf.tsx
index a701238c..d4ba54d1 100644
--- a/src/Element/NoteToSelf.tsx
+++ b/src/Element/NoteToSelf.tsx
@@ -20,19 +20,13 @@ function NoteLabel({ pubkey }: NoteToSelfProps) {
const user = useUserProfile(pubkey);
return (
- {" "}
-
+
{user?.nip05 && }
);
}
-export default function NoteToSelf({
- pubkey,
- clickable,
- className,
- link,
-}: NoteToSelfProps) {
+export default function NoteToSelf({ pubkey, clickable, className, link }: NoteToSelfProps) {
const navigate = useNavigate();
const clickLink = () => {
@@ -45,12 +39,7 @@ export default function NoteToSelf({
diff --git a/src/Element/ProfileImage.tsx b/src/Element/ProfileImage.tsx
index db123b09..4c529e63 100644
--- a/src/Element/ProfileImage.tsx
+++ b/src/Element/ProfileImage.tsx
@@ -17,13 +17,7 @@ export interface ProfileImageProps {
link?: string;
}
-export default function ProfileImage({
- pubkey,
- subHeader,
- showUsername = true,
- className,
- link,
-}: ProfileImageProps) {
+export default function ProfileImage({ pubkey, subHeader, showUsername = true, className, link }: ProfileImageProps) {
const navigate = useNavigate();
const user = useUserProfile(pubkey);
@@ -34,19 +28,12 @@ export default function ProfileImage({
return (
-
navigate(link ?? profileLink(pubkey))}
- />
+ navigate(link ?? profileLink(pubkey))} />
{showUsername && (
-
+
{name}
{user?.nip05 &&
}
@@ -58,10 +45,7 @@ export default function ProfileImage({
);
}
-export function getDisplayName(
- user: MetadataCache | undefined,
- pubkey: HexKey
-) {
+export function getDisplayName(user: MetadataCache | undefined, pubkey: HexKey) {
let name = hexToBech32("npub", pubkey).substring(0, 12);
if (user?.display_name !== undefined && user.display_name.length > 0) {
name = user.display_name;
diff --git a/src/Element/ProfilePreview.tsx b/src/Element/ProfilePreview.tsx
index 415b02ce..69aba61d 100644
--- a/src/Element/ProfilePreview.tsx
+++ b/src/Element/ProfilePreview.tsx
@@ -25,21 +25,12 @@ export default function ProfilePreview(props: ProfilePreviewProps) {
};
return (
-
+
{inView && (
<>
{user?.about}
- ) : undefined
- }
+ subHeader={options.about ?
{user?.about}
: undefined}
/>
{props.actions ?? (
diff --git a/src/Element/ProxyImg.tsx b/src/Element/ProxyImg.tsx
index 7f7d8193..37893c13 100644
--- a/src/Element/ProxyImg.tsx
+++ b/src/Element/ProxyImg.tsx
@@ -1,11 +1,7 @@
import useImgProxy from "Feed/ImgProxy";
import { useEffect, useState } from "react";
-interface ProxyImgProps
- extends React.DetailedHTMLProps<
- React.ImgHTMLAttributes,
- HTMLImageElement
- > {
+interface ProxyImgProps extends React.DetailedHTMLProps, HTMLImageElement> {
size?: number;
}
@@ -17,7 +13,7 @@ export const ProxyImg = (props: ProxyImgProps) => {
useEffect(() => {
if (src) {
proxy(src, size)
- .then((a) => setUrl(a))
+ .then(a => setUrl(a))
.catch(console.warn);
}
}, [src]);
diff --git a/src/Element/Reactions.tsx b/src/Element/Reactions.tsx
index cee3721d..dbeabf85 100644
--- a/src/Element/Reactions.tsx
+++ b/src/Element/Reactions.tsx
@@ -28,14 +28,7 @@ interface ReactionsProps {
zaps: ParsedZap[];
}
-const Reactions = ({
- show,
- setShow,
- positive,
- negative,
- reposts,
- zaps,
-}: ReactionsProps) => {
+const Reactions = ({ show, setShow, positive, negative, reposts, zaps }: ReactionsProps) => {
const { formatMessage } = useIntl();
const onClose = () => setShow(false);
const likes = useMemo(() => {
@@ -48,8 +41,7 @@ const Reactions = ({
sorted.sort((a, b) => b.created_at - a.created_at);
return sorted;
}, [negative]);
- const total =
- positive.length + negative.length + zaps.length + reposts.length;
+ const total = positive.length + negative.length + zaps.length + reposts.length;
const defaultTabs: Tab[] = [
{
text: formatMessage(messages.Likes, { n: likes.length }),
@@ -93,24 +85,17 @@ const Reactions = ({
-
+
{tab.value === 0 &&
- likes.map((ev) => {
+ likes.map(ev => {
return (
- {ev.content === "+" ? (
-
- ) : (
- ev.content
- )}
+ {ev.content === "+" ? : ev.content}
@@ -118,23 +103,22 @@ const Reactions = ({
);
})}
{tab.value === 1 &&
- zaps.map((z) => {
+ zaps.map(z => {
return (
-
-
-
-
{formatShort(z.amount)}
+ z.zapper && (
+
+
+
+ {formatShort(z.amount)}
+
+
{z.content}>} />
+
-
{z.content}>}
- />
-
-
+ )
);
})}
{tab.value === 2 &&
- reposts.map((ev) => {
+ reposts.map(ev => {
return (
@@ -146,7 +130,7 @@ const Reactions = ({
);
})}
{tab.value === 3 &&
- dislikes.map((ev) => {
+ dislikes.map(ev => {
return (
diff --git a/src/Element/Relay.tsx b/src/Element/Relay.tsx
index ed486a60..3fd138f8 100644
--- a/src/Element/Relay.tsx
+++ b/src/Element/Relay.tsx
@@ -27,10 +27,7 @@ export default function Relay(props: RelayProps) {
const dispatch = useDispatch();
const { formatMessage } = useIntl();
const navigate = useNavigate();
- const allRelaySettings = useSelector<
- RootState,
- Record
- >((s) => s.login.relays);
+ const allRelaySettings = useSelector>(s => s.login.relays);
const relaySettings = allRelaySettings[props.addr];
const state = useRelayState(props.addr);
const name = useMemo(() => new URL(props.addr).host, [props.addr]);
@@ -66,11 +63,8 @@ export default function Relay(props: RelayProps) {
write: !relaySettings.write,
read: relaySettings.read,
})
- }
- >
-
+ }>
+
@@ -82,11 +76,8 @@ export default function Relay(props: RelayProps) {
write: relaySettings.write,
read: !relaySettings.read,
})
- }
- >
-
+ }>
+
@@ -104,10 +95,7 @@ export default function Relay(props: RelayProps) {
{state?.disconnects}
- navigate(state?.id ?? "")}
- >
+ navigate(state?.id ?? "")}>
diff --git a/src/Element/SendSats.tsx b/src/Element/SendSats.tsx
index 5d2a69bc..8c4545a9 100644
--- a/src/Element/SendSats.tsx
+++ b/src/Element/SendSats.tsx
@@ -54,9 +54,7 @@ export default function LNURLTip(props: LNURLTipProps) {
const service = props.svc;
const show = props.show || false;
const { note, author, target } = props;
- const amounts = [
- 500, 1_000, 5_000, 10_000, 20_000, 50_000, 100_000, 1_000_000,
- ];
+ const amounts = [500, 1_000, 5_000, 10_000, 20_000, 50_000, 100_000, 1_000_000];
const emojis: Record
= {
1_000: "👍",
5_000: "💜",
@@ -77,13 +75,12 @@ export default function LNURLTip(props: LNURLTipProps) {
const { formatMessage } = useIntl();
const publisher = useEventPublisher();
const horizontalScroll = useHorizontalScroll();
- const canComment =
- (payService?.commentAllowed ?? 0) > 0 || payService?.nostrPubkey;
+ const canComment = (payService?.commentAllowed ?? 0) > 0 || payService?.nostrPubkey;
useEffect(() => {
if (show && !props.invoice) {
loadService()
- .then((a) => setPayService(a ?? undefined))
+ .then(a => setPayService(a ?? undefined))
.catch(() => setError(formatMessage(messages.LNURLFail)));
} else {
setPayService(undefined);
@@ -99,13 +96,11 @@ export default function LNURLTip(props: LNURLTipProps) {
if (payService) {
const min = (payService.minSendable ?? 0) / 1000;
const max = (payService.maxSendable ?? 0) / 1000;
- return amounts.filter((a) => a >= min && a <= max);
+ return amounts.filter(a => a >= min && a <= max);
}
return [];
}, [payService]);
- // TODO Why was this never used? I think this might be a bug, or was it just an oversight?
-
const selectAmount = (a: number) => {
setError(undefined);
setInvoice(undefined);
@@ -141,14 +136,10 @@ export default function LNURLTip(props: LNURLTipProps) {
if (!amount || !payService) return null;
let url = "";
const amountParam = `amount=${Math.floor(amount * 1000)}`;
- const commentParam =
- comment && payService?.commentAllowed
- ? `&comment=${encodeURIComponent(comment)}`
- : "";
+ const commentParam = comment && payService?.commentAllowed ? `&comment=${encodeURIComponent(comment)}` : "";
if (payService.nostrPubkey && author) {
const ev = await publisher.zap(author, note, comment);
- const nostrParam =
- ev && `&nostr=${encodeURIComponent(JSON.stringify(ev.ToObject()))}`;
+ const nostrParam = ev && `&nostr=${encodeURIComponent(JSON.stringify(ev.ToObject()))}`;
url = `${payService.callback}?${amountParam}${commentParam}${nostrParam}`;
} else {
url = `${payService.callback}?${amountParam}${commentParam}`;
@@ -185,14 +176,13 @@ export default function LNURLTip(props: LNURLTipProps) {
className="f-grow mr10"
placeholder={formatMessage(messages.Custom)}
value={customAmount}
- onChange={(e) => setCustomAmount(parseInt(e.target.value))}
+ onChange={e => setCustomAmount(parseInt(e.target.value))}
/>
@@ -222,12 +212,8 @@ export default function LNURLTip(props: LNURLTipProps) {
- {serviceAmounts.map((a) => (
- selectAmount(a)}
- >
+ {serviceAmounts.map(a => (
+ selectAmount(a)}>
{emojis[a] && <>{emojis[a]} >}
{formatShort(a)}
@@ -241,28 +227,18 @@ export default function LNURLTip(props: LNURLTipProps) {
placeholder={formatMessage(messages.Comment)}
className="f-grow"
maxLength={payService?.commentAllowed || 120}
- onChange={(e) => setComment(e.target.value)}
+ onChange={e => setComment(e.target.value)}
/>
)}
{(amount ?? 0) > 0 && (
-
diff --git a/src/Pages/settings/Profile.tsx b/src/Pages/settings/Profile.tsx
index fb2a84df..4e559ca8 100644
--- a/src/Pages/settings/Profile.tsx
+++ b/src/Pages/settings/Profile.tsx
@@ -25,12 +25,8 @@ export interface ProfileSettingsProps {
export default function ProfileSettings(props: ProfileSettingsProps) {
const navigate = useNavigate();
- const id = useSelector
(
- (s) => s.login.publicKey
- );
- const privKey = useSelector(
- (s) => s.login.privateKey
- );
+ const id = useSelector(s => s.login.publicKey);
+ const privKey = useSelector(s => s.login.privateKey);
const user = useUserProfile(id ?? "");
const publisher = useEventPublisher();
const uploader = useFileUpload();
@@ -118,11 +114,7 @@ export default function ProfileSettings(props: ProfileSettingsProps) {
:
- setName(e.target.value)}
- />
+ setName(e.target.value)} />
@@ -130,11 +122,7 @@ export default function ProfileSettings(props: ProfileSettingsProps) {
:
- setDisplayName(e.target.value)}
- />
+ setDisplayName(e.target.value)} />
@@ -142,11 +130,7 @@ export default function ProfileSettings(props: ProfileSettingsProps) {
:
-
+
@@ -154,11 +138,7 @@ export default function ProfileSettings(props: ProfileSettingsProps) {
:
- setWebsite(e.target.value)}
- />
+ setWebsite(e.target.value)} />
@@ -166,12 +146,7 @@ export default function ProfileSettings(props: ProfileSettingsProps) {
:
- setNip05(e.target.value)}
- />
+ setNip05(e.target.value)} />
navigate("/verification")}>
@@ -183,11 +158,7 @@ export default function ProfileSettings(props: ProfileSettingsProps) {
:
- setLud16(e.target.value)}
- />
+ setLud16(e.target.value)} />
@@ -212,10 +183,7 @@ export default function ProfileSettings(props: ProfileSettingsProps) {
-
+
setNewAvatar()}>
@@ -229,12 +197,9 @@ export default function ProfileSettings(props: ProfileSettingsProps) {
+ className="banner">
setNewBanner()}>
diff --git a/src/Pages/settings/RelayInfo.tsx b/src/Pages/settings/RelayInfo.tsx
index 59aad7cf..d53171cd 100644
--- a/src/Pages/settings/RelayInfo.tsx
+++ b/src/Pages/settings/RelayInfo.tsx
@@ -14,9 +14,7 @@ const RelayInfo = () => {
const navigate = useNavigate();
const dispatch = useDispatch();
- const conn = Array.from(System.Sockets.values()).find(
- (a) => a.Id === params.id
- );
+ const conn = Array.from(System.Sockets.values()).find(a => a.Id === params.id);
console.debug(conn);
const stats = useRelayState(conn?.Address ?? "");
@@ -63,12 +61,9 @@ const RelayInfo = () => {
+ rel="noreferrer">
{stats.info.contact}
@@ -79,17 +74,12 @@ const RelayInfo = () => {
- {stats.info.supported_nips.map((a) => (
+ {stats.info.supported_nips.map(a => (
- navigate(
- `https://github.com/nostr-protocol/nips/blob/master/${a
- .toString()
- .padStart(2, "0")}.md`
- )
- }
- >
+ navigate(`https://github.com/nostr-protocol/nips/blob/master/${a.toString().padStart(2, "0")}.md`)
+ }>
NIP-{a.toString().padStart(2, "0")}
))}
@@ -102,8 +92,7 @@ const RelayInfo = () => {
onClick={() => {
dispatch(removeRelay(unwrap(conn).Address));
navigate("/settings/relays");
- }}
- >
+ }}>
diff --git a/src/Pages/settings/Relays.tsx b/src/Pages/settings/Relays.tsx
index bac4d475..d41e343e 100644
--- a/src/Pages/settings/Relays.tsx
+++ b/src/Pages/settings/Relays.tsx
@@ -13,9 +13,7 @@ import messages from "./messages";
const RelaySettingsPage = () => {
const dispatch = useDispatch();
const publisher = useEventPublisher();
- const relays = useSelector
>(
- (s) => s.login.relays
- );
+ const relays = useSelector>(s => s.login.relays);
const [newRelay, setNewRelay] = useState();
async function saveRelays() {
@@ -36,7 +34,7 @@ const RelaySettingsPage = () => {
className="f-grow"
placeholder="wss://my-relay.com"
value={newRelay}
- onChange={(e) => setNewRelay(e.target.value)}
+ onChange={e => setNewRelay(e.target.value)}
/>
addNewRelay()}>
@@ -64,7 +62,7 @@ const RelaySettingsPage = () => {
<>
Relays
- {Object.keys(relays || {}).map((a) => (
+ {Object.keys(relays || {}).map(a => (
))}
diff --git a/src/Pages/settings/messages.js b/src/Pages/settings/messages.js
index ac2bc762..59d51107 100644
--- a/src/Pages/settings/messages.js
+++ b/src/Pages/settings/messages.js
@@ -28,8 +28,7 @@ const messages = defineMessages({
ServiceKey: "Service Key",
ServiceSalt: "Service Salt",
EnableReactions: "Enable reactions",
- EnableReactionsHelp:
- "Reactions will be shown on every page, if disabled no reactions will be shown",
+ EnableReactionsHelp: "Reactions will be shown on every page, if disabled no reactions will be shown",
ConfirmReposts: "Confirm Reposts",
ConfirmRepostsHelp: "Reposts need to be manually confirmed",
ShowLatest: "Automatically show latest notes",
diff --git a/src/State/Login.ts b/src/State/Login.ts
index c1c54def..202aac6a 100644
--- a/src/State/Login.ts
+++ b/src/State/Login.ts
@@ -1,4 +1,4 @@
-import { createSlice, PayloadAction } from "@reduxjs/toolkit";
+import { AnyAction, createSlice, PayloadAction, ThunkAction } from "@reduxjs/toolkit";
import * as secp from "@noble/secp256k1";
import { DefaultRelays } from "Const";
import { HexKey, TaggedRawEvent } from "Nostr";
@@ -202,13 +202,10 @@ const LoginSlice = createSlice({
reducers: {
init: (state, action: PayloadAction) => {
state.useDb = action.payload;
- state.privateKey =
- window.localStorage.getItem(PrivateKeyItem) ?? undefined;
+ state.privateKey = window.localStorage.getItem(PrivateKeyItem) ?? undefined;
if (state.privateKey) {
window.localStorage.removeItem(PublicKeyItem); // reset nip07 if using private key
- state.publicKey = secp.utils.bytesToHex(
- secp.schnorr.getPublicKey(state.privateKey)
- );
+ state.publicKey = secp.utils.bytesToHex(secp.schnorr.getPublicKey(state.privateKey));
state.loggedOut = false;
} else {
state.loggedOut = true;
@@ -234,9 +231,7 @@ const LoginSlice = createSlice({
}
// notifications
- const readNotif = parseInt(
- window.localStorage.getItem(NotificationsReadItem) ?? "0"
- );
+ const readNotif = parseInt(window.localStorage.getItem(NotificationsReadItem) ?? "0");
if (!isNaN(readNotif)) {
state.readNotifications = readNotif;
}
@@ -251,18 +246,14 @@ const LoginSlice = createSlice({
state.loggedOut = false;
state.privateKey = action.payload;
window.localStorage.setItem(PrivateKeyItem, action.payload);
- state.publicKey = secp.utils.bytesToHex(
- secp.schnorr.getPublicKey(action.payload)
- );
+ state.publicKey = secp.utils.bytesToHex(secp.schnorr.getPublicKey(action.payload));
},
setGeneratedPrivateKey: (state, action: PayloadAction) => {
state.loggedOut = false;
state.newUserKey = true;
state.privateKey = action.payload;
window.localStorage.setItem(PrivateKeyItem, action.payload);
- state.publicKey = secp.utils.bytesToHex(
- secp.schnorr.getPublicKey(action.payload)
- );
+ state.publicKey = secp.utils.bytesToHex(secp.schnorr.getPublicKey(action.payload));
},
setPublicKey: (state, action: PayloadAction) => {
window.localStorage.setItem(PublicKeyItem, action.payload);
@@ -303,7 +294,7 @@ const LoginSlice = createSlice({
const update = Array.isArray(keys) ? keys : [keys];
let changes = false;
- for (const pk of update.filter((a) => a.length === 64)) {
+ for (const pk of update.filter(a => a.length === 64)) {
if (!existing.has(pk)) {
existing.add(pk);
changes = true;
@@ -323,10 +314,7 @@ const LoginSlice = createSlice({
window.localStorage.setItem(FollowList, JSON.stringify(state.follows));
},
- setMuted(
- state,
- action: PayloadAction<{ createdAt: number; keys: HexKey[] }>
- ) {
+ setMuted(state, action: PayloadAction<{ createdAt: number; keys: HexKey[] }>) {
const { createdAt, keys } = action.payload;
if (createdAt >= state.latestMuted) {
const muted = new Set([...keys]);
@@ -334,10 +322,7 @@ const LoginSlice = createSlice({
state.latestMuted = createdAt;
}
},
- setBlocked(
- state,
- action: PayloadAction<{ createdAt: number; keys: HexKey[] }>
- ) {
+ setBlocked(state, action: PayloadAction<{ createdAt: number; keys: HexKey[] }>) {
const { createdAt, keys } = action.payload;
if (createdAt >= state.latestMuted) {
const blocked = new Set([...keys]);
@@ -345,10 +330,7 @@ const LoginSlice = createSlice({
state.latestMuted = createdAt;
}
},
- addDirectMessage: (
- state,
- action: PayloadAction>
- ) => {
+ addDirectMessage: (state, action: PayloadAction>) => {
let n = action.payload;
if (!Array.isArray(n)) {
n = [n];
@@ -356,7 +338,7 @@ const LoginSlice = createSlice({
let didChange = false;
for (const x of n) {
- if (!state.dms.some((a) => a.id === x.id)) {
+ if (!state.dms.some(a => a.id === x.id)) {
state.dms.push(x);
didChange = true;
}
@@ -366,10 +348,10 @@ const LoginSlice = createSlice({
state.dms = [...state.dms];
}
},
- incDmInteraction: (state) => {
+ incDmInteraction: state => {
state.dmInteraction += 1;
},
- logout: (state) => {
+ logout: state => {
const relays = { ...state.relays };
Object.assign(state, InitState);
state.loggedOut = true;
@@ -377,22 +359,16 @@ const LoginSlice = createSlice({
state.relays = relays;
window.localStorage.setItem(RelayListKey, JSON.stringify(relays));
},
- markNotificationsRead: (state) => {
+ markNotificationsRead: state => {
state.readNotifications = Math.ceil(new Date().getTime() / 1000);
- window.localStorage.setItem(
- NotificationsReadItem,
- state.readNotifications.toString()
- );
+ window.localStorage.setItem(NotificationsReadItem, state.readNotifications.toString());
},
setLatestNotifications: (state, action: PayloadAction) => {
state.latestNotification = action.payload;
},
setPreferences: (state, action: PayloadAction) => {
state.preferences = action.payload;
- window.localStorage.setItem(
- UserPreferencesKey,
- JSON.stringify(state.preferences)
- );
+ window.localStorage.setItem(UserPreferencesKey, JSON.stringify(state.preferences));
},
},
});
@@ -420,14 +396,12 @@ export function sendNotification({
body,
icon,
timestamp,
-}: NotificationRequest) {
+}: NotificationRequest): ThunkAction {
return async (dispatch: AppDispatch, getState: () => RootState) => {
const state = getState();
const { readNotifications } = state.login;
- const hasPermission =
- "Notification" in window && Notification.permission === "granted";
- const shouldShowNotification =
- hasPermission && timestamp > readNotifications;
+ const hasPermission = "Notification" in window && Notification.permission === "granted";
+ const shouldShowNotification = hasPermission && timestamp > readNotifications;
if (shouldShowNotification) {
try {
const worker = await navigator.serviceWorker.ready;
diff --git a/src/State/Users/Db.ts b/src/State/Users/Db.ts
index 590c4d2d..82cb8a62 100644
--- a/src/State/Users/Db.ts
+++ b/src/State/Users/Db.ts
@@ -11,7 +11,7 @@ class IndexedUsersDb implements UsersDb {
isAvailable() {
if ("indexedDB" in window) {
- return new Promise((resolve) => {
+ return new Promise(resolve => {
const req = window.indexedDB.open("dummy", 1);
req.onsuccess = () => {
resolve(true);
@@ -44,7 +44,7 @@ class IndexedUsersDb implements UsersDb {
async bulkGet(keys: HexKey[]) {
const ret = await idb.users.bulkGet(keys);
- return ret.filter((a) => a !== undefined).map((a_1) => unwrap(a_1));
+ return ret.filter(a => a !== undefined).map(a_1 => unwrap(a_1));
}
async add(user: MetadataCache) {
@@ -68,10 +68,7 @@ class IndexedUsersDb implements UsersDb {
}
}
-function groupByPubkey(
- acc: Record,
- user: MetadataCache
-) {
+function groupByPubkey(acc: Record, user: MetadataCache) {
return { ...acc, [user.pubkey]: user };
}
@@ -83,7 +80,7 @@ class ReduxUsersDb implements UsersDb {
async query(q: string) {
const state = store.getState();
const { users } = state.users;
- return Object.values(users).filter((user) => {
+ return Object.values(users).filter(user => {
const profile = user as MetadataCache;
return (
profile.name?.includes(q) ||
@@ -123,7 +120,7 @@ class ReduxUsersDb implements UsersDb {
const state = store.getState();
const { users } = state.users;
const ids = new Set([...keys]);
- return Object.values(users).filter((user) => {
+ return Object.values(users).filter(user => {
return ids.has(user.pubkey);
});
}
diff --git a/src/State/Users/Hooks.ts b/src/State/Users/Hooks.ts
index cbd01409..211cfc74 100644
--- a/src/State/Users/Hooks.ts
+++ b/src/State/Users/Hooks.ts
@@ -10,10 +10,10 @@ export function useQuery(query: string) {
return useLiveQuery(async () => db.query(query), [query]);
}
-export function useKey(pubKey: HexKey) {
+export function useKey(pubKey?: HexKey) {
const db = useDb();
const { users } = useSelector((state: RootState) => state.users);
- const defaultUser = users[pubKey];
+ const defaultUser = pubKey ? users[pubKey] : undefined;
const user = useLiveQuery(async () => {
if (pubKey) {
@@ -29,7 +29,7 @@ export function useKey(pubKey: HexKey) {
return user;
}
-export function useKeys(pubKeys: HexKey[]): Map {
+export function useKeys(pubKeys?: HexKey[]): Map {
const db = useDb();
const { users } = useSelector((state: RootState) => state.users);
@@ -37,10 +37,10 @@ export function useKeys(pubKeys: HexKey[]): Map {
if (pubKeys) {
try {
const ret = await db.bulkGet(pubKeys);
- return new Map(ret.map((a) => [a.pubkey, a]));
+ return new Map(ret.map(a => [a.pubkey, a]));
} catch (error) {
console.error(error);
- return new Map(pubKeys.map((a) => [a, users[a]]));
+ return new Map(pubKeys.map(a => [a, users[a]]));
}
}
return new Map();
diff --git a/src/Upload/NostrBuild.ts b/src/Upload/NostrBuild.ts
index 225f59fc..74d22209 100644
--- a/src/Upload/NostrBuild.ts
+++ b/src/Upload/NostrBuild.ts
@@ -1,8 +1,6 @@
import { UploadResult } from "Upload";
-export default async function NostrBuild(
- file: File | Blob
-): Promise {
+export default async function NostrBuild(file: File | Blob): Promise {
const fd = new FormData();
fd.append("fileToUpload", file);
fd.append("submit", "Upload Image");
diff --git a/src/Upload/NostrImg.ts b/src/Upload/NostrImg.ts
index dd6e5b3c..705d51ff 100644
--- a/src/Upload/NostrImg.ts
+++ b/src/Upload/NostrImg.ts
@@ -1,8 +1,6 @@
import { UploadResult } from "Upload";
-export default async function NostrImg(
- file: File | Blob
-): Promise {
+export default async function NostrImg(file: File | Blob): Promise {
const fd = new FormData();
fd.append("image", file);
diff --git a/src/Upload/VoidCat.ts b/src/Upload/VoidCat.ts
index db41806f..df99976f 100644
--- a/src/Upload/VoidCat.ts
+++ b/src/Upload/VoidCat.ts
@@ -6,10 +6,7 @@ import { UploadResult } from "Upload";
* Upload file to void.cat
* https://void.cat/swagger/index.html
*/
-export default async function VoidCat(
- file: File | Blob,
- filename: string
-): Promise {
+export default async function VoidCat(file: File | Blob, filename: string): Promise {
const buf = await file.arrayBuffer();
const digest = await crypto.subtle.digest("SHA-256", buf);
@@ -35,9 +32,7 @@ export default async function VoidCat(
ext = ["", "webp"];
}
return {
- url:
- rsp.file?.metadata?.url ??
- `${VoidCatHost}/d/${rsp.file?.id}${ext ? `.${ext[1]}` : ""}`,
+ url: rsp.file?.metadata?.url ?? `${VoidCatHost}/d/${rsp.file?.id}${ext ? `.${ext[1]}` : ""}`,
};
} else {
return {
diff --git a/src/Upload/index.ts b/src/Upload/index.ts
index 68b5c5c7..10ea1998 100644
--- a/src/Upload/index.ts
+++ b/src/Upload/index.ts
@@ -14,9 +14,7 @@ export interface Uploader {
}
export default function useFileUpload(): Uploader {
- const fileUploader = useSelector(
- (s: RootState) => s.login.preferences.fileUploader
- );
+ const fileUploader = useSelector((s: RootState) => s.login.preferences.fileUploader);
switch (fileUploader) {
case "nostr.build": {
diff --git a/src/Util.ts b/src/Util.ts
index e64eb581..03806d45 100644
--- a/src/Util.ts
+++ b/src/Util.ts
@@ -10,7 +10,7 @@ export const sha256 = (str: string) => {
};
export async function openFile(): Promise {
- return new Promise((resolve) => {
+ return new Promise(resolve => {
const elm = document.createElement("input");
elm.type = "file";
elm.onchange = (e: Event) => {
@@ -33,7 +33,7 @@ export async function openFile(): Promise {
export function parseId(id: string) {
const hrp = ["note", "npub", "nsec"];
try {
- if (hrp.some((a) => id.startsWith(a))) {
+ if (hrp.some(a => id.startsWith(a))) {
return bech32ToHex(id);
}
} catch (e) {
@@ -72,7 +72,7 @@ export function eventLink(hex: u256) {
* Convert hex to bech32
* @param {string} hex
*/
-export function hexToBech32(hrp: string, hex: string) {
+export function hexToBech32(hrp: string, hex?: string) {
if (typeof hex !== "string" || hex.length === 0 || hex.length % 2 !== 0) {
return "";
}
@@ -122,16 +122,8 @@ export function normalizeReaction(content: string) {
/**
* Get reactions to a specific event (#e + kind filter)
*/
-export function getReactions(
- notes: TaggedRawEvent[],
- id: u256,
- kind = EventKind.Reaction
-) {
- return (
- notes?.filter(
- (a) => a.kind === kind && a.tags.some((a) => a[0] === "e" && a[1] === id)
- ) || []
- );
+export function getReactions(notes: TaggedRawEvent[], id: u256, kind = EventKind.Reaction) {
+ return notes?.filter(a => a.kind === kind && a.tags.some(a => a[0] === "e" && a[1] === id)) || [];
}
/**
@@ -171,10 +163,7 @@ export function debounce(timeout: number, fn: () => void) {
return () => clearTimeout(t);
}
-export function addIdAndDefaultMessageToMessages(
- messages: Record,
- messageIdPrefix: string
-) {
+export function addIdAndDefaultMessageToMessages(messages: Record, messageIdPrefix: string) {
const result: Record = {};
for (const key in messages) {
diff --git a/src/index.css b/src/index.css
index 2d8bf144..a6af9705 100644
--- a/src/index.css
+++ b/src/index.css
@@ -22,12 +22,7 @@
--gray-tertiary: #444;
--gray-dark: #2b2b2b;
--gray-superdark: #1a1a1a;
- --gray-gradient: linear-gradient(
- to bottom right,
- var(--gray-superlight),
- var(--gray),
- var(--gray-light)
- );
+ --gray-gradient: linear-gradient(to bottom right, var(--gray-superlight), var(--gray), var(--gray-light));
--snort-gradient: linear-gradient(90deg, #a178ff 0%, #ff6baf 108.33%);
--invoice-gradient: linear-gradient(
45deg,
@@ -41,12 +36,7 @@
rgba(161, 120, 255, 0.6),
rgba(255, 107, 175, 0.6) 108.33%
);
- --expired-invoice-gradient: linear-gradient(
- 45deg,
- var(--note-bg) 50%,
- var(--gray),
- var(--gray-superdark)
- );
+ --expired-invoice-gradient: linear-gradient(45deg, var(--note-bg) 50%, var(--gray), var(--gray-superdark));
--strike-army-gradient: linear-gradient(to bottom right, #ccff00, #a1c900);
}
@@ -71,18 +61,8 @@ html.light {
--gray-dark: #2b2b2b;
--gray-superdark: #eee;
- --invoice-gradient: linear-gradient(
- 45deg,
- var(--note-bg) 50%,
- rgb(247, 183, 51, 0.2),
- rgb(252, 74, 26, 0.2)
- );
- --paid-invoice-gradient: linear-gradient(
- 45deg,
- var(--note-bg) 50%,
- rgb(247, 183, 51, 0.6),
- rgb(252, 74, 26, 0.6)
- );
+ --invoice-gradient: linear-gradient(45deg, var(--note-bg) 50%, rgb(247, 183, 51, 0.2), rgb(252, 74, 26, 0.2));
+ --paid-invoice-gradient: linear-gradient(45deg, var(--note-bg) 50%, rgb(247, 183, 51, 0.6), rgb(252, 74, 26, 0.6));
}
body {
@@ -96,8 +76,7 @@ body {
}
code {
- font-family: source-code-pro, Menlo, Monaco, Consolas, "Courier New",
- monospace;
+ font-family: source-code-pro, Menlo, Monaco, Consolas, "Courier New", monospace;
}
.page {
diff --git a/src/service-worker.js b/src/service-worker.js
index 6240a119..1d75620f 100644
--- a/src/service-worker.js
+++ b/src/service-worker.js
@@ -11,9 +11,7 @@ precacheAndRoute(self.__WB_MANIFEST);
const staticTypes = ["image", "video", "audio"];
registerRoute(
- ({ request, url }) =>
- url.origin === self.location.origin &&
- staticTypes.includes(request.destination),
+ ({ request, url }) => url.origin === self.location.origin && staticTypes.includes(request.destination),
new StaleWhileRevalidate({
cacheName: "static-content",
plugins: [new ExpirationPlugin({ maxEntries: 50 })],
@@ -21,14 +19,7 @@ registerRoute(
);
// External media domains which have unique urls (never changing content) and can be cached forever
-const externalMediaHosts = [
- "void.cat",
- "nostr.build",
- "imgur.com",
- "i.imgur.com",
- "pbs.twimg.com",
- "i.ibb.co",
-];
+const externalMediaHosts = ["void.cat", "nostr.build", "imgur.com", "i.imgur.com", "pbs.twimg.com", "i.ibb.co"];
registerRoute(
({ url }) => externalMediaHosts.includes(url.host),
new CacheFirst({
@@ -36,7 +27,7 @@ registerRoute(
})
);
-self.addEventListener("message", (event) => {
+self.addEventListener("message", event => {
if (event.data && event.data.type === "SKIP_WAITING") {
self.skipWaiting();
}
diff --git a/src/serviceWorkerRegistration.js b/src/serviceWorkerRegistration.js
index fd0e8c5a..e1b8889c 100644
--- a/src/serviceWorkerRegistration.js
+++ b/src/serviceWorkerRegistration.js
@@ -15,9 +15,7 @@ const isLocalhost = Boolean(
// [::1] is the IPv6 localhost address.
window.location.hostname === "[::1]" ||
// 127.0.0.0/8 are considered localhost for IPv4.
- window.location.hostname.match(
- /^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/
- )
+ window.location.hostname.match(/^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/)
);
export function register(config) {
@@ -57,7 +55,7 @@ export function register(config) {
function registerValidSW(swUrl, config) {
navigator.serviceWorker
.register(swUrl)
- .then((registration) => {
+ .then(registration => {
registration.onupdatefound = () => {
const installingWorker = registration.installing;
if (installingWorker == null) {
@@ -93,7 +91,7 @@ function registerValidSW(swUrl, config) {
};
};
})
- .catch((error) => {
+ .catch(error => {
console.error("Error during service worker registration:", error);
});
}
@@ -103,15 +101,12 @@ function checkValidServiceWorker(swUrl, config) {
fetch(swUrl, {
headers: { "Service-Worker": "script" },
})
- .then((response) => {
+ .then(response => {
// Ensure service worker exists, and that we really are getting a JS file.
const contentType = response.headers.get("content-type");
- if (
- response.status === 404 ||
- (contentType != null && contentType.indexOf("javascript") === -1)
- ) {
+ if (response.status === 404 || (contentType != null && contentType.indexOf("javascript") === -1)) {
// No service worker found. Probably a different app. Reload the page.
- navigator.serviceWorker.ready.then((registration) => {
+ navigator.serviceWorker.ready.then(registration => {
registration.unregister().then(() => {
window.location.reload();
});
@@ -122,19 +117,17 @@ function checkValidServiceWorker(swUrl, config) {
}
})
.catch(() => {
- console.log(
- "No internet connection found. App is running in offline mode."
- );
+ console.log("No internet connection found. App is running in offline mode.");
});
}
export function unregister() {
if ("serviceWorker" in navigator) {
navigator.serviceWorker.ready
- .then((registration) => {
+ .then(registration => {
registration.unregister();
})
- .catch((error) => {
+ .catch(error => {
console.error(error.message);
});
}