This commit is contained in:
xds
2026-02-24 12:47:19 +03:00
parent a1d37ac517
commit 122c5a7cbc
5 changed files with 38 additions and 7 deletions

View File

@@ -52,9 +52,10 @@ export const aiService = {
},
// Get generations history
async getGenerations(limit, offset, characterId) {
async getGenerations(limit, offset, characterId, onlyLiked = false) {
const params = { limit, offset }
if (characterId) params.character_id = characterId
if (onlyLiked) params.only_liked = true
const response = await api.get('/generations', { params })
return response.data
},

View File

@@ -8,5 +8,9 @@ export const ideaService = {
deleteIdea: (id) => api.delete(`/ideas/${id}`),
addGenerationToIdea: (ideaId, generationId) => api.post(`/ideas/${ideaId}/generations/${generationId}`),
removeGenerationFromIdea: (ideaId, generationId) => api.delete(`/ideas/${ideaId}/generations/${generationId}`),
getIdeaGenerations: (ideaId, limit = 10, offset = 0) => api.get(`/ideas/${ideaId}/generations`, { params: { limit, offset } })
getIdeaGenerations: (ideaId, limit = 10, offset = 0, onlyLiked = false) => {
const params = { limit, offset };
if (onlyLiked) params.only_liked = true;
return api.get(`/ideas/${ideaId}/generations`, { params });
}
};

View File

@@ -133,9 +133,9 @@ export const useIdeaStore = defineStore('ideas', () => {
}
// Assuming getIdeaGenerations is separate from getIdea
async function fetchIdeaGenerations(ideaId, limit = 100, offset = 0) {
async function fetchIdeaGenerations(ideaId, limit = 100, offset = 0, onlyLiked = false) {
try {
const response = await ideaService.getIdeaGenerations(ideaId, limit, offset);
const response = await ideaService.getIdeaGenerations(ideaId, limit, offset, onlyLiked);
return response;
} catch (err) {
console.error('Error fetching idea generations:', err);

View File

@@ -201,6 +201,7 @@ watch(isSettingsVisible, (val) => {
const activeOverlayId = ref(null) // For mobile tap-to-show overlay
const filterCharacter = ref(null) // Character filter for gallery
const onlyLiked = ref(false)
// Options
const qualityOptions = ref([
@@ -287,6 +288,13 @@ watch(filterCharacter, async () => {
await refreshHistory()
})
watch(onlyLiked, async () => {
historyGenerations.value = []
historyTotal.value = 0
historyFirst.value = 0
await refreshHistory()
})
// --- Data Loading ---
const loadData = async () => {
@@ -364,7 +372,7 @@ const loadData = async () => {
const refreshHistory = async () => {
try {
const response = await aiService.getGenerations(historyRows.value, 0, filterCharacter.value?.id || filterCharacter.value?._id)
const response = await aiService.getGenerations(historyRows.value, 0, filterCharacter.value?.id || filterCharacter.value?._id, onlyLiked.value)
if (response && response.generations) {
// Update existing items and add new ones at the top
const newGenerations = []
@@ -525,7 +533,7 @@ const loadMoreHistory = async () => {
try {
const nextOffset = historyGenerations.value.length
const response = await aiService.getGenerations(historyRows.value, nextOffset, filterCharacter.value?.id)
const response = await aiService.getGenerations(historyRows.value, nextOffset, filterCharacter.value?.id, onlyLiked.value)
if (response && response.generations) {
const newGenerations = response.generations.filter(gen =>
@@ -880,6 +888,11 @@ const confirmAddToAlbum = async () => {
</div>
</template>
</Dropdown>
<Button :icon="onlyLiked ? 'pi pi-heart-fill' : 'pi pi-heart'"
@click="onlyLiked = !onlyLiked" rounded text
class="!w-7 !h-7 !p-0"
:class="onlyLiked ? '!text-pink-500 !bg-pink-500/10' : '!text-slate-400 hover:!bg-white/10'"
v-tooltip.bottom="onlyLiked ? 'Show all' : 'Show liked only'" />
<Button icon="pi pi-refresh" @click="refreshHistory" rounded text
class="!text-slate-400 hover:!bg-white/10 !w-7 !h-7 !p-0 md:hidden" />
<Button :icon="isSelectMode ? 'pi pi-times' : 'pi pi-check-square'" @click="toggleSelectMode"

View File

@@ -175,6 +175,7 @@ restoreSettings()
watch([prompt, quality, aspectRatio, imageCount, selectedModel, sendToTelegram, telegramId, useProfileImage, useEnvironment, selectedCharacter, selectedEnvironment, selectedAssets], saveSettings, { deep: true })
const viewMode = ref('feed') // 'feed' or 'gallery'
const onlyLiked = ref(false)
const isSubmitting = ref(false)
const isSettingsVisible = ref(localStorage.getItem('idea_detail_settings_visible') !== 'false')
@@ -255,7 +256,7 @@ const loadCharacters = async () => {
const fetchGenerations = async (ideaId) => {
loadingGenerations.value = true
try {
const response = await ideaStore.fetchIdeaGenerations(ideaId, 100)
const response = await ideaStore.fetchIdeaGenerations(ideaId, 100, onlyLiked.value)
let loadedGens = []
if (response.data && response.data.generations) {
loadedGens = response.data.generations
@@ -914,6 +915,12 @@ const toggleLike = async (gen) => {
}
}
watch(onlyLiked, (newVal) => {
if (currentIdea.value) {
fetchGenerations(currentIdea.value.id)
}
})
// Exit select mode when switching to feed
watch(viewMode, (v) => {
if (v !== 'gallery') {
@@ -969,6 +976,12 @@ watch(viewMode, (v) => {
</button>
</div>
<Button :icon="onlyLiked ? 'pi pi-heart-fill' : 'pi pi-heart'"
@click="onlyLiked = !onlyLiked" rounded text
class="!w-7 !h-7 !p-0"
:class="onlyLiked ? '!text-pink-500 !bg-pink-500/10' : '!text-slate-400 hover:!bg-white/10'"
v-tooltip.bottom="onlyLiked ? 'Show all' : 'Show liked only'" />
<Button icon="pi pi-trash" text rounded severity="danger" size="small"
class="!w-7 !h-7"
v-tooltip.bottom="'Delete Idea'"