fix: Fixed title, added banner to home page

This commit is contained in:
florian 2024-03-08 12:53:06 +00:00
parent c358083737
commit a3525e05a2
4 changed files with 23 additions and 9 deletions

View File

@ -9,7 +9,6 @@
- move settings dialog to main start screen
- replace search icon with nav back button
- record demo explaination video
- global can not be accessed any more
- different header for multiple tags??
- navigation entry points:
- Search (custom hashtags, profile search, content search, community seaarch)

View File

@ -5,9 +5,12 @@ import { useGlobalState } from '../../utils/globalState';
import usePeopleLists from '../../utils/useLists';
import { createImgProxyUrl } from '../nostrImageDownload';
import { useState } from 'react';
import { Helmet } from 'react-helmet';
import useProfile from '../../utils/useProfile';
const Home = () => {
const { nav, currentSettings } = useNav();
const { title } = useProfile(currentSettings);
const [showAdult, setShowAdult] = useState(currentSettings.showAdult || false);
const [state] = useGlobalState();
const topicKeys = Object.keys(topics);
@ -15,6 +18,9 @@ const Home = () => {
return (
<div className="home-container">
<Helmet>
<title>{title}</title>
</Helmet>
<div className="home">
<h2>Topics</h2>
<div className="topics">
@ -74,7 +80,11 @@ const Home = () => {
</div>
<div
className="topic"
style={{}}
style={{
backgroundImage:
state.profile?.banner &&
`linear-gradient(170deg, rgba(0, 0, 0, .8) 0%, rgba(0, 0, 0, 0) 50%, rgba(0, 0, 0, 0) 100%), url(${createImgProxyUrl(state.profile?.banner, 600, -1)})`,
}}
onClick={() =>
nav({
...currentSettings,

View File

@ -15,7 +15,7 @@ export default function useEvents(filter: NDKFilter | NDKFilter[], opts?: Subscr
const [eose, setEose] = useState(false);
const [events, setEvents] = useState<NDKEvent[]>([]);
const id = useMemo(() => {
console.warn('new ID!!!');
// console.warn('new ID!!!');
return hashSha256(filter);
}, [filter]);

View File

@ -1,32 +1,37 @@
import { appName } from '../components/env';
import { appName, topics } from '../components/env';
import { useEffect, useState } from 'react';
import { Settings } from './useNav';
import { NostrImage } from '../components/nostrImageDownload';
import useProfileNgine from '../ngine/hooks/useProfile';
import { nip19 } from 'nostr-tools';
import { NDKSubscriptionCacheUsage } from '@nostr-dev-kit/ndk';
import { useLocation, useParams } from 'react-router-dom';
// TODO maybe remove profile and only build title here?? useTitle?
const useProfile = (settings: Settings, activeImage?: NostrImage) => {
const [title, setTitle] = useState(appName);
const location = useLocation();
const { topic } = useParams();
const profileNpub = settings.npubs.length == 1 ? settings.npubs[0] : activeImage && activeImage?.author;
const pubKeyHex = profileNpub ? (nip19.decode(profileNpub).data as string) : '';
const activeProfile = useProfileNgine(pubKeyHex, NDKSubscriptionCacheUsage.ONLY_RELAY);
// console.log({profileNpub, pubKeyHex, activeProfile})
useEffect(() => {
if (settings.npubs.length > 0 && activeProfile && (activeProfile.displayName || activeProfile.name)) {
setTitle((activeProfile.displayName || activeProfile.name) + ` | ${appName}`);
} else if (settings.tags && settings.tags.length > 0) {
setTitle('#' + settings.tags.join(' #') + ` | ${appName}`);
} else {
setTitle(`Random photos from popular hashtags | ${appName}`);
} else if (topic) {
setTitle(`${topics[topic].name} | ${appName}`);
} else if (location.pathname == '/global') {
setTitle(`Global | ${appName}`);
} else if (location.pathname == '/') {
setTitle(`Home | ${appName}`);
}
}, [activeProfile, settings.npubs, settings.tags]);
}, [activeProfile, settings.npubs, settings.tags, topic, location]);
return {
activeProfile,