fix: init after login
This commit is contained in:
@ -41,7 +41,6 @@ export function VideoTile({
|
|||||||
const bestVideo = video.bestVideo();
|
const bestVideo = video.bestVideo();
|
||||||
const [hasImg, setHasImage] = useState(true);
|
const [hasImg, setHasImage] = useState(true);
|
||||||
if (!liveMedia) return;
|
if (!liveMedia) return;
|
||||||
console.debug(liveMedia)
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className={classNames("flex gap-2", className, {
|
className={classNames("flex gap-2", className, {
|
||||||
|
@ -40,7 +40,7 @@ export function useDeadLink(ev: TaggedNostrEvent | NostrEvent) {
|
|||||||
if (alt && alive) {
|
if (alt && alive) {
|
||||||
return {
|
return {
|
||||||
...pl,
|
...pl,
|
||||||
url: alt
|
url: alt,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -57,13 +57,14 @@ export function useDeadLink(ev: TaggedNostrEvent | NostrEvent) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const links = ev.kind === VIDEO_KIND || ev.kind === SHORTS_KIND ?
|
const links =
|
||||||
VideoInfo.parse(ev)?.sources() :
|
ev.kind === VIDEO_KIND || ev.kind === SHORTS_KIND
|
||||||
[
|
? VideoInfo.parse(ev)?.sources()
|
||||||
|
: [
|
||||||
{
|
{
|
||||||
url: findTag(ev, "streaming") ?? findTag(ev, "recording"),
|
url: findTag(ev, "streaming") ?? findTag(ev, "recording"),
|
||||||
alternatives: []
|
alternatives: [],
|
||||||
} as MediaPayload
|
} as MediaPayload,
|
||||||
];
|
];
|
||||||
|
|
||||||
getLiveLink(links).catch(console.error);
|
getLiveLink(links).catch(console.error);
|
||||||
|
17
src/login.ts
17
src/login.ts
@ -32,13 +32,8 @@ export class LoginStore extends ExternalStore<LoginSession | undefined> {
|
|||||||
this.#session = JSON.parse(json);
|
this.#session = JSON.parse(json);
|
||||||
if (this.#session) {
|
if (this.#session) {
|
||||||
let save = false;
|
let save = false;
|
||||||
this.#session.state = new UserState(
|
this.#session.state = this.#makeState();
|
||||||
this.#session?.pubkey,
|
this.#session.state?.on("change", () => {
|
||||||
undefined,
|
|
||||||
this.#session.state as UserStateObject<never> | undefined,
|
|
||||||
);
|
|
||||||
|
|
||||||
this.#session.state.on("change", () => {
|
|
||||||
this.#save();
|
this.#save();
|
||||||
});
|
});
|
||||||
//reset
|
//reset
|
||||||
@ -67,11 +62,18 @@ export class LoginStore extends ExternalStore<LoginSession | undefined> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#makeState() {
|
||||||
|
if (this.#session) {
|
||||||
|
return new UserState(this.#session.pubkey, undefined, this.#session.state as UserStateObject<never> | undefined);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
loginWithPubkey(pk: string, type = LoginType.Nip7) {
|
loginWithPubkey(pk: string, type = LoginType.Nip7) {
|
||||||
this.#session = {
|
this.#session = {
|
||||||
type,
|
type,
|
||||||
pubkey: pk,
|
pubkey: pk,
|
||||||
};
|
};
|
||||||
|
this.#session.state = this.#makeState();
|
||||||
this.#save();
|
this.#save();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -81,6 +83,7 @@ export class LoginStore extends ExternalStore<LoginSession | undefined> {
|
|||||||
pubkey: bytesToHex(schnorr.getPublicKey(key)),
|
pubkey: bytesToHex(schnorr.getPublicKey(key)),
|
||||||
privateKey: key,
|
privateKey: key,
|
||||||
};
|
};
|
||||||
|
this.#session.state = this.#makeState();
|
||||||
this.#save();
|
this.#save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ export function LayoutPage() {
|
|||||||
login.state.checkIsStandardList(USER_CARDS);
|
login.state.checkIsStandardList(USER_CARDS);
|
||||||
login.state.init(login.signer(), system);
|
login.state.init(login.signer(), system);
|
||||||
}
|
}
|
||||||
}, []);
|
}, [login]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
trackEvent("pageview");
|
trackEvent("pageview");
|
||||||
|
Reference in New Issue
Block a user