Enhance content management and user interaction features
- Introduced a new content source toggle in the profile and app header to switch between IndeeHub and TopDoc films. - Updated the content fetching logic to dynamically load content based on the selected source. - Enhanced the seeding process to include a combined catalog of IndeeHub and TopDoc films, ensuring diverse content availability. - Improved user interaction by preventing duplicate reactions and ensuring a smoother voting experience across comments and content. - Added support for Amber login (NIP-55) for Android users, integrating it into the existing authentication flow. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -2,8 +2,10 @@ import { defineStore } from 'pinia'
|
||||
import { ref } from 'vue'
|
||||
import type { Content } from '../types/content'
|
||||
import { indeeHubFilms, bitcoinFilms, documentaries, dramas } from '../data/indeeHubFilms'
|
||||
import { topDocFilms, topDocBitcoin, topDocCrypto, topDocMoney, topDocEconomics } from '../data/topDocFilms'
|
||||
import { contentService } from '../services/content.service'
|
||||
import { mapApiProjectsToContents } from '../utils/mappers'
|
||||
import { useContentSourceStore } from './contentSource'
|
||||
|
||||
const USE_MOCK_DATA = import.meta.env.VITE_USE_MOCK_DATA === 'true' || import.meta.env.DEV
|
||||
|
||||
@@ -67,10 +69,9 @@ export const useContentStore = defineStore('content', () => {
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch content from mock data
|
||||
* Fetch IndeeHub mock content (original catalog)
|
||||
*/
|
||||
function fetchContentFromMock() {
|
||||
// Set featured content immediately - God Bless Bitcoin
|
||||
function fetchIndeeHubMock() {
|
||||
const godBlessBitcoin = bitcoinFilms.find(f => f.title === 'God Bless Bitcoin') || bitcoinFilms[0]
|
||||
if (godBlessBitcoin) {
|
||||
featuredContent.value = {
|
||||
@@ -81,7 +82,6 @@ export const useContentStore = defineStore('content', () => {
|
||||
featuredContent.value = indeeHubFilms[0]
|
||||
}
|
||||
|
||||
// Organize content into rows
|
||||
contentRows.value = {
|
||||
featured: indeeHubFilms.slice(0, 10),
|
||||
newReleases: indeeHubFilms.slice(0, 8).reverse(),
|
||||
@@ -94,6 +94,34 @@ export const useContentStore = defineStore('content', () => {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch TopDocumentaryFilms mock content
|
||||
*/
|
||||
function fetchTopDocMock() {
|
||||
featuredContent.value = topDocFilms[0]
|
||||
|
||||
contentRows.value = {
|
||||
featured: topDocFilms.slice(0, 10),
|
||||
newReleases: [...topDocFilms].sort((a, b) => (b.releaseYear ?? 0) - (a.releaseYear ?? 0)).slice(0, 8),
|
||||
bitcoin: topDocBitcoin,
|
||||
documentaries: topDocEconomics.slice(0, 10),
|
||||
dramas: topDocMoney,
|
||||
independent: topDocCrypto.slice(0, 10)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Route to the correct mock loader based on the active content source
|
||||
*/
|
||||
function fetchContentFromMock() {
|
||||
const sourceStore = useContentSourceStore()
|
||||
if (sourceStore.activeSource === 'topdocfilms') {
|
||||
fetchTopDocMock()
|
||||
} else {
|
||||
fetchIndeeHubMock()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Main fetch content method
|
||||
*/
|
||||
|
||||
26
src/stores/contentSource.ts
Normal file
26
src/stores/contentSource.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
import { defineStore } from 'pinia'
|
||||
import { ref, watch } from 'vue'
|
||||
|
||||
export type ContentSourceId = 'indeehub' | 'topdocfilms'
|
||||
|
||||
const STORAGE_KEY = 'indeedhub:content-source'
|
||||
|
||||
export const useContentSourceStore = defineStore('contentSource', () => {
|
||||
const saved = localStorage.getItem(STORAGE_KEY) as ContentSourceId | null
|
||||
const activeSource = ref<ContentSourceId>(saved === 'topdocfilms' ? 'topdocfilms' : 'indeehub')
|
||||
|
||||
// Persist to localStorage on change
|
||||
watch(activeSource, (v) => {
|
||||
localStorage.setItem(STORAGE_KEY, v)
|
||||
})
|
||||
|
||||
function setSource(source: ContentSourceId) {
|
||||
activeSource.value = source
|
||||
}
|
||||
|
||||
function toggle() {
|
||||
activeSource.value = activeSource.value === 'indeehub' ? 'topdocfilms' : 'indeehub'
|
||||
}
|
||||
|
||||
return { activeSource, setSource, toggle }
|
||||
})
|
||||
Reference in New Issue
Block a user