Add Rideshare functionality to NostrFeed module
- Introduced a new RideshareComposer component for creating rideshare posts, allowing users to specify ride details such as type, locations, date, time, and contact methods. - Enhanced NostrFeed.vue to display rideshare badges for relevant posts, improving visibility and categorization of rideshare content. - Updated Home.vue to integrate the RideshareComposer, providing users with an option to compose rideshare requests or offers alongside regular notes. These changes enhance the user experience by facilitating rideshare interactions within the NostrFeed module, promoting community engagement.
This commit is contained in:
parent
667a7c2d89
commit
dfd3ddd112
3 changed files with 564 additions and 10 deletions
|
|
@ -92,6 +92,44 @@ function isAdminPost(pubkey: string): boolean {
|
|||
return adminPubkeys.includes(pubkey)
|
||||
}
|
||||
|
||||
// Check if a post is a rideshare post
|
||||
function isRidesharePost(note: any): boolean {
|
||||
// Check for rideshare tags
|
||||
const hasTags = note.tags?.some((tag: string[]) =>
|
||||
tag[0] === 't' && ['rideshare', 'carpool'].includes(tag[1])
|
||||
) || false
|
||||
|
||||
// Check for rideshare-specific custom tags
|
||||
const hasRideshareTypeTags = note.tags?.some((tag: string[]) =>
|
||||
tag[0] === 'rideshare_type' && ['offering', 'seeking'].includes(tag[1])
|
||||
) || false
|
||||
|
||||
// Check content for rideshare keywords (fallback)
|
||||
const hasRideshareContent = note.content && (
|
||||
note.content.includes('🚗 OFFERING RIDE') ||
|
||||
note.content.includes('🚶 SEEKING RIDE') ||
|
||||
note.content.includes('#rideshare') ||
|
||||
note.content.includes('#carpool')
|
||||
)
|
||||
|
||||
return hasTags || hasRideshareTypeTags || hasRideshareContent
|
||||
}
|
||||
|
||||
// Get rideshare type from post
|
||||
function getRideshareType(note: any): string | null {
|
||||
// Check custom tags first
|
||||
const typeTag = note.tags?.find((tag: string[]) => tag[0] === 'rideshare_type')
|
||||
if (typeTag) {
|
||||
return typeTag[1] === 'offering' ? 'Offering Ride' : 'Seeking Ride'
|
||||
}
|
||||
|
||||
// Fallback to content analysis
|
||||
if (note.content?.includes('🚗 OFFERING RIDE')) return 'Offering Ride'
|
||||
if (note.content?.includes('🚶 SEEKING RIDE')) return 'Seeking Ride'
|
||||
|
||||
return 'Rideshare'
|
||||
}
|
||||
|
||||
// Get market product data for market events
|
||||
function getMarketProductData(note: any) {
|
||||
if (note.kind === 30018) {
|
||||
|
|
@ -281,6 +319,13 @@ async function onToggleLike(note: any) {
|
|||
>
|
||||
{{ getMarketEventType({ kind: note.kind }) }}
|
||||
</Badge>
|
||||
<Badge
|
||||
v-if="isRidesharePost(note)"
|
||||
variant="secondary"
|
||||
class="text-xs px-1.5 py-0.5 bg-blue-100 text-blue-800 dark:bg-blue-900 dark:text-blue-200"
|
||||
>
|
||||
🚗 {{ getRideshareType(note) }}
|
||||
</Badge>
|
||||
<span class="text-sm font-medium">{{ getDisplayName(note.pubkey) }}</span>
|
||||
</div>
|
||||
<span class="text-xs text-muted-foreground">
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue