Service worker precache
Yarn upgrades / cleanup
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
import { EventKind, NostrEvent, RequestBuilder, TaggedRawEvent } from "@snort/system";
|
||||
import { EventKind, NostrEvent, RequestBuilder, TaggedNostrEvent } from "@snort/system";
|
||||
import { RefreshFeedCache, TWithCreated } from "./RefreshFeedCache";
|
||||
import { LoginSession } from "Login";
|
||||
import { unixNow } from "SnortUtils";
|
||||
@ -21,7 +21,7 @@ export class NotificationsCache extends RefreshFeedCache<NostrEvent> {
|
||||
}
|
||||
}
|
||||
|
||||
async onEvent(evs: readonly TaggedRawEvent[]) {
|
||||
async onEvent(evs: readonly TaggedNostrEvent[]) {
|
||||
const filtered = evs.filter(a => this.#kinds.includes(a.kind) && a.tags.some(b => b[0] === "p"));
|
||||
if (filtered.length > 0) {
|
||||
await this.bulkSet(filtered);
|
||||
|
@ -1,12 +1,12 @@
|
||||
import { FeedCache } from "@snort/shared";
|
||||
import { RequestBuilder, TaggedRawEvent } from "@snort/system";
|
||||
import { RequestBuilder, TaggedNostrEvent } from "@snort/system";
|
||||
import { LoginSession } from "Login";
|
||||
|
||||
export type TWithCreated<T> = T & { created_at: number };
|
||||
|
||||
export abstract class RefreshFeedCache<T> extends FeedCache<TWithCreated<T>> {
|
||||
abstract buildSub(session: LoginSession, rb: RequestBuilder): void;
|
||||
abstract onEvent(evs: Readonly<Array<TaggedRawEvent>>): void;
|
||||
abstract onEvent(evs: Readonly<Array<TaggedNostrEvent>>): void;
|
||||
|
||||
/**
|
||||
* Get latest event
|
||||
|
@ -1,19 +0,0 @@
|
||||
import Hls from "hls.js";
|
||||
import { HTMLProps, useEffect, useRef } from "react";
|
||||
|
||||
export function LiveVideoPlayer(props: HTMLProps<HTMLVideoElement> & { stream: string }) {
|
||||
const video = useRef<HTMLVideoElement>(null);
|
||||
useEffect(() => {
|
||||
if (props.stream && video.current && !video.current.src && Hls.isSupported()) {
|
||||
const hls = new Hls();
|
||||
hls.loadSource(props.stream);
|
||||
hls.attachMedia(video.current);
|
||||
return () => hls.destroy();
|
||||
}
|
||||
}, [video, props]);
|
||||
return (
|
||||
<div>
|
||||
<video ref={video} {...props} controls={true} />
|
||||
</div>
|
||||
);
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
import { FormattedMessage, useIntl } from "react-intl";
|
||||
import { HexKey, Lists, NostrPrefix, TaggedRawEvent, encodeTLV } from "@snort/system";
|
||||
import { HexKey, Lists, NostrPrefix, TaggedNostrEvent, encodeTLV } from "@snort/system";
|
||||
import { Menu, MenuItem } from "@szhsin/react-menu";
|
||||
import { useDispatch, useSelector } from "react-redux";
|
||||
|
||||
@ -26,7 +26,7 @@ export interface NoteTranslation {
|
||||
}
|
||||
|
||||
interface NosteContextMenuProps {
|
||||
ev: TaggedRawEvent;
|
||||
ev: TaggedNostrEvent;
|
||||
setShowReactions(b: boolean): void;
|
||||
react(content: string): Promise<void>;
|
||||
onTranslated?: (t: NoteTranslation) => void;
|
||||
|
@ -33,7 +33,7 @@ const UserItem = (metadata: MetadataCache) => {
|
||||
return (
|
||||
<div key={pubkey} className="user-item">
|
||||
<div className="user-picture">
|
||||
<Avatar user={metadata} />
|
||||
<Avatar pubkey={pubkey} user={metadata} />
|
||||
</div>
|
||||
<div className="user-details">
|
||||
<strong>{display_name || rest.name}</strong>
|
||||
|
@ -145,7 +145,7 @@ function ProfileDmActions({ id }: { id: string }) {
|
||||
const blocked = isBlocked(pubkey);
|
||||
return (
|
||||
<>
|
||||
<Avatar user={profile} size={210} />
|
||||
<Avatar pubkey={pubkey} user={profile} size={210} />
|
||||
<h2>{getDisplayName(profile, pubkey)}</h2>
|
||||
<p>
|
||||
<Text content={truncAbout(profile?.about) ?? ""} tags={[]} creator={pubkey} disableMedia={true} depth={0} />
|
||||
|
@ -39,7 +39,8 @@ const PreferencesPage = () => {
|
||||
|
||||
useEffect(() => {
|
||||
(async () => {
|
||||
setEmoji((await searchEmoji("")).map(a => ({ name: a.name, char: a.char })));
|
||||
const allEmoji = await searchEmoji("");
|
||||
setEmoji(allEmoji.map(a => ({ name: a.name, char: a.char })));
|
||||
})();
|
||||
}, []);
|
||||
|
||||
|
@ -9,7 +9,7 @@ import {
|
||||
SystemInterface,
|
||||
TLVEntry,
|
||||
TLVEntryType,
|
||||
TaggedRawEvent,
|
||||
TaggedNostrEvent,
|
||||
UserMetadata,
|
||||
encodeTLVEntries,
|
||||
} from "@snort/system";
|
||||
@ -61,7 +61,7 @@ export interface ChatSystem {
|
||||
* Create a request for this system to get updates
|
||||
*/
|
||||
subscription(id: string): RequestBuilder | undefined;
|
||||
onEvent(evs: readonly TaggedRawEvent[]): Promise<void> | void;
|
||||
onEvent(evs: readonly TaggedNostrEvent[]): Promise<void> | void;
|
||||
|
||||
listChats(pk: string): Array<Chat>;
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { ExternalStore, FeedCache, dedupe } from "@snort/shared";
|
||||
import { RequestBuilder, NostrEvent, EventKind, SystemInterface, TaggedRawEvent } from "@snort/system";
|
||||
import { RequestBuilder, NostrEvent, EventKind, SystemInterface, TaggedNostrEvent } from "@snort/system";
|
||||
import { unwrap } from "SnortUtils";
|
||||
import { Chat, ChatSystem, ChatType, lastReadInChat } from "chat";
|
||||
|
||||
@ -31,7 +31,7 @@ export class Nip29ChatSystem extends ExternalStore<Array<Chat>> implements ChatS
|
||||
return rb;
|
||||
}
|
||||
|
||||
async onEvent(evs: readonly TaggedRawEvent[]) {
|
||||
async onEvent(evs: readonly TaggedNostrEvent[]) {
|
||||
const msg = evs.filter(a => a.kind === EventKind.SimpleChatMessage && a.tags.some(b => b[0] === "g"));
|
||||
if (msg.length > 0) {
|
||||
await this.#cache.bulkSet(msg);
|
||||
|
@ -7,6 +7,7 @@ import * as ReactDOM from "react-dom/client";
|
||||
import { Provider } from "react-redux";
|
||||
import { createBrowserRouter, RouterProvider } from "react-router-dom";
|
||||
import { EventPublisher, NostrSystem, ProfileLoaderService, Nip7Signer, PowWorker } from "@snort/system";
|
||||
import { SnortContext } from "@snort/system-react";
|
||||
|
||||
import * as serviceWorkerRegistration from "serviceWorkerRegistration";
|
||||
import { IntlProvider } from "IntlProvider";
|
||||
@ -34,7 +35,6 @@ import DebugPage from "Pages/Debug";
|
||||
import { db } from "Db";
|
||||
import { preload, RelayMetrics, UserCache, UserRelays } from "Cache";
|
||||
import { LoginStore } from "Login";
|
||||
import { SnortContext } from "@snort/system-react";
|
||||
|
||||
/**
|
||||
* Singleton nostr system
|
||||
@ -66,9 +66,6 @@ export const ProfileLoader = new ProfileLoaderService(System, UserCache);
|
||||
*/
|
||||
export const DefaultPowWorker = new PowWorker("/pow.js");
|
||||
|
||||
// @ts-expect-error Setting webpack nonce
|
||||
window.__webpack_nonce__ = "ZmlhdGphZiBzYWlkIHNub3J0LnNvY2lhbCBpcyBwcmV0dHkgZ29vZCwgd2UgbWFkZSBpdCE=";
|
||||
|
||||
serviceWorkerRegistration.register();
|
||||
|
||||
export const router = createBrowserRouter([
|
||||
|
@ -1,22 +1,14 @@
|
||||
/// <reference lib="webworker" />
|
||||
declare const self: ServiceWorkerGlobalScope;
|
||||
declare const self: ServiceWorkerGlobalScope & {
|
||||
__WB_MANIFEST: (string | PrecacheEntry)[]
|
||||
};
|
||||
|
||||
import { clientsClaim } from "workbox-core";
|
||||
import { registerRoute } from "workbox-routing";
|
||||
import { CacheFirst } from "workbox-strategies";
|
||||
import {PrecacheEntry, precacheAndRoute} from 'workbox-precaching';
|
||||
|
||||
precacheAndRoute(self.__WB_MANIFEST);
|
||||
clientsClaim();
|
||||
|
||||
const staticTypes = ["image", "video", "audio", "script", "style", "font"];
|
||||
const paths = ["/"];
|
||||
registerRoute(
|
||||
({ request, url }) =>
|
||||
url.origin === self.location.origin && (staticTypes.includes(request.destination) || paths.includes(url.pathname)),
|
||||
new CacheFirst({
|
||||
cacheName: "static-content",
|
||||
})
|
||||
);
|
||||
|
||||
self.addEventListener("message", event => {
|
||||
if (event.data && event.data.type === "SKIP_WAITING") {
|
||||
self.skipWaiting();
|
||||
|
@ -440,4 +440,4 @@
|
||||
"zjJZBd": "You're ready!",
|
||||
"zonsdq": "Failed to load LNURL service",
|
||||
"zvCDao": "Automatically show latest notes"
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user