small hashtag fixes

This commit is contained in:
hzrd149 2023-07-14 15:17:02 -05:00
parent fb1f242b7c
commit b8a3fd1513
6 changed files with 24 additions and 13 deletions

View File

@ -0,0 +1,5 @@
---
"nostrudel": patch
---
small fix for hashtags

View File

@ -3,4 +3,4 @@ export const matchImageUrls =
/https?:\/\/([\dA-z\.-]+\.[A-z\.]{2,12})((?:\/[\+~%\/\.\w\-_]*)?\.(?:svg|gif|png|jpg|jpeg|webp|avif))(\??(?:[\?#\-\+=&;%@\.\w_]*)#?(?:[\-\.\!\/\\\w]*))?/i;
export const matchNostrLink = /(nostr:|@)?((npub|note|nprofile|nevent)1[qpzry9x8gf2tvdw0s3jn54khce6mua7l]{58,})/i;
export const matchHashtag = /(^|\s)#([^\s#]+)/i;
export const matchHashtag = /(^|[^\p{L}])#(\p{L}+)/iu;

View File

@ -23,6 +23,7 @@ import { truncatedId } from "../../helpers/nostr-event";
import QrScannerModal from "../../components/qr-scanner-modal";
import { safeDecode } from "../../helpers/nip19";
import { useInvoiceModalContext } from "../../providers/invoice-modal";
import { matchHashtag } from "../../helpers/regexp";
type relay = string;
type NostrBandSearchResults = {
@ -91,13 +92,20 @@ export default function SearchView() {
}, [searchParams]);
const handleSearchText = (text: string) => {
if (text.startsWith("nostr:") || text.startsWith("web+nostr:") || safeDecode(search)) {
const cleanText = text.trim();
if (cleanText.startsWith("nostr:") || cleanText.startsWith("web+nostr:") || safeDecode(search)) {
navigate({ pathname: "/l/" + encodeURIComponent(text) }, { replace: true });
} else if (text.trim().match(/^#(\w+)/i)) {
navigate({ pathname: "/t/" + text.toLowerCase().trim().replace(/^#/, "") });
} else {
setSearchParams({ q: text }, { replace: true });
return;
}
const hashTagMatch = cleanText.match(matchHashtag);
if (hashTagMatch) {
navigate({ pathname: "/t/" + hashTagMatch[2].toLocaleLowerCase() });
return;
}
setSearchParams({ q: cleanText }, { replace: true });
};
const readClipboard = useCallback(async () => {

View File

@ -18,14 +18,14 @@ function FollowerItem({ index, style, data: followers }: ListChildComponentProps
);
}
const UserFollowersTab = () => {
export default function UserFollowersTab() {
const { pubkey } = useOutletContext() as { pubkey: string };
const relays = useReadRelayUrls(useAdditionalRelayContext());
const followers = useUserFollowers(pubkey, relays, true);
return (
<Flex gap="2" direction="column" overflowY="auto" p="2" h="full">
<Flex gap="2" direction="column" p="2" h="90vh">
{followers ? (
<Box flex={1}>
<AutoSizer disableWidth>
@ -49,6 +49,4 @@ const UserFollowersTab = () => {
)}
</Flex>
);
};
export default UserFollowersTab;
}

View File

@ -24,7 +24,7 @@ export default function UserFollowingTab() {
const contacts = useUserContacts(pubkey, contextRelays, true);
return (
<Flex gap="2" direction="column" overflowY="auto" p="2" h="full">
<Flex gap="2" direction="column" p="2" h="90vh">
{contacts ? (
<Box flex={1}>
<AutoSizer disableWidth>

View File

@ -109,7 +109,7 @@ const UserView = () => {
flexGrow="1"
isLazy
index={activeTab}
onChange={(v) => navigate(tabs[v].path)}
onChange={(v) => navigate(tabs[v].path, { replace: true })}
colorScheme="brand"
>
<TabList overflowX="auto" overflowY="hidden" flexShrink={0}>