@@ -234,29 +234,52 @@ const albumPanelConfig = computed<AlbumThumbConfig>(() => ({
234234const photoCallbacks = {
235235 star : () => {
236236 PhotoService .star (selectedPhotosIds .value , true );
237+ // Update the photos in the store immediately to reflect the change
238+ selectedPhotosIds .value .forEach ((photoId ) => {
239+ const photo = photosStore .photos .find ((p ) => p .id === photoId );
240+ if (photo ) {
241+ photo .is_starred = true ;
242+ }
243+ });
237244 AlbumService .clearCache (albumStore .album ?.id );
238- emits (" refresh" );
239245 },
240246 unstar : () => {
241247 PhotoService .star (selectedPhotosIds .value , false );
248+ // Update the photos in the store immediately to reflect the change
249+ selectedPhotosIds .value .forEach ((photoId ) => {
250+ const photo = photosStore .photos .find ((p ) => p .id === photoId );
251+ if (photo ) {
252+ photo .is_starred = false ;
253+ }
254+ });
242255 AlbumService .clearCache (albumStore .album ?.id );
243- emits (" refresh" );
244256 },
245257 setAsCover : () => {
246258 if (albumStore .album === undefined ) return ;
247259 PhotoService .setAsCover (selectedPhoto .value ! .id , albumStore .album .id );
248- // Update the album's cover_id immediately to reflect the change
260+ // Update the album's cover_id immediately to reflect the change (toggle behavior)
249261 if (albumStore .modelAlbum !== undefined ) {
250- albumStore .modelAlbum .cover_id = selectedPhoto .value ! .id ;
262+ albumStore .modelAlbum .cover_id = albumStore . modelAlbum . cover_id === selectedPhoto . value ! . id ? null : selectedPhoto .value ! .id ;
251263 }
252264 AlbumService .clearCache (albumStore .album .id );
253265 },
254266 setAsHeader : () => {
255267 if (albumStore .album === undefined ) return ;
256268 PhotoService .setAsHeader (selectedPhoto .value ! .id , albumStore .album .id , false );
257- // Update the album's header_id immediately to reflect the change
269+ // Update the album's header_id immediately to reflect the change (toggle behavior)
270+ const isToggleOff = albumStore .modelAlbum ?.header_id === selectedPhoto .value ! .id ;
258271 if (albumStore .modelAlbum !== undefined ) {
259- albumStore .modelAlbum .header_id = selectedPhoto .value ! .id ;
272+ albumStore .modelAlbum .header_id = isToggleOff ? null : selectedPhoto .value ! .id ;
273+ }
274+ // Update the header image URL in the album's preFormattedData
275+ if (albumStore .album .preFormattedData ) {
276+ if (isToggleOff ) {
277+ albumStore .album .preFormattedData .url = null ;
278+ } else {
279+ // Use medium or small variant for the header image
280+ const headerUrl = selectedPhoto .value ! .size_variants .medium ?.url ?? selectedPhoto .value ! .size_variants .small ?.url ?? null ;
281+ albumStore .album .preFormattedData .url = headerUrl ;
282+ }
260283 }
261284 AlbumService .clearCache (albumStore .album .id );
262285 },
@@ -289,6 +312,11 @@ const albumCallbacks = {
289312 if (albumStore .album === undefined ) return ;
290313 if (selectedAlbum .value ?.thumb ?.id === undefined ) return ;
291314 PhotoService .setAsCover (selectedAlbum .value ! .thumb ?.id , albumStore .album .id );
315+ // Update the album's cover_id immediately to reflect the change (toggle behavior)
316+ if (albumStore .modelAlbum !== undefined ) {
317+ albumStore .modelAlbum .cover_id =
318+ albumStore .modelAlbum .cover_id === selectedAlbum .value ! .thumb ?.id ? null : selectedAlbum .value ! .thumb ?.id ;
319+ }
292320 AlbumService .clearCache (albumStore .album .id );
293321 emits (" refresh" );
294322 },
0 commit comments