fixed ssr errors
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
import { platform } from '@tauri-apps/api/os';
|
||||
import { ArrowLeft, ArrowRight, Refresh } from 'iconoir-react';
|
||||
import { useLayoutEffect, useState } from 'react';
|
||||
import { useCallback, useEffect, useState } from 'react';
|
||||
|
||||
export default function AppActions() {
|
||||
const [os, setOS] = useState('');
|
||||
@@ -17,13 +16,23 @@ export default function AppActions() {
|
||||
window.location.reload();
|
||||
};
|
||||
|
||||
useLayoutEffect(() => {
|
||||
const getPlatform = async () => {
|
||||
const result = await platform();
|
||||
setOS(result);
|
||||
};
|
||||
const getPlatform = useCallback(async () => {
|
||||
const { platform } = await import('@tauri-apps/api/os');
|
||||
const result = await platform();
|
||||
|
||||
getPlatform().catch(console.error);
|
||||
setOS(result);
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
let ignore = false;
|
||||
|
||||
if (!ignore) {
|
||||
getPlatform().catch(console.error);
|
||||
}
|
||||
|
||||
return () => {
|
||||
ignore = true;
|
||||
};
|
||||
}, []);
|
||||
|
||||
return (
|
||||
|
||||
@@ -7,7 +7,7 @@ export const ChannelListItem = ({ data }: { data: any }) => {
|
||||
|
||||
return (
|
||||
<a
|
||||
href={`channel?id=${data.event_id}`}
|
||||
href={`/channel?id=${data.event_id}`}
|
||||
className="inline-flex items-center gap-2 rounded-md px-2.5 py-1.5 hover:bg-zinc-900"
|
||||
>
|
||||
<div className="relative h-5 w-5 shrink-0 rounded">
|
||||
|
||||
@@ -11,7 +11,7 @@ import { useEffect, useState } from 'react';
|
||||
export default function ChatList() {
|
||||
const [list, setList] = useState([]);
|
||||
const [activeAccount]: any = useLocalStorage('account', {});
|
||||
const profile = JSON.parse(activeAccount.metadata);
|
||||
const profile = activeAccount.metadata ? JSON.parse(activeAccount.metadata) : null;
|
||||
|
||||
useEffect(() => {
|
||||
let ignore = false;
|
||||
|
||||
@@ -13,7 +13,7 @@ import { useCallback, useContext, useEffect, useRef } from 'react';
|
||||
|
||||
export default function EventCollector() {
|
||||
const [pool, relays]: any = useContext(RelayContext);
|
||||
const [activeAccount]: any = useLocalStorage('account', {});
|
||||
const [activeAccount]: any = useLocalStorage('account', null);
|
||||
|
||||
const setHasNewerNote = useSetAtom(hasNewerNoteAtom);
|
||||
const follows = JSON.parse(activeAccount.follows);
|
||||
@@ -106,7 +106,15 @@ export default function EventCollector() {
|
||||
}, [activeAccount.pubkey, activeAccount.id, follows, pool, relays, setHasNewerNote]);
|
||||
|
||||
useEffect(() => {
|
||||
subscribe();
|
||||
let ignore = false;
|
||||
|
||||
if (!ignore) {
|
||||
subscribe();
|
||||
}
|
||||
|
||||
return () => {
|
||||
ignore = true;
|
||||
};
|
||||
}, [setHasNewerNote, subscribe]);
|
||||
|
||||
return <NetworkStatusIndicator />;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { memo } from 'react';
|
||||
import ReactPlayer from 'react-player/lazy';
|
||||
import ReactPlayer from 'react-player';
|
||||
|
||||
export const VideoPreview = memo(function VideoPreview({ url }: { url: string }) {
|
||||
return (
|
||||
|
||||
Reference in New Issue
Block a user