Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 9bd298a160 | |||
| f78b151b64 | |||
| dfd9ed988e | |||
| a25f14e1b9 |
@@ -16,9 +16,6 @@ import {
|
|||||||
mdiCloudKeyOutline,
|
mdiCloudKeyOutline,
|
||||||
mdiRegex,
|
mdiRegex,
|
||||||
mdiCodeJson,
|
mdiCodeJson,
|
||||||
mdiClockOutline,
|
|
||||||
mdiAccountOutline,
|
|
||||||
mdiRestart,
|
|
||||||
} from '@mdi/js';
|
} from '@mdi/js';
|
||||||
import Layout from '@theme/Layout';
|
import Layout from '@theme/Layout';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
@@ -29,42 +26,6 @@ const withLanguage = (date: Date) => (language: string) => date.toLocaleDateStri
|
|||||||
type Item = Omit<TimelineItem, 'done' | 'getDateLabel'> & { date: Date };
|
type Item = Omit<TimelineItem, 'done' | 'getDateLabel'> & { date: Date };
|
||||||
|
|
||||||
const items: Item[] = [
|
const items: Item[] = [
|
||||||
{
|
|
||||||
icon: mdiClockOutline,
|
|
||||||
iconColor: 'gray',
|
|
||||||
title: 'setTimeout is cursed',
|
|
||||||
description:
|
|
||||||
'The setTimeout method in JavaScript is cursed when used with small values because the implementation may or may not actually wait the specified time.',
|
|
||||||
link: {
|
|
||||||
url: 'https://github.com/immich-app/immich/pull/20655',
|
|
||||||
text: '#20655',
|
|
||||||
},
|
|
||||||
date: new Date(2025, 7, 4),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
icon: mdiAccountOutline,
|
|
||||||
iconColor: '#DAB1DA',
|
|
||||||
title: 'PostgreSQL USER is cursed',
|
|
||||||
description:
|
|
||||||
'The USER keyword in PostgreSQL is cursed because you can select from it like a table, which leads to confusion if you have a table name user as well.',
|
|
||||||
link: {
|
|
||||||
url: 'https://github.com/immich-app/immich/pull/19891',
|
|
||||||
text: '#19891',
|
|
||||||
},
|
|
||||||
date: new Date(2025, 7, 4),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
icon: mdiRestart,
|
|
||||||
iconColor: '#8395e3',
|
|
||||||
title: 'PostgreSQL RESET is cursed',
|
|
||||||
description:
|
|
||||||
'PostgreSQL RESET is cursed because it is impossible to RESET a PostgreSQL extension parameter if the extension has been uninstalled.',
|
|
||||||
link: {
|
|
||||||
url: 'https://github.com/immich-app/immich/pull/19363',
|
|
||||||
text: '#19363',
|
|
||||||
},
|
|
||||||
date: new Date(2025, 5, 20),
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
icon: mdiRegex,
|
icon: mdiRegex,
|
||||||
iconColor: 'purple',
|
iconColor: 'purple',
|
||||||
|
|||||||
@@ -683,7 +683,7 @@ describe('/albums', () => {
|
|||||||
.set('Authorization', `Bearer ${user1.accessToken}`)
|
.set('Authorization', `Bearer ${user1.accessToken}`)
|
||||||
.send({ role: AlbumUserRole.Editor });
|
.send({ role: AlbumUserRole.Editor });
|
||||||
|
|
||||||
expect(status).toBe(204);
|
expect(status).toBe(200);
|
||||||
|
|
||||||
// Get album to verify the role change
|
// Get album to verify the role change
|
||||||
const { body } = await request(app)
|
const { body } = await request(app)
|
||||||
|
|||||||
@@ -555,7 +555,7 @@ describe('/asset', () => {
|
|||||||
expect(body).toMatchObject({ id: user1Assets[0].id, livePhotoVideoId: null });
|
expect(body).toMatchObject({ id: user1Assets[0].id, livePhotoVideoId: null });
|
||||||
});
|
});
|
||||||
|
|
||||||
it.skip('should update date time original when sidecar file contains DateTimeOriginal', async () => {
|
it('should update date time original when sidecar file contains DateTimeOriginal', async () => {
|
||||||
const sidecarData = `<?xpacket begin='?' id='W5M0MpCehiHzreSzNTczkc9d'?>
|
const sidecarData = `<?xpacket begin='?' id='W5M0MpCehiHzreSzNTczkc9d'?>
|
||||||
<x:xmpmeta xmlns:x='adobe:ns:meta/' x:xmptk='Image::ExifTool 12.40'>
|
<x:xmpmeta xmlns:x='adobe:ns:meta/' x:xmptk='Image::ExifTool 12.40'>
|
||||||
<rdf:RDF xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#'>
|
<rdf:RDF xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#'>
|
||||||
|
|||||||
@@ -116,7 +116,7 @@ describe('/partners', () => {
|
|||||||
.delete(`/partners/${user3.userId}`)
|
.delete(`/partners/${user3.userId}`)
|
||||||
.set('Authorization', `Bearer ${user1.accessToken}`);
|
.set('Authorization', `Bearer ${user1.accessToken}`);
|
||||||
|
|
||||||
expect(status).toBe(204);
|
expect(status).toBe(200);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should throw a bad request if partner not found', async () => {
|
it('should throw a bad request if partner not found', async () => {
|
||||||
|
|||||||
@@ -485,7 +485,7 @@ describe('/shared-links', () => {
|
|||||||
.delete(`/shared-links/${linkWithAlbum.id}`)
|
.delete(`/shared-links/${linkWithAlbum.id}`)
|
||||||
.set('Authorization', `Bearer ${user1.accessToken}`);
|
.set('Authorization', `Bearer ${user1.accessToken}`);
|
||||||
|
|
||||||
expect(status).toBe(204);
|
expect(status).toBe(200);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -304,7 +304,7 @@ describe('/users', () => {
|
|||||||
const { status } = await request(app)
|
const { status } = await request(app)
|
||||||
.delete(`/users/me/license`)
|
.delete(`/users/me/license`)
|
||||||
.set('Authorization', `Bearer ${nonAdmin.accessToken}`);
|
.set('Authorization', `Bearer ${nonAdmin.accessToken}`);
|
||||||
expect(status).toBe(204);
|
expect(status).toBe(200);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -355,9 +355,6 @@
|
|||||||
"trash_number_of_days_description": "Number of days to keep the assets in trash before permanently removing them",
|
"trash_number_of_days_description": "Number of days to keep the assets in trash before permanently removing them",
|
||||||
"trash_settings": "Trash Settings",
|
"trash_settings": "Trash Settings",
|
||||||
"trash_settings_description": "Manage trash settings",
|
"trash_settings_description": "Manage trash settings",
|
||||||
"unlink_all_oauth_accounts": "Unlink all OAuth accounts",
|
|
||||||
"unlink_all_oauth_accounts_description": "Remember to unlink all OAuth accounts before migrating to a new provider.",
|
|
||||||
"unlink_all_oauth_accounts_prompt": "Are you sure you want to unlink all OAuth accounts? This will reset the OAuth ID for each user and cannot be undone.",
|
|
||||||
"user_cleanup_job": "User cleanup",
|
"user_cleanup_job": "User cleanup",
|
||||||
"user_delete_delay": "<b>{user}</b>'s account and assets will be scheduled for permanent deletion in {delay, plural, one {# day} other {# days}}.",
|
"user_delete_delay": "<b>{user}</b>'s account and assets will be scheduled for permanent deletion in {delay, plural, one {# day} other {# days}}.",
|
||||||
"user_delete_delay_settings": "Delete delay",
|
"user_delete_delay_settings": "Delete delay",
|
||||||
@@ -915,7 +912,6 @@
|
|||||||
"failed_to_load_notifications": "Failed to load notifications",
|
"failed_to_load_notifications": "Failed to load notifications",
|
||||||
"failed_to_load_people": "Failed to load people",
|
"failed_to_load_people": "Failed to load people",
|
||||||
"failed_to_remove_product_key": "Failed to remove product key",
|
"failed_to_remove_product_key": "Failed to remove product key",
|
||||||
"failed_to_reset_pin_code": "Failed to reset PIN code",
|
|
||||||
"failed_to_stack_assets": "Failed to stack assets",
|
"failed_to_stack_assets": "Failed to stack assets",
|
||||||
"failed_to_unstack_assets": "Failed to un-stack assets",
|
"failed_to_unstack_assets": "Failed to un-stack assets",
|
||||||
"failed_to_update_notification_status": "Failed to update notification status",
|
"failed_to_update_notification_status": "Failed to update notification status",
|
||||||
@@ -924,7 +920,6 @@
|
|||||||
"paths_validation_failed": "{paths, plural, one {# path} other {# paths}} failed validation",
|
"paths_validation_failed": "{paths, plural, one {# path} other {# paths}} failed validation",
|
||||||
"profile_picture_transparent_pixels": "Profile pictures cannot have transparent pixels. Please zoom in and/or move the image.",
|
"profile_picture_transparent_pixels": "Profile pictures cannot have transparent pixels. Please zoom in and/or move the image.",
|
||||||
"quota_higher_than_disk_size": "You set a quota higher than the disk size",
|
"quota_higher_than_disk_size": "You set a quota higher than the disk size",
|
||||||
"something_went_wrong": "Something went wrong",
|
|
||||||
"unable_to_add_album_users": "Unable to add users to album",
|
"unable_to_add_album_users": "Unable to add users to album",
|
||||||
"unable_to_add_assets_to_shared_link": "Unable to add assets to shared link",
|
"unable_to_add_assets_to_shared_link": "Unable to add assets to shared link",
|
||||||
"unable_to_add_comment": "Unable to add comment",
|
"unable_to_add_comment": "Unable to add comment",
|
||||||
@@ -1061,7 +1056,6 @@
|
|||||||
"folder_not_found": "Folder not found",
|
"folder_not_found": "Folder not found",
|
||||||
"folders": "Folders",
|
"folders": "Folders",
|
||||||
"folders_feature_description": "Browsing the folder view for the photos and videos on the file system",
|
"folders_feature_description": "Browsing the folder view for the photos and videos on the file system",
|
||||||
"forgot_pin_code_question": "Forgot your PIN?",
|
|
||||||
"forward": "Forward",
|
"forward": "Forward",
|
||||||
"gcast_enabled": "Google Cast",
|
"gcast_enabled": "Google Cast",
|
||||||
"gcast_enabled_description": "This feature loads external resources from Google in order to work.",
|
"gcast_enabled_description": "This feature loads external resources from Google in order to work.",
|
||||||
@@ -1605,9 +1599,6 @@
|
|||||||
"reset_password": "Reset password",
|
"reset_password": "Reset password",
|
||||||
"reset_people_visibility": "Reset people visibility",
|
"reset_people_visibility": "Reset people visibility",
|
||||||
"reset_pin_code": "Reset PIN code",
|
"reset_pin_code": "Reset PIN code",
|
||||||
"reset_pin_code_description": "If you forgot your PIN code, you can contact the server administrator to reset it",
|
|
||||||
"reset_pin_code_success": "Successfully reset PIN code",
|
|
||||||
"reset_pin_code_with_password": "You can always reset your PIN code with your password",
|
|
||||||
"reset_sqlite": "Reset SQLite Database",
|
"reset_sqlite": "Reset SQLite Database",
|
||||||
"reset_sqlite_confirmation": "Are you sure you want to reset the SQLite database? You will need to log out and log in again to resync the data",
|
"reset_sqlite_confirmation": "Are you sure you want to reset the SQLite database? You will need to log out and log in again to resync the data",
|
||||||
"reset_sqlite_success": "Successfully reset the SQLite database",
|
"reset_sqlite_success": "Successfully reset the SQLite database",
|
||||||
|
|||||||
@@ -1,10 +0,0 @@
|
|||||||
|
|
||||||
cmake_minimum_required(VERSION 3.10.2)
|
|
||||||
project("native_buffer")
|
|
||||||
|
|
||||||
add_library(native_buffer SHARED
|
|
||||||
src/main/cpp/native_buffer.c)
|
|
||||||
|
|
||||||
find_library(log-lib log)
|
|
||||||
|
|
||||||
target_link_libraries(native_buffer ${log-lib})
|
|
||||||
@@ -83,12 +83,6 @@ android {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
namespace 'app.alextran.immich'
|
namespace 'app.alextran.immich'
|
||||||
|
|
||||||
externalNativeBuild {
|
|
||||||
cmake {
|
|
||||||
path "CMakeLists.txt"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
flutter {
|
flutter {
|
||||||
|
|||||||
@@ -1,52 +0,0 @@
|
|||||||
#include <jni.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
|
|
||||||
JNIEXPORT jlong JNICALL
|
|
||||||
Java_app_alextran_immich_images_ThumbnailsImpl_00024Companion_allocateNative(
|
|
||||||
JNIEnv *env, jclass clazz, jint size)
|
|
||||||
{
|
|
||||||
void *ptr = malloc(size);
|
|
||||||
return (jlong)ptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
JNIEXPORT jlong JNICALL
|
|
||||||
Java_app_alextran_immich_images_ThumbnailsImpl_allocateNative(
|
|
||||||
JNIEnv *env, jclass clazz, jint size)
|
|
||||||
{
|
|
||||||
void *ptr = malloc(size);
|
|
||||||
return (jlong)ptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
JNIEXPORT void JNICALL
|
|
||||||
Java_app_alextran_immich_images_ThumbnailsImpl_00024Companion_freeNative(
|
|
||||||
JNIEnv *env, jclass clazz, jlong address)
|
|
||||||
{
|
|
||||||
if (address != 0)
|
|
||||||
{
|
|
||||||
free((void *)address);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
JNIEXPORT void JNICALL
|
|
||||||
Java_app_alextran_immich_images_ThumbnailsImpl_freeNative(
|
|
||||||
JNIEnv *env, jclass clazz, jlong address)
|
|
||||||
{
|
|
||||||
if (address != 0)
|
|
||||||
{
|
|
||||||
free((void *)address);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
JNIEXPORT jobject JNICALL
|
|
||||||
Java_app_alextran_immich_images_ThumbnailsImpl_00024Companion_wrapAsBuffer(
|
|
||||||
JNIEnv *env, jclass clazz, jlong address, jint capacity)
|
|
||||||
{
|
|
||||||
return (*env)->NewDirectByteBuffer(env, (void*)address, capacity);
|
|
||||||
}
|
|
||||||
|
|
||||||
JNIEXPORT jobject JNICALL
|
|
||||||
Java_app_alextran_immich_images_ThumbnailsImpl_wrapAsBuffer(
|
|
||||||
JNIEnv *env, jclass clazz, jlong address, jint capacity)
|
|
||||||
{
|
|
||||||
return (*env)->NewDirectByteBuffer(env, (void*)address, capacity);
|
|
||||||
}
|
|
||||||
@@ -1,20 +1,7 @@
|
|||||||
package app.alextran.immich
|
package app.alextran.immich
|
||||||
|
|
||||||
import android.content.Context
|
|
||||||
import com.bumptech.glide.GlideBuilder
|
|
||||||
import com.bumptech.glide.annotation.GlideModule
|
import com.bumptech.glide.annotation.GlideModule
|
||||||
import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPoolAdapter
|
|
||||||
import com.bumptech.glide.load.engine.cache.DiskCacheAdapter
|
|
||||||
import com.bumptech.glide.load.engine.cache.MemoryCacheAdapter
|
|
||||||
import com.bumptech.glide.module.AppGlideModule
|
import com.bumptech.glide.module.AppGlideModule
|
||||||
|
|
||||||
@GlideModule
|
@GlideModule
|
||||||
class AppGlideModule : AppGlideModule() {
|
class AppGlideModule : AppGlideModule()
|
||||||
override fun applyOptions(context: Context, builder: GlideBuilder) {
|
|
||||||
super.applyOptions(context, builder)
|
|
||||||
// disable caching as this is already done on the Flutter side
|
|
||||||
builder.setMemoryCache(MemoryCacheAdapter())
|
|
||||||
builder.setDiskCache(DiskCacheAdapter.Factory())
|
|
||||||
builder.setBitmapPool(BitmapPoolAdapter())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -2,8 +2,7 @@ package app.alextran.immich
|
|||||||
|
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
import android.os.ext.SdkExtensions
|
import android.os.ext.SdkExtensions
|
||||||
import app.alextran.immich.images.ThumbnailApi
|
import androidx.annotation.NonNull
|
||||||
import app.alextran.immich.images.ThumbnailsImpl
|
|
||||||
import app.alextran.immich.sync.NativeSyncApi
|
import app.alextran.immich.sync.NativeSyncApi
|
||||||
import app.alextran.immich.sync.NativeSyncApiImpl26
|
import app.alextran.immich.sync.NativeSyncApiImpl26
|
||||||
import app.alextran.immich.sync.NativeSyncApiImpl30
|
import app.alextran.immich.sync.NativeSyncApiImpl30
|
||||||
@@ -11,7 +10,7 @@ import io.flutter.embedding.android.FlutterFragmentActivity
|
|||||||
import io.flutter.embedding.engine.FlutterEngine
|
import io.flutter.embedding.engine.FlutterEngine
|
||||||
|
|
||||||
class MainActivity : FlutterFragmentActivity() {
|
class MainActivity : FlutterFragmentActivity() {
|
||||||
override fun configureFlutterEngine(flutterEngine: FlutterEngine) {
|
override fun configureFlutterEngine(@NonNull flutterEngine: FlutterEngine) {
|
||||||
super.configureFlutterEngine(flutterEngine)
|
super.configureFlutterEngine(flutterEngine)
|
||||||
flutterEngine.plugins.add(BackgroundServicePlugin())
|
flutterEngine.plugins.add(BackgroundServicePlugin())
|
||||||
flutterEngine.plugins.add(HttpSSLOptionsPlugin())
|
flutterEngine.plugins.add(HttpSSLOptionsPlugin())
|
||||||
@@ -24,6 +23,5 @@ class MainActivity : FlutterFragmentActivity() {
|
|||||||
NativeSyncApiImpl30(this)
|
NativeSyncApiImpl30(this)
|
||||||
}
|
}
|
||||||
NativeSyncApi.setUp(flutterEngine.dartExecutor.binaryMessenger, nativeSyncApiImpl)
|
NativeSyncApi.setUp(flutterEngine.dartExecutor.binaryMessenger, nativeSyncApiImpl)
|
||||||
ThumbnailApi.setUp(flutterEngine.dartExecutor.binaryMessenger, ThumbnailsImpl(this))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,117 +0,0 @@
|
|||||||
// Autogenerated from Pigeon (v26.0.0), do not edit directly.
|
|
||||||
// See also: https://pub.dev/packages/pigeon
|
|
||||||
@file:Suppress("UNCHECKED_CAST", "ArrayInDataClass")
|
|
||||||
|
|
||||||
package app.alextran.immich.images
|
|
||||||
|
|
||||||
import android.util.Log
|
|
||||||
import io.flutter.plugin.common.BasicMessageChannel
|
|
||||||
import io.flutter.plugin.common.BinaryMessenger
|
|
||||||
import io.flutter.plugin.common.EventChannel
|
|
||||||
import io.flutter.plugin.common.MessageCodec
|
|
||||||
import io.flutter.plugin.common.StandardMethodCodec
|
|
||||||
import io.flutter.plugin.common.StandardMessageCodec
|
|
||||||
import java.io.ByteArrayOutputStream
|
|
||||||
import java.nio.ByteBuffer
|
|
||||||
private object ThumbnailsPigeonUtils {
|
|
||||||
|
|
||||||
fun wrapResult(result: Any?): List<Any?> {
|
|
||||||
return listOf(result)
|
|
||||||
}
|
|
||||||
|
|
||||||
fun wrapError(exception: Throwable): List<Any?> {
|
|
||||||
return if (exception is FlutterError) {
|
|
||||||
listOf(
|
|
||||||
exception.code,
|
|
||||||
exception.message,
|
|
||||||
exception.details
|
|
||||||
)
|
|
||||||
} else {
|
|
||||||
listOf(
|
|
||||||
exception.javaClass.simpleName,
|
|
||||||
exception.toString(),
|
|
||||||
"Cause: " + exception.cause + ", Stacktrace: " + Log.getStackTraceString(exception)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Error class for passing custom error details to Flutter via a thrown PlatformException.
|
|
||||||
* @property code The error code.
|
|
||||||
* @property message The error message.
|
|
||||||
* @property details The error details. Must be a datatype supported by the api codec.
|
|
||||||
*/
|
|
||||||
class FlutterError (
|
|
||||||
val code: String,
|
|
||||||
override val message: String? = null,
|
|
||||||
val details: Any? = null
|
|
||||||
) : Throwable()
|
|
||||||
private open class ThumbnailsPigeonCodec : StandardMessageCodec() {
|
|
||||||
override fun readValueOfType(type: Byte, buffer: ByteBuffer): Any? {
|
|
||||||
return super.readValueOfType(type, buffer)
|
|
||||||
}
|
|
||||||
override fun writeValue(stream: ByteArrayOutputStream, value: Any?) {
|
|
||||||
super.writeValue(stream, value)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/** Generated interface from Pigeon that represents a handler of messages from Flutter. */
|
|
||||||
interface ThumbnailApi {
|
|
||||||
fun requestImage(assetId: String, requestId: Long, width: Long, height: Long, callback: (Result<Map<String, Long>>) -> Unit)
|
|
||||||
fun cancelImageRequest(requestId: Long)
|
|
||||||
|
|
||||||
companion object {
|
|
||||||
/** The codec used by ThumbnailApi. */
|
|
||||||
val codec: MessageCodec<Any?> by lazy {
|
|
||||||
ThumbnailsPigeonCodec()
|
|
||||||
}
|
|
||||||
/** Sets up an instance of `ThumbnailApi` to handle messages through the `binaryMessenger`. */
|
|
||||||
@JvmOverloads
|
|
||||||
fun setUp(binaryMessenger: BinaryMessenger, api: ThumbnailApi?, messageChannelSuffix: String = "") {
|
|
||||||
val separatedMessageChannelSuffix = if (messageChannelSuffix.isNotEmpty()) ".$messageChannelSuffix" else ""
|
|
||||||
run {
|
|
||||||
val channel = BasicMessageChannel<Any?>(binaryMessenger, "dev.flutter.pigeon.immich_mobile.ThumbnailApi.requestImage$separatedMessageChannelSuffix", codec)
|
|
||||||
if (api != null) {
|
|
||||||
channel.setMessageHandler { message, reply ->
|
|
||||||
val args = message as List<Any?>
|
|
||||||
val assetIdArg = args[0] as String
|
|
||||||
val requestIdArg = args[1] as Long
|
|
||||||
val widthArg = args[2] as Long
|
|
||||||
val heightArg = args[3] as Long
|
|
||||||
api.requestImage(assetIdArg, requestIdArg, widthArg, heightArg) { result: Result<Map<String, Long>> ->
|
|
||||||
val error = result.exceptionOrNull()
|
|
||||||
if (error != null) {
|
|
||||||
reply.reply(ThumbnailsPigeonUtils.wrapError(error))
|
|
||||||
} else {
|
|
||||||
val data = result.getOrNull()
|
|
||||||
reply.reply(ThumbnailsPigeonUtils.wrapResult(data))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
channel.setMessageHandler(null)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
run {
|
|
||||||
val channel = BasicMessageChannel<Any?>(binaryMessenger, "dev.flutter.pigeon.immich_mobile.ThumbnailApi.cancelImageRequest$separatedMessageChannelSuffix", codec)
|
|
||||||
if (api != null) {
|
|
||||||
channel.setMessageHandler { message, reply ->
|
|
||||||
val args = message as List<Any?>
|
|
||||||
val requestIdArg = args[0] as Long
|
|
||||||
val wrapped: List<Any?> = try {
|
|
||||||
api.cancelImageRequest(requestIdArg)
|
|
||||||
listOf(null)
|
|
||||||
} catch (exception: Throwable) {
|
|
||||||
ThumbnailsPigeonUtils.wrapError(exception)
|
|
||||||
}
|
|
||||||
reply.reply(wrapped)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
channel.setMessageHandler(null)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,236 +0,0 @@
|
|||||||
package app.alextran.immich.images
|
|
||||||
|
|
||||||
import android.content.ContentResolver
|
|
||||||
import android.content.ContentUris
|
|
||||||
import android.content.Context
|
|
||||||
import android.graphics.*
|
|
||||||
import android.net.Uri
|
|
||||||
import android.os.Build
|
|
||||||
import android.os.CancellationSignal
|
|
||||||
import android.os.OperationCanceledException
|
|
||||||
import android.provider.MediaStore
|
|
||||||
import android.provider.MediaStore.Images
|
|
||||||
import android.provider.MediaStore.Video
|
|
||||||
import android.util.Size
|
|
||||||
import java.nio.ByteBuffer
|
|
||||||
import kotlin.math.*
|
|
||||||
import java.util.concurrent.Executors
|
|
||||||
import com.bumptech.glide.Glide
|
|
||||||
import com.bumptech.glide.Priority
|
|
||||||
import com.bumptech.glide.load.DecodeFormat
|
|
||||||
import java.util.HashMap
|
|
||||||
import java.util.concurrent.CancellationException
|
|
||||||
import java.util.concurrent.Future
|
|
||||||
|
|
||||||
data class Request(
|
|
||||||
val requestId: Long,
|
|
||||||
val taskFuture: Future<*>,
|
|
||||||
val cancellationSignal: CancellationSignal,
|
|
||||||
val callback: (Result<Map<String, Long>>) -> Unit
|
|
||||||
)
|
|
||||||
|
|
||||||
class ThumbnailsImpl(context: Context) : ThumbnailApi {
|
|
||||||
private val ctx: Context = context.applicationContext
|
|
||||||
private val resolver: ContentResolver = ctx.contentResolver
|
|
||||||
private val threadPool =
|
|
||||||
Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors() / 2 + 1)
|
|
||||||
private val requestMap = HashMap<Long, Request>()
|
|
||||||
|
|
||||||
companion object {
|
|
||||||
val PROJECTION = arrayOf(
|
|
||||||
MediaStore.MediaColumns.DATE_MODIFIED,
|
|
||||||
MediaStore.Files.FileColumns.MEDIA_TYPE,
|
|
||||||
)
|
|
||||||
const val SELECTION = "${MediaStore.MediaColumns._ID} = ?"
|
|
||||||
val URI: Uri = MediaStore.Files.getContentUri("external")
|
|
||||||
|
|
||||||
const val MEDIA_TYPE_IMAGE = MediaStore.Files.FileColumns.MEDIA_TYPE_IMAGE
|
|
||||||
const val MEDIA_TYPE_VIDEO = MediaStore.Files.FileColumns.MEDIA_TYPE_VIDEO
|
|
||||||
val CANCELLED = Result.success<Map<String, Long>>(mapOf())
|
|
||||||
val OPTIONS = BitmapFactory.Options().apply { inPreferredConfig = Bitmap.Config.ARGB_8888 }
|
|
||||||
|
|
||||||
init {
|
|
||||||
System.loadLibrary("native_buffer")
|
|
||||||
}
|
|
||||||
|
|
||||||
@JvmStatic
|
|
||||||
external fun allocateNative(size: Int): Long
|
|
||||||
|
|
||||||
@JvmStatic
|
|
||||||
external fun freeNative(pointer: Long)
|
|
||||||
|
|
||||||
@JvmStatic
|
|
||||||
external fun wrapAsBuffer(address: Long, capacity: Int): ByteBuffer
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun requestImage(
|
|
||||||
assetId: String,
|
|
||||||
requestId: Long,
|
|
||||||
width: Long,
|
|
||||||
height: Long,
|
|
||||||
callback: (Result<Map<String, Long>>) -> Unit
|
|
||||||
) {
|
|
||||||
val signal = CancellationSignal()
|
|
||||||
val task = threadPool.submit {
|
|
||||||
try {
|
|
||||||
getThumbnailBufferInternal(assetId, width, height, callback, signal)
|
|
||||||
} catch (e: Exception) {
|
|
||||||
when (e) {
|
|
||||||
is OperationCanceledException -> callback(CANCELLED)
|
|
||||||
is CancellationException -> callback(CANCELLED)
|
|
||||||
else -> callback(Result.failure(e))
|
|
||||||
}
|
|
||||||
} finally {
|
|
||||||
requestMap.remove(requestId)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
requestMap[requestId] = Request(requestId, task, signal, callback)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun cancelImageRequest(requestId: Long) {
|
|
||||||
val request = requestMap.remove(requestId) ?: return
|
|
||||||
request.taskFuture.cancel(false)
|
|
||||||
request.cancellationSignal.cancel()
|
|
||||||
if (request.taskFuture.isCancelled) {
|
|
||||||
request.callback(CANCELLED)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun getThumbnailBufferInternal(
|
|
||||||
assetId: String,
|
|
||||||
width: Long,
|
|
||||||
height: Long,
|
|
||||||
callback: (Result<Map<String, Long>>) -> Unit,
|
|
||||||
signal: CancellationSignal
|
|
||||||
) {
|
|
||||||
signal.throwIfCanceled()
|
|
||||||
val targetWidth = width.toInt()
|
|
||||||
val targetHeight = height.toInt()
|
|
||||||
val id = assetId.toLong()
|
|
||||||
|
|
||||||
val cursor = resolver.query(URI, PROJECTION, SELECTION, arrayOf(assetId), null)
|
|
||||||
?: return callback(Result.failure(RuntimeException("Asset not found")))
|
|
||||||
|
|
||||||
signal.throwIfCanceled()
|
|
||||||
cursor.use { c ->
|
|
||||||
if (!c.moveToNext()) {
|
|
||||||
return callback(Result.failure(RuntimeException("Asset not found")))
|
|
||||||
}
|
|
||||||
|
|
||||||
val mediaType = c.getInt(1)
|
|
||||||
val bitmap = when (mediaType) {
|
|
||||||
MEDIA_TYPE_IMAGE -> decodeImage(id, targetWidth, targetHeight, signal)
|
|
||||||
MEDIA_TYPE_VIDEO -> decodeVideoThumbnail(id, targetWidth, targetHeight, signal)
|
|
||||||
else -> return callback(Result.failure(RuntimeException("Unsupported media type")))
|
|
||||||
}
|
|
||||||
|
|
||||||
processBitmap(bitmap, callback, signal)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun processBitmap(
|
|
||||||
bitmap: Bitmap,
|
|
||||||
callback: (Result<Map<String, Long>>) -> Unit,
|
|
||||||
signal: CancellationSignal
|
|
||||||
) {
|
|
||||||
signal.throwIfCanceled()
|
|
||||||
val actualWidth = bitmap.width
|
|
||||||
val actualHeight = bitmap.height
|
|
||||||
|
|
||||||
val size = actualWidth * actualHeight * 4
|
|
||||||
val pointer = allocateNative(size)
|
|
||||||
|
|
||||||
try {
|
|
||||||
signal.throwIfCanceled()
|
|
||||||
val buffer = wrapAsBuffer(pointer, size)
|
|
||||||
bitmap.copyPixelsToBuffer(buffer)
|
|
||||||
signal.throwIfCanceled()
|
|
||||||
val res = mapOf(
|
|
||||||
"pointer" to pointer,
|
|
||||||
"width" to actualWidth.toLong(),
|
|
||||||
"height" to actualHeight.toLong()
|
|
||||||
)
|
|
||||||
callback(Result.success(res))
|
|
||||||
} catch (e: Exception) {
|
|
||||||
freeNative(pointer)
|
|
||||||
callback(if (e is OperationCanceledException) CANCELLED else Result.failure(e))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun decodeImage(
|
|
||||||
id: Long,
|
|
||||||
targetWidth: Int,
|
|
||||||
targetHeight: Int,
|
|
||||||
signal: CancellationSignal
|
|
||||||
): Bitmap {
|
|
||||||
signal.throwIfCanceled()
|
|
||||||
val uri = ContentUris.withAppendedId(Images.Media.EXTERNAL_CONTENT_URI, id)
|
|
||||||
if (targetHeight > 768 || targetWidth > 768) {
|
|
||||||
return decodeSource(uri, targetWidth, targetHeight, signal)
|
|
||||||
}
|
|
||||||
|
|
||||||
return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
|
||||||
resolver.loadThumbnail(uri, Size(targetWidth, targetHeight), signal)
|
|
||||||
} else {
|
|
||||||
signal.setOnCancelListener { Images.Thumbnails.cancelThumbnailRequest(resolver, id) }
|
|
||||||
Images.Thumbnails.getThumbnail(resolver, id, Images.Thumbnails.MINI_KIND, OPTIONS)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun decodeVideoThumbnail(
|
|
||||||
id: Long,
|
|
||||||
targetWidth: Int,
|
|
||||||
targetHeight: Int,
|
|
||||||
signal: CancellationSignal
|
|
||||||
): Bitmap {
|
|
||||||
signal.throwIfCanceled()
|
|
||||||
return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
|
||||||
val uri = ContentUris.withAppendedId(Video.Media.EXTERNAL_CONTENT_URI, id)
|
|
||||||
resolver.loadThumbnail(uri, Size(targetWidth, targetHeight), signal)
|
|
||||||
} else {
|
|
||||||
signal.setOnCancelListener { Video.Thumbnails.cancelThumbnailRequest(resolver, id) }
|
|
||||||
Video.Thumbnails.getThumbnail(resolver, id, Video.Thumbnails.MINI_KIND, OPTIONS)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun decodeSource(
|
|
||||||
uri: Uri,
|
|
||||||
targetWidth: Int,
|
|
||||||
targetHeight: Int,
|
|
||||||
signal: CancellationSignal
|
|
||||||
): Bitmap {
|
|
||||||
signal.throwIfCanceled()
|
|
||||||
return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
|
||||||
val source = ImageDecoder.createSource(resolver, uri)
|
|
||||||
signal.throwIfCanceled()
|
|
||||||
ImageDecoder.decodeBitmap(source) { decoder, info, _ ->
|
|
||||||
val sampleSize =
|
|
||||||
getSampleSize(info.size.width, info.size.height, targetWidth, targetHeight)
|
|
||||||
decoder.setTargetSampleSize(sampleSize)
|
|
||||||
decoder.allocator = ImageDecoder.ALLOCATOR_SOFTWARE
|
|
||||||
decoder.setTargetColorSpace(ColorSpace.get(ColorSpace.Named.SRGB))
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
val ref = Glide.with(ctx)
|
|
||||||
.asBitmap()
|
|
||||||
.priority(Priority.IMMEDIATE)
|
|
||||||
.load(uri)
|
|
||||||
.disallowHardwareConfig()
|
|
||||||
.format(DecodeFormat.PREFER_ARGB_8888)
|
|
||||||
.submit(targetWidth, targetHeight)
|
|
||||||
signal.setOnCancelListener { Glide.with(ctx).clear(ref) }
|
|
||||||
ref.get()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun getSampleSize(fullWidth: Int, fullHeight: Int, reqWidth: Int, reqHeight: Int): Int {
|
|
||||||
return 1 shl max(
|
|
||||||
0, floor(
|
|
||||||
min(
|
|
||||||
log2(fullWidth / (2.0 * reqWidth)),
|
|
||||||
log2(fullHeight / (2.0 * reqHeight)),
|
|
||||||
)
|
|
||||||
).toInt()
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -24,8 +24,6 @@
|
|||||||
FAC6F89B2D287C890078CB2F /* ShareExtension.appex in Embed Foundation Extensions */ = {isa = PBXBuildFile; fileRef = FAC6F8902D287C890078CB2F /* ShareExtension.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
|
FAC6F89B2D287C890078CB2F /* ShareExtension.appex in Embed Foundation Extensions */ = {isa = PBXBuildFile; fileRef = FAC6F8902D287C890078CB2F /* ShareExtension.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
|
||||||
FAC6F8B72D287F120078CB2F /* ShareViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = FAC6F8B52D287F120078CB2F /* ShareViewController.swift */; };
|
FAC6F8B72D287F120078CB2F /* ShareViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = FAC6F8B52D287F120078CB2F /* ShareViewController.swift */; };
|
||||||
FAC6F8B92D287F120078CB2F /* MainInterface.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = FAC6F8B32D287F120078CB2F /* MainInterface.storyboard */; };
|
FAC6F8B92D287F120078CB2F /* MainInterface.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = FAC6F8B32D287F120078CB2F /* MainInterface.storyboard */; };
|
||||||
FED3B1962E253E9B0030FD97 /* ThumbnailsImpl.swift in Sources */ = {isa = PBXBuildFile; fileRef = FED3B1942E253E9B0030FD97 /* ThumbnailsImpl.swift */; };
|
|
||||||
FED3B1972E253E9B0030FD97 /* Thumbnails.g.swift in Sources */ = {isa = PBXBuildFile; fileRef = FED3B1932E253E9B0030FD97 /* Thumbnails.g.swift */; };
|
|
||||||
/* End PBXBuildFile section */
|
/* End PBXBuildFile section */
|
||||||
|
|
||||||
/* Begin PBXContainerItemProxy section */
|
/* Begin PBXContainerItemProxy section */
|
||||||
@@ -104,8 +102,6 @@
|
|||||||
FAC6F8B42D287F120078CB2F /* ShareExtension.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = ShareExtension.entitlements; sourceTree = "<group>"; };
|
FAC6F8B42D287F120078CB2F /* ShareExtension.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = ShareExtension.entitlements; sourceTree = "<group>"; };
|
||||||
FAC6F8B52D287F120078CB2F /* ShareViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShareViewController.swift; sourceTree = "<group>"; };
|
FAC6F8B52D287F120078CB2F /* ShareViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShareViewController.swift; sourceTree = "<group>"; };
|
||||||
FAC7416727DB9F5500C668D8 /* RunnerProfile.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = RunnerProfile.entitlements; sourceTree = "<group>"; };
|
FAC7416727DB9F5500C668D8 /* RunnerProfile.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = RunnerProfile.entitlements; sourceTree = "<group>"; };
|
||||||
FED3B1932E253E9B0030FD97 /* Thumbnails.g.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Thumbnails.g.swift; sourceTree = "<group>"; };
|
|
||||||
FED3B1942E253E9B0030FD97 /* ThumbnailsImpl.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ThumbnailsImpl.swift; sourceTree = "<group>"; };
|
|
||||||
/* End PBXFileReference section */
|
/* End PBXFileReference section */
|
||||||
|
|
||||||
/* Begin PBXFileSystemSynchronizedBuildFileExceptionSet section */
|
/* Begin PBXFileSystemSynchronizedBuildFileExceptionSet section */
|
||||||
@@ -247,7 +243,6 @@
|
|||||||
1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */,
|
1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */,
|
||||||
74858FAE1ED2DC5600515810 /* AppDelegate.swift */,
|
74858FAE1ED2DC5600515810 /* AppDelegate.swift */,
|
||||||
74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */,
|
74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */,
|
||||||
FED3B1952E253E9B0030FD97 /* Images */,
|
|
||||||
);
|
);
|
||||||
path = Runner;
|
path = Runner;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
@@ -263,15 +258,6 @@
|
|||||||
path = ShareExtension;
|
path = ShareExtension;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
};
|
};
|
||||||
FED3B1952E253E9B0030FD97 /* Images */ = {
|
|
||||||
isa = PBXGroup;
|
|
||||||
children = (
|
|
||||||
FED3B1932E253E9B0030FD97 /* Thumbnails.g.swift */,
|
|
||||||
FED3B1942E253E9B0030FD97 /* ThumbnailsImpl.swift */,
|
|
||||||
);
|
|
||||||
path = Images;
|
|
||||||
sourceTree = "<group>";
|
|
||||||
};
|
|
||||||
/* End PBXGroup section */
|
/* End PBXGroup section */
|
||||||
|
|
||||||
/* Begin PBXNativeTarget section */
|
/* Begin PBXNativeTarget section */
|
||||||
@@ -537,8 +523,6 @@
|
|||||||
files = (
|
files = (
|
||||||
65F32F31299BD2F800CE9261 /* BackgroundServicePlugin.swift in Sources */,
|
65F32F31299BD2F800CE9261 /* BackgroundServicePlugin.swift in Sources */,
|
||||||
74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */,
|
74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */,
|
||||||
FED3B1962E253E9B0030FD97 /* ThumbnailsImpl.swift in Sources */,
|
|
||||||
FED3B1972E253E9B0030FD97 /* Thumbnails.g.swift in Sources */,
|
|
||||||
1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */,
|
1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */,
|
||||||
65F32F33299D349D00CE9261 /* BackgroundSyncWorker.swift in Sources */,
|
65F32F33299D349D00CE9261 /* BackgroundSyncWorker.swift in Sources */,
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -25,7 +25,6 @@ import UIKit
|
|||||||
|
|
||||||
let controller: FlutterViewController = window?.rootViewController as! FlutterViewController
|
let controller: FlutterViewController = window?.rootViewController as! FlutterViewController
|
||||||
NativeSyncApiSetup.setUp(binaryMessenger: controller.binaryMessenger, api: NativeSyncApiImpl())
|
NativeSyncApiSetup.setUp(binaryMessenger: controller.binaryMessenger, api: NativeSyncApiImpl())
|
||||||
ThumbnailApiSetup.setUp(binaryMessenger: controller.binaryMessenger, api: ThumbnailApiImpl())
|
|
||||||
|
|
||||||
BackgroundServicePlugin.setPluginRegistrantCallback { registry in
|
BackgroundServicePlugin.setPluginRegistrantCallback { registry in
|
||||||
if !registry.hasPlugin("org.cocoapods.path-provider-foundation") {
|
if !registry.hasPlugin("org.cocoapods.path-provider-foundation") {
|
||||||
|
|||||||
@@ -1,119 +0,0 @@
|
|||||||
// Autogenerated from Pigeon (v26.0.0), do not edit directly.
|
|
||||||
// See also: https://pub.dev/packages/pigeon
|
|
||||||
|
|
||||||
import Foundation
|
|
||||||
|
|
||||||
#if os(iOS)
|
|
||||||
import Flutter
|
|
||||||
#elseif os(macOS)
|
|
||||||
import FlutterMacOS
|
|
||||||
#else
|
|
||||||
#error("Unsupported platform.")
|
|
||||||
#endif
|
|
||||||
|
|
||||||
private func wrapResult(_ result: Any?) -> [Any?] {
|
|
||||||
return [result]
|
|
||||||
}
|
|
||||||
|
|
||||||
private func wrapError(_ error: Any) -> [Any?] {
|
|
||||||
if let pigeonError = error as? PigeonError {
|
|
||||||
return [
|
|
||||||
pigeonError.code,
|
|
||||||
pigeonError.message,
|
|
||||||
pigeonError.details,
|
|
||||||
]
|
|
||||||
}
|
|
||||||
if let flutterError = error as? FlutterError {
|
|
||||||
return [
|
|
||||||
flutterError.code,
|
|
||||||
flutterError.message,
|
|
||||||
flutterError.details,
|
|
||||||
]
|
|
||||||
}
|
|
||||||
return [
|
|
||||||
"\(error)",
|
|
||||||
"\(type(of: error))",
|
|
||||||
"Stacktrace: \(Thread.callStackSymbols)",
|
|
||||||
]
|
|
||||||
}
|
|
||||||
|
|
||||||
private func isNullish(_ value: Any?) -> Bool {
|
|
||||||
return value is NSNull || value == nil
|
|
||||||
}
|
|
||||||
|
|
||||||
private func nilOrValue<T>(_ value: Any?) -> T? {
|
|
||||||
if value is NSNull { return nil }
|
|
||||||
return value as! T?
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private class ThumbnailsPigeonCodecReader: FlutterStandardReader {
|
|
||||||
}
|
|
||||||
|
|
||||||
private class ThumbnailsPigeonCodecWriter: FlutterStandardWriter {
|
|
||||||
}
|
|
||||||
|
|
||||||
private class ThumbnailsPigeonCodecReaderWriter: FlutterStandardReaderWriter {
|
|
||||||
override func reader(with data: Data) -> FlutterStandardReader {
|
|
||||||
return ThumbnailsPigeonCodecReader(data: data)
|
|
||||||
}
|
|
||||||
|
|
||||||
override func writer(with data: NSMutableData) -> FlutterStandardWriter {
|
|
||||||
return ThumbnailsPigeonCodecWriter(data: data)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class ThumbnailsPigeonCodec: FlutterStandardMessageCodec, @unchecked Sendable {
|
|
||||||
static let shared = ThumbnailsPigeonCodec(readerWriter: ThumbnailsPigeonCodecReaderWriter())
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/// Generated protocol from Pigeon that represents a handler of messages from Flutter.
|
|
||||||
protocol ThumbnailApi {
|
|
||||||
func requestImage(assetId: String, requestId: Int64, width: Int64, height: Int64, completion: @escaping (Result<[String: Int64], Error>) -> Void)
|
|
||||||
func cancelImageRequest(requestId: Int64) throws
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Generated setup class from Pigeon to handle messages through the `binaryMessenger`.
|
|
||||||
class ThumbnailApiSetup {
|
|
||||||
static var codec: FlutterStandardMessageCodec { ThumbnailsPigeonCodec.shared }
|
|
||||||
/// Sets up an instance of `ThumbnailApi` to handle messages through the `binaryMessenger`.
|
|
||||||
static func setUp(binaryMessenger: FlutterBinaryMessenger, api: ThumbnailApi?, messageChannelSuffix: String = "") {
|
|
||||||
let channelSuffix = messageChannelSuffix.count > 0 ? ".\(messageChannelSuffix)" : ""
|
|
||||||
let requestImageChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.immich_mobile.ThumbnailApi.requestImage\(channelSuffix)", binaryMessenger: binaryMessenger, codec: codec)
|
|
||||||
if let api = api {
|
|
||||||
requestImageChannel.setMessageHandler { message, reply in
|
|
||||||
let args = message as! [Any?]
|
|
||||||
let assetIdArg = args[0] as! String
|
|
||||||
let requestIdArg = args[1] as! Int64
|
|
||||||
let widthArg = args[2] as! Int64
|
|
||||||
let heightArg = args[3] as! Int64
|
|
||||||
api.requestImage(assetId: assetIdArg, requestId: requestIdArg, width: widthArg, height: heightArg) { result in
|
|
||||||
switch result {
|
|
||||||
case .success(let res):
|
|
||||||
reply(wrapResult(res))
|
|
||||||
case .failure(let error):
|
|
||||||
reply(wrapError(error))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
requestImageChannel.setMessageHandler(nil)
|
|
||||||
}
|
|
||||||
let cancelImageRequestChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.immich_mobile.ThumbnailApi.cancelImageRequest\(channelSuffix)", binaryMessenger: binaryMessenger, codec: codec)
|
|
||||||
if let api = api {
|
|
||||||
cancelImageRequestChannel.setMessageHandler { message, reply in
|
|
||||||
let args = message as! [Any?]
|
|
||||||
let requestIdArg = args[0] as! Int64
|
|
||||||
do {
|
|
||||||
try api.cancelImageRequest(requestId: requestIdArg)
|
|
||||||
reply(wrapResult(nil))
|
|
||||||
} catch {
|
|
||||||
reply(wrapError(error))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
cancelImageRequestChannel.setMessageHandler(nil)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,177 +0,0 @@
|
|||||||
import CryptoKit
|
|
||||||
import Flutter
|
|
||||||
import MobileCoreServices
|
|
||||||
import Photos
|
|
||||||
|
|
||||||
class Request {
|
|
||||||
weak var workItem: DispatchWorkItem?
|
|
||||||
var isCancelled = false
|
|
||||||
let callback: (Result<[String: Int64], any Error>) -> Void
|
|
||||||
|
|
||||||
init(callback: @escaping (Result<[String: Int64], any Error>) -> Void) {
|
|
||||||
self.callback = callback
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class ThumbnailApiImpl: ThumbnailApi {
|
|
||||||
private static let imageManager = PHImageManager.default()
|
|
||||||
private static let fetchOptions = {
|
|
||||||
let fetchOptions = PHFetchOptions()
|
|
||||||
fetchOptions.fetchLimit = 1
|
|
||||||
fetchOptions.wantsIncrementalChangeDetails = false
|
|
||||||
return fetchOptions
|
|
||||||
}()
|
|
||||||
private static let requestOptions = {
|
|
||||||
let requestOptions = PHImageRequestOptions()
|
|
||||||
requestOptions.isNetworkAccessAllowed = true
|
|
||||||
requestOptions.deliveryMode = .highQualityFormat
|
|
||||||
requestOptions.resizeMode = .fast
|
|
||||||
requestOptions.isSynchronous = true
|
|
||||||
requestOptions.version = .current
|
|
||||||
return requestOptions
|
|
||||||
}()
|
|
||||||
|
|
||||||
private static let assetQueue = DispatchQueue(label: "thumbnail.assets", qos: .userInitiated)
|
|
||||||
private static let requestQueue = DispatchQueue(label: "thumbnail.requests", qos: .userInitiated)
|
|
||||||
private static let cancelQueue = DispatchQueue(label: "thumbnail.cancellation", qos: .default)
|
|
||||||
private static let processingQueue = DispatchQueue(label: "thumbnail.processing", qos: .userInteractive, attributes: .concurrent)
|
|
||||||
|
|
||||||
private static let rgbColorSpace = CGColorSpaceCreateDeviceRGB()
|
|
||||||
private static let bitmapInfo = CGBitmapInfo(rawValue: CGImageAlphaInfo.premultipliedLast.rawValue).rawValue
|
|
||||||
private static var requests = [Int64: Request]()
|
|
||||||
private static let cancelledResult = Result<[String: Int64], any Error>.success([:])
|
|
||||||
private static let concurrencySemaphore = DispatchSemaphore(value: ProcessInfo.processInfo.activeProcessorCount * 2)
|
|
||||||
private static let assetCache = {
|
|
||||||
let assetCache = NSCache<NSString, PHAsset>()
|
|
||||||
assetCache.countLimit = 10000
|
|
||||||
return assetCache
|
|
||||||
}()
|
|
||||||
|
|
||||||
func requestImage(assetId: String, requestId: Int64, width: Int64, height: Int64, completion: @escaping (Result<[String: Int64], any Error>) -> Void) {
|
|
||||||
let request = Request(callback: completion)
|
|
||||||
let item = DispatchWorkItem {
|
|
||||||
if request.isCancelled {
|
|
||||||
return completion(Self.cancelledResult)
|
|
||||||
}
|
|
||||||
|
|
||||||
Self.concurrencySemaphore.wait()
|
|
||||||
defer {
|
|
||||||
Self.concurrencySemaphore.signal()
|
|
||||||
}
|
|
||||||
|
|
||||||
if request.isCancelled {
|
|
||||||
return completion(Self.cancelledResult)
|
|
||||||
}
|
|
||||||
|
|
||||||
guard let asset = Self.requestAsset(assetId: assetId)
|
|
||||||
else {
|
|
||||||
Self.removeRequest(requestId: requestId)
|
|
||||||
completion(.failure(PigeonError(code: "", message: "Could not get asset data for \(assetId)", details: nil)))
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if request.isCancelled {
|
|
||||||
return completion(Self.cancelledResult)
|
|
||||||
}
|
|
||||||
|
|
||||||
var image: UIImage?
|
|
||||||
Self.imageManager.requestImage(
|
|
||||||
for: asset,
|
|
||||||
targetSize: CGSize(width: Double(width), height: Double(height)),
|
|
||||||
contentMode: .aspectFit,
|
|
||||||
options: Self.requestOptions,
|
|
||||||
resultHandler: { (_image, info) -> Void in
|
|
||||||
image = _image
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
if request.isCancelled {
|
|
||||||
return completion(Self.cancelledResult)
|
|
||||||
}
|
|
||||||
|
|
||||||
guard let image = image,
|
|
||||||
let cgImage = image.cgImage else {
|
|
||||||
Self.removeRequest(requestId: requestId)
|
|
||||||
return completion(.failure(PigeonError(code: "", message: "Could not get pixel data for \(assetId)", details: nil)))
|
|
||||||
}
|
|
||||||
|
|
||||||
let pointer = UnsafeMutableRawPointer.allocate(
|
|
||||||
byteCount: Int(cgImage.width) * Int(cgImage.height) * 4,
|
|
||||||
alignment: MemoryLayout<UInt8>.alignment
|
|
||||||
)
|
|
||||||
|
|
||||||
if request.isCancelled {
|
|
||||||
pointer.deallocate()
|
|
||||||
return completion(Self.cancelledResult)
|
|
||||||
}
|
|
||||||
|
|
||||||
guard let context = CGContext(
|
|
||||||
data: pointer,
|
|
||||||
width: cgImage.width,
|
|
||||||
height: cgImage.height,
|
|
||||||
bitsPerComponent: 8,
|
|
||||||
bytesPerRow: cgImage.width * 4,
|
|
||||||
space: Self.rgbColorSpace,
|
|
||||||
bitmapInfo: Self.bitmapInfo
|
|
||||||
) else {
|
|
||||||
pointer.deallocate()
|
|
||||||
Self.removeRequest(requestId: requestId)
|
|
||||||
return completion(.failure(PigeonError(code: "", message: "Could not create context for \(assetId)", details: nil)))
|
|
||||||
}
|
|
||||||
|
|
||||||
if request.isCancelled {
|
|
||||||
pointer.deallocate()
|
|
||||||
return completion(Self.cancelledResult)
|
|
||||||
}
|
|
||||||
|
|
||||||
context.interpolationQuality = .none
|
|
||||||
context.draw(cgImage, in: CGRect(x: 0, y: 0, width: cgImage.width, height: cgImage.height))
|
|
||||||
|
|
||||||
if request.isCancelled {
|
|
||||||
pointer.deallocate()
|
|
||||||
return completion(Self.cancelledResult)
|
|
||||||
}
|
|
||||||
|
|
||||||
completion(.success(["pointer": Int64(Int(bitPattern: pointer)), "width": Int64(cgImage.width), "height": Int64(cgImage.height)]))
|
|
||||||
Self.removeRequest(requestId: requestId)
|
|
||||||
}
|
|
||||||
|
|
||||||
request.workItem = item
|
|
||||||
Self.addRequest(requestId: requestId, request: request)
|
|
||||||
Self.processingQueue.async(execute: item)
|
|
||||||
}
|
|
||||||
|
|
||||||
func cancelImageRequest(requestId: Int64) {
|
|
||||||
Self.cancelRequest(requestId: requestId)
|
|
||||||
}
|
|
||||||
|
|
||||||
private static func addRequest(requestId: Int64, request: Request) -> Void {
|
|
||||||
requestQueue.sync { requests[requestId] = request }
|
|
||||||
}
|
|
||||||
|
|
||||||
private static func removeRequest(requestId: Int64) -> Void {
|
|
||||||
requestQueue.sync { requests[requestId] = nil }
|
|
||||||
}
|
|
||||||
|
|
||||||
private static func cancelRequest(requestId: Int64) -> Void {
|
|
||||||
requestQueue.async {
|
|
||||||
guard let request = requests.removeValue(forKey: requestId) else { return }
|
|
||||||
request.isCancelled = true
|
|
||||||
guard let item = request.workItem else { return }
|
|
||||||
if item.isCancelled {
|
|
||||||
request.callback(Self.cancelledResult)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static func requestAsset(assetId: String) -> PHAsset? {
|
|
||||||
var asset: PHAsset?
|
|
||||||
assetQueue.sync { asset = assetCache.object(forKey: assetId as NSString) }
|
|
||||||
if asset != nil { return asset }
|
|
||||||
|
|
||||||
guard let asset = PHAsset.fetchAssets(withLocalIdentifiers: [assetId], options: Self.fetchOptions).firstObject
|
|
||||||
else { return nil }
|
|
||||||
assetQueue.async { assetCache.setObject(asset, forKey: assetId as NSString) }
|
|
||||||
return asset
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -26,9 +26,8 @@ const String kDownloadGroupLivePhoto = 'group_livephoto';
|
|||||||
|
|
||||||
// Timeline constants
|
// Timeline constants
|
||||||
const int kTimelineNoneSegmentSize = 120;
|
const int kTimelineNoneSegmentSize = 120;
|
||||||
const int kTimelineAssetLoadBatchSize = 1024;
|
const int kTimelineAssetLoadBatchSize = 256;
|
||||||
const int kTimelineAssetLoadOppositeSize = 64;
|
const int kTimelineAssetLoadOppositeSize = 64;
|
||||||
const int kTimelineImageCacheMemory = 200 * 1024 * 1024;
|
|
||||||
|
|
||||||
// Widget keys
|
// Widget keys
|
||||||
const String appShareGroupId = "group.app.immich.share";
|
const String appShareGroupId = "group.app.immich.share";
|
||||||
|
|||||||
@@ -85,13 +85,3 @@ extension DateRangeFormatting on DateTime {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extension IsSameExtension on DateTime {
|
|
||||||
bool isSameDay(DateTime other) {
|
|
||||||
return day == other.day && month == other.month && year == other.year;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool isSameMonth(DateTime other) {
|
|
||||||
return month == other.month && year == other.year;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,211 +1,18 @@
|
|||||||
import 'dart:async';
|
import 'dart:typed_data';
|
||||||
import 'dart:ffi';
|
import 'dart:ui';
|
||||||
import 'dart:io';
|
|
||||||
import 'dart:ui' as ui;
|
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:photo_manager/photo_manager.dart';
|
||||||
import 'package:flutter/services.dart';
|
|
||||||
import 'package:flutter/foundation.dart';
|
|
||||||
import 'package:immich_mobile/providers/image/cache/remote_image_cache_manager.dart';
|
|
||||||
import 'package:immich_mobile/providers/infrastructure/platform.provider.dart';
|
|
||||||
import 'package:ffi/ffi.dart';
|
|
||||||
import 'package:immich_mobile/services/api.service.dart';
|
|
||||||
import 'package:logging/logging.dart';
|
|
||||||
|
|
||||||
abstract class ImageRequest {
|
class AssetMediaRepository {
|
||||||
static int _nextRequestId = 0;
|
const AssetMediaRepository();
|
||||||
|
|
||||||
final int requestId = _nextRequestId++;
|
Future<Uint8List?> getThumbnail(String id, {int quality = 80, Size size = const Size.square(256)}) => AssetEntity(
|
||||||
bool _isCancelled = false;
|
id: id,
|
||||||
|
// The below fields are not used in thumbnailDataWithSize but are required
|
||||||
get isCancelled => _isCancelled;
|
// to create an AssetEntity instance. It is faster to create a dummy AssetEntity
|
||||||
|
// instance than to fetch the asset from the device first.
|
||||||
ImageRequest();
|
typeInt: AssetType.image.index,
|
||||||
|
width: size.width.toInt(),
|
||||||
Future<ImageInfo?> load(ImageDecoderCallback decode, {double scale = 1.0});
|
height: size.height.toInt(),
|
||||||
|
).thumbnailDataWithSize(ThumbnailSize(size.width.toInt(), size.height.toInt()), quality: quality);
|
||||||
void cancel() {
|
|
||||||
if (isCancelled) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
_isCancelled = true;
|
|
||||||
return _onCancelled();
|
|
||||||
}
|
|
||||||
|
|
||||||
void _onCancelled();
|
|
||||||
}
|
|
||||||
|
|
||||||
class LocalImageRequest extends ImageRequest {
|
|
||||||
final String localId;
|
|
||||||
final int width;
|
|
||||||
final int height;
|
|
||||||
|
|
||||||
LocalImageRequest({required this.localId, required ui.Size size})
|
|
||||||
: width = size.width.toInt(),
|
|
||||||
height = size.height.toInt();
|
|
||||||
|
|
||||||
@override
|
|
||||||
Future<ImageInfo?> load(ImageDecoderCallback decode, {double scale = 1.0}) async {
|
|
||||||
if (_isCancelled) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
final Map<String, int> info = await thumbnailApi.requestImage(
|
|
||||||
localId,
|
|
||||||
requestId: requestId,
|
|
||||||
width: width,
|
|
||||||
height: height,
|
|
||||||
);
|
|
||||||
|
|
||||||
final address = info['pointer'];
|
|
||||||
if (address == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
final pointer = Pointer<Uint8>.fromAddress(address);
|
|
||||||
try {
|
|
||||||
if (_isCancelled) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
final actualWidth = info['width']!;
|
|
||||||
final actualHeight = info['height']!;
|
|
||||||
final actualSize = actualWidth * actualHeight * 4;
|
|
||||||
|
|
||||||
final buffer = await ImmutableBuffer.fromUint8List(pointer.asTypedList(actualSize));
|
|
||||||
if (_isCancelled) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
final descriptor = ui.ImageDescriptor.raw(
|
|
||||||
buffer,
|
|
||||||
width: actualWidth,
|
|
||||||
height: actualHeight,
|
|
||||||
pixelFormat: ui.PixelFormat.rgba8888,
|
|
||||||
);
|
|
||||||
final codec = await descriptor.instantiateCodec();
|
|
||||||
if (_isCancelled) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
final frame = await codec.getNextFrame();
|
|
||||||
return ImageInfo(image: frame.image, scale: scale);
|
|
||||||
} finally {
|
|
||||||
malloc.free(pointer);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Future<void> _onCancelled() {
|
|
||||||
return thumbnailApi.cancelImageRequest(requestId);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class RemoteImageRequest extends ImageRequest {
|
|
||||||
static final log = Logger('RemoteImageRequest');
|
|
||||||
static final cacheManager = RemoteImageCacheManager();
|
|
||||||
static final client = HttpClient();
|
|
||||||
String uri;
|
|
||||||
Map<String, String> headers;
|
|
||||||
HttpClientRequest? _request;
|
|
||||||
|
|
||||||
RemoteImageRequest({required this.uri, required this.headers});
|
|
||||||
|
|
||||||
@override
|
|
||||||
Future<ImageInfo?> load(ImageDecoderCallback decode, {double scale = 1.0}) async {
|
|
||||||
if (_isCancelled) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
// The DB calls made by the cache manager are a *massive* bottleneck (6+ seconds) with high concurrency.
|
|
||||||
// Since it isn't possible to cancel these operations, we only prefer the cache when they can be avoided.
|
|
||||||
// The DB hit is left as a fallback for offline use.
|
|
||||||
final cachedFileBuffer = await _loadCachedFile(uri, inMemoryOnly: true);
|
|
||||||
if (cachedFileBuffer != null) {
|
|
||||||
return _decodeBuffer(cachedFileBuffer, decode, scale);
|
|
||||||
}
|
|
||||||
|
|
||||||
final buffer = await _downloadImage(uri);
|
|
||||||
if (buffer == null || _isCancelled) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return await _decodeBuffer(buffer, decode, scale);
|
|
||||||
} catch (e) {
|
|
||||||
if (e is HttpException && (e.message.endsWith('aborted') || e.message.startsWith('Connection closed'))) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
log.severe('Failed to load remote image', e);
|
|
||||||
final buffer = await _loadCachedFile(uri, inMemoryOnly: false);
|
|
||||||
if (buffer != null) {
|
|
||||||
return _decodeBuffer(buffer, decode, scale);
|
|
||||||
}
|
|
||||||
rethrow;
|
|
||||||
} finally {
|
|
||||||
_request = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<ImmutableBuffer?> _downloadImage(String url) async {
|
|
||||||
final request = _request = await client.getUrl(Uri.parse(url));
|
|
||||||
if (_isCancelled) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
final headers = ApiService.getRequestHeaders();
|
|
||||||
for (final entry in headers.entries) {
|
|
||||||
request.headers.set(entry.key, entry.value);
|
|
||||||
}
|
|
||||||
final response = await request.close();
|
|
||||||
if (_isCancelled) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
final bytes = await consolidateHttpClientResponseBytes(response);
|
|
||||||
_cacheFile(url, bytes);
|
|
||||||
if (_isCancelled) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return await ImmutableBuffer.fromUint8List(bytes);
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> _cacheFile(String url, Uint8List bytes) async {
|
|
||||||
try {
|
|
||||||
await cacheManager.putFile(url, bytes);
|
|
||||||
} catch (e) {
|
|
||||||
log.severe('Failed to cache image', e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<ImmutableBuffer?> _loadCachedFile(String url, {required bool inMemoryOnly}) async {
|
|
||||||
if (_isCancelled) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
final file = await (inMemoryOnly ? cacheManager.getFileFromMemory(url) : cacheManager.getFileFromCache(url));
|
|
||||||
if (_isCancelled || file == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return await ImmutableBuffer.fromFilePath(file.file.path);
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<ImageInfo?> _decodeBuffer(ImmutableBuffer buffer, ImageDecoderCallback decode, scale) async {
|
|
||||||
if (_isCancelled) {
|
|
||||||
buffer.dispose();
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
final codec = await decode(buffer);
|
|
||||||
if (_isCancelled) {
|
|
||||||
buffer.dispose();
|
|
||||||
codec.dispose();
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
final frame = await codec.getNextFrame();
|
|
||||||
return ImageInfo(image: frame.image, scale: scale);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
void _onCancelled() {
|
|
||||||
_request?.abort();
|
|
||||||
_request = null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -71,8 +71,6 @@ Future<void> initApp() async {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PaintingBinding.instance.imageCache.maximumSizeBytes = kTimelineImageCacheMemory;
|
|
||||||
|
|
||||||
await DynamicTheme.fetchSystemPalette();
|
await DynamicTheme.fetchSystemPalette();
|
||||||
|
|
||||||
final log = Logger("ImmichErrorLogger");
|
final log = Logger("ImmichErrorLogger");
|
||||||
|
|||||||
@@ -224,7 +224,7 @@ class FileDetailDialog extends ConsumerWidget {
|
|||||||
borderRadius: const BorderRadius.all(Radius.circular(12)),
|
borderRadius: const BorderRadius.all(Radius.circular(12)),
|
||||||
),
|
),
|
||||||
child: asset != null
|
child: asset != null
|
||||||
? Thumbnail.fromBaseAsset(asset: asset, size: const Size(512, 512), fit: BoxFit.cover)
|
? Thumbnail(asset: asset, size: const Size(512, 512), fit: BoxFit.cover)
|
||||||
: null,
|
: null,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
Generated
-107
@@ -1,107 +0,0 @@
|
|||||||
// Autogenerated from Pigeon (v26.0.0), do not edit directly.
|
|
||||||
// See also: https://pub.dev/packages/pigeon
|
|
||||||
// ignore_for_file: public_member_api_docs, non_constant_identifier_names, avoid_as, unused_import, unnecessary_parenthesis, prefer_null_aware_operators, omit_local_variable_types, unused_shown_name, unnecessary_import, no_leading_underscores_for_local_identifiers
|
|
||||||
|
|
||||||
import 'dart:async';
|
|
||||||
import 'dart:typed_data' show Float64List, Int32List, Int64List, Uint8List;
|
|
||||||
|
|
||||||
import 'package:flutter/foundation.dart' show ReadBuffer, WriteBuffer;
|
|
||||||
import 'package:flutter/services.dart';
|
|
||||||
|
|
||||||
PlatformException _createConnectionError(String channelName) {
|
|
||||||
return PlatformException(
|
|
||||||
code: 'channel-error',
|
|
||||||
message: 'Unable to establish connection on channel: "$channelName".',
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
class _PigeonCodec extends StandardMessageCodec {
|
|
||||||
const _PigeonCodec();
|
|
||||||
@override
|
|
||||||
void writeValue(WriteBuffer buffer, Object? value) {
|
|
||||||
if (value is int) {
|
|
||||||
buffer.putUint8(4);
|
|
||||||
buffer.putInt64(value);
|
|
||||||
} else {
|
|
||||||
super.writeValue(buffer, value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Object? readValueOfType(int type, ReadBuffer buffer) {
|
|
||||||
switch (type) {
|
|
||||||
default:
|
|
||||||
return super.readValueOfType(type, buffer);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class ThumbnailApi {
|
|
||||||
/// Constructor for [ThumbnailApi]. The [binaryMessenger] named argument is
|
|
||||||
/// available for dependency injection. If it is left null, the default
|
|
||||||
/// BinaryMessenger will be used which routes to the host platform.
|
|
||||||
ThumbnailApi({BinaryMessenger? binaryMessenger, String messageChannelSuffix = ''})
|
|
||||||
: pigeonVar_binaryMessenger = binaryMessenger,
|
|
||||||
pigeonVar_messageChannelSuffix = messageChannelSuffix.isNotEmpty ? '.$messageChannelSuffix' : '';
|
|
||||||
final BinaryMessenger? pigeonVar_binaryMessenger;
|
|
||||||
|
|
||||||
static const MessageCodec<Object?> pigeonChannelCodec = _PigeonCodec();
|
|
||||||
|
|
||||||
final String pigeonVar_messageChannelSuffix;
|
|
||||||
|
|
||||||
Future<Map<String, int>> requestImage(
|
|
||||||
String assetId, {
|
|
||||||
required int requestId,
|
|
||||||
required int width,
|
|
||||||
required int height,
|
|
||||||
}) async {
|
|
||||||
final String pigeonVar_channelName =
|
|
||||||
'dev.flutter.pigeon.immich_mobile.ThumbnailApi.requestImage$pigeonVar_messageChannelSuffix';
|
|
||||||
final BasicMessageChannel<Object?> pigeonVar_channel = BasicMessageChannel<Object?>(
|
|
||||||
pigeonVar_channelName,
|
|
||||||
pigeonChannelCodec,
|
|
||||||
binaryMessenger: pigeonVar_binaryMessenger,
|
|
||||||
);
|
|
||||||
final Future<Object?> pigeonVar_sendFuture = pigeonVar_channel.send(<Object?>[assetId, requestId, width, height]);
|
|
||||||
final List<Object?>? pigeonVar_replyList = await pigeonVar_sendFuture as List<Object?>?;
|
|
||||||
if (pigeonVar_replyList == null) {
|
|
||||||
throw _createConnectionError(pigeonVar_channelName);
|
|
||||||
} else if (pigeonVar_replyList.length > 1) {
|
|
||||||
throw PlatformException(
|
|
||||||
code: pigeonVar_replyList[0]! as String,
|
|
||||||
message: pigeonVar_replyList[1] as String?,
|
|
||||||
details: pigeonVar_replyList[2],
|
|
||||||
);
|
|
||||||
} else if (pigeonVar_replyList[0] == null) {
|
|
||||||
throw PlatformException(
|
|
||||||
code: 'null-error',
|
|
||||||
message: 'Host platform returned null value for non-null return value.',
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
return (pigeonVar_replyList[0] as Map<Object?, Object?>?)!.cast<String, int>();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> cancelImageRequest(int requestId) async {
|
|
||||||
final String pigeonVar_channelName =
|
|
||||||
'dev.flutter.pigeon.immich_mobile.ThumbnailApi.cancelImageRequest$pigeonVar_messageChannelSuffix';
|
|
||||||
final BasicMessageChannel<Object?> pigeonVar_channel = BasicMessageChannel<Object?>(
|
|
||||||
pigeonVar_channelName,
|
|
||||||
pigeonChannelCodec,
|
|
||||||
binaryMessenger: pigeonVar_binaryMessenger,
|
|
||||||
);
|
|
||||||
final Future<Object?> pigeonVar_sendFuture = pigeonVar_channel.send(<Object?>[requestId]);
|
|
||||||
final List<Object?>? pigeonVar_replyList = await pigeonVar_sendFuture as List<Object?>?;
|
|
||||||
if (pigeonVar_replyList == null) {
|
|
||||||
throw _createConnectionError(pigeonVar_channelName);
|
|
||||||
} else if (pigeonVar_replyList.length > 1) {
|
|
||||||
throw PlatformException(
|
|
||||||
code: pigeonVar_replyList[0]! as String,
|
|
||||||
message: pigeonVar_replyList[1] as String?,
|
|
||||||
details: pigeonVar_replyList[2],
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -119,7 +119,7 @@ class _DriftCreateAlbumPageState extends ConsumerState<DriftCreateAlbumPage> {
|
|||||||
final asset = selectedAssets.elementAt(index);
|
final asset = selectedAssets.elementAt(index);
|
||||||
return GestureDetector(
|
return GestureDetector(
|
||||||
onTap: onBackgroundTapped,
|
onTap: onBackgroundTapped,
|
||||||
child: Thumbnail.fromBaseAsset(asset: asset),
|
child: Thumbnail(asset: asset),
|
||||||
);
|
);
|
||||||
}, childCount: selectedAssets.length),
|
}, childCount: selectedAssets.length),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import 'package:hooks_riverpod/hooks_riverpod.dart';
|
|||||||
import 'package:immich_mobile/extensions/build_context_extensions.dart';
|
import 'package:immich_mobile/extensions/build_context_extensions.dart';
|
||||||
import 'package:immich_mobile/extensions/translate_extensions.dart';
|
import 'package:immich_mobile/extensions/translate_extensions.dart';
|
||||||
import 'package:immich_mobile/pages/common/large_leading_tile.dart';
|
import 'package:immich_mobile/pages/common/large_leading_tile.dart';
|
||||||
import 'package:immich_mobile/presentation/widgets/images/remote_image_provider.dart';
|
|
||||||
import 'package:immich_mobile/presentation/widgets/images/thumbnail.widget.dart';
|
import 'package:immich_mobile/presentation/widgets/images/thumbnail.widget.dart';
|
||||||
import 'package:immich_mobile/providers/infrastructure/asset.provider.dart';
|
import 'package:immich_mobile/providers/infrastructure/asset.provider.dart';
|
||||||
import 'package:immich_mobile/routing/router.dart';
|
import 'package:immich_mobile/routing/router.dart';
|
||||||
@@ -164,11 +163,7 @@ class _PlaceTile extends StatelessWidget {
|
|||||||
title: Text(place.$1, style: context.textTheme.titleMedium?.copyWith(fontWeight: FontWeight.w500)),
|
title: Text(place.$1, style: context.textTheme.titleMedium?.copyWith(fontWeight: FontWeight.w500)),
|
||||||
leading: ClipRRect(
|
leading: ClipRRect(
|
||||||
borderRadius: const BorderRadius.all(Radius.circular(20)),
|
borderRadius: const BorderRadius.all(Radius.circular(20)),
|
||||||
child: Thumbnail(
|
child: Thumbnail(size: const Size(80, 80), fit: BoxFit.cover, remoteId: place.$2),
|
||||||
imageProvider: RemoteThumbProvider(assetId: place.$2),
|
|
||||||
size: const Size(80, 80),
|
|
||||||
fit: BoxFit.cover,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ import 'package:immich_mobile/presentation/widgets/bottom_sheet/remote_album_bot
|
|||||||
import 'package:immich_mobile/presentation/widgets/remote_album/drift_album_option.widget.dart';
|
import 'package:immich_mobile/presentation/widgets/remote_album/drift_album_option.widget.dart';
|
||||||
import 'package:immich_mobile/presentation/widgets/timeline/timeline.widget.dart';
|
import 'package:immich_mobile/presentation/widgets/timeline/timeline.widget.dart';
|
||||||
import 'package:immich_mobile/providers/infrastructure/album.provider.dart';
|
import 'package:immich_mobile/providers/infrastructure/album.provider.dart';
|
||||||
import 'package:immich_mobile/providers/infrastructure/current_album.provider.dart';
|
|
||||||
import 'package:immich_mobile/providers/infrastructure/remote_album.provider.dart';
|
import 'package:immich_mobile/providers/infrastructure/remote_album.provider.dart';
|
||||||
import 'package:immich_mobile/providers/infrastructure/timeline.provider.dart';
|
import 'package:immich_mobile/providers/infrastructure/timeline.provider.dart';
|
||||||
import 'package:immich_mobile/providers/user.provider.dart';
|
import 'package:immich_mobile/providers/user.provider.dart';
|
||||||
@@ -216,18 +215,7 @@ class _RemoteAlbumPageState extends ConsumerState<RemoteAlbumPage> {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return PopScope(
|
return ProviderScope(
|
||||||
onPopInvokedWithResult: (didPop, _) {
|
|
||||||
if (didPop) {
|
|
||||||
Future.microtask(() {
|
|
||||||
if (mounted) {
|
|
||||||
ref.read(currentRemoteAlbumProvider.notifier).dispose();
|
|
||||||
ref.read(remoteAlbumProvider.notifier).refresh();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
},
|
|
||||||
child: ProviderScope(
|
|
||||||
overrides: [
|
overrides: [
|
||||||
timelineServiceProvider.overrideWith((ref) {
|
timelineServiceProvider.overrideWith((ref) {
|
||||||
final timelineService = ref.watch(timelineFactoryProvider).remoteAlbum(albumId: _album.id);
|
final timelineService = ref.watch(timelineFactoryProvider).remoteAlbum(albumId: _album.id);
|
||||||
@@ -244,7 +232,6 @@ class _RemoteAlbumPageState extends ConsumerState<RemoteAlbumPage> {
|
|||||||
),
|
),
|
||||||
bottomSheet: RemoteAlbumBottomSheet(album: _album),
|
bottomSheet: RemoteAlbumBottomSheet(album: _album),
|
||||||
),
|
),
|
||||||
),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,6 @@ import 'package:immich_mobile/extensions/theme_extensions.dart';
|
|||||||
import 'package:immich_mobile/extensions/translate_extensions.dart';
|
import 'package:immich_mobile/extensions/translate_extensions.dart';
|
||||||
import 'package:immich_mobile/models/albums/album_search.model.dart';
|
import 'package:immich_mobile/models/albums/album_search.model.dart';
|
||||||
import 'package:immich_mobile/pages/common/large_leading_tile.dart';
|
import 'package:immich_mobile/pages/common/large_leading_tile.dart';
|
||||||
import 'package:immich_mobile/presentation/widgets/images/remote_image_provider.dart';
|
|
||||||
import 'package:immich_mobile/presentation/widgets/images/thumbnail.widget.dart';
|
import 'package:immich_mobile/presentation/widgets/images/thumbnail.widget.dart';
|
||||||
import 'package:immich_mobile/providers/infrastructure/album.provider.dart';
|
import 'package:immich_mobile/providers/infrastructure/album.provider.dart';
|
||||||
import 'package:immich_mobile/providers/infrastructure/current_album.provider.dart';
|
import 'package:immich_mobile/providers/infrastructure/current_album.provider.dart';
|
||||||
@@ -444,11 +443,7 @@ class _AlbumList extends ConsumerWidget {
|
|||||||
leading: album.thumbnailAssetId != null
|
leading: album.thumbnailAssetId != null
|
||||||
? ClipRRect(
|
? ClipRRect(
|
||||||
borderRadius: const BorderRadius.all(Radius.circular(15)),
|
borderRadius: const BorderRadius.all(Radius.circular(15)),
|
||||||
child: SizedBox(
|
child: SizedBox(width: 80, height: 80, child: Thumbnail(remoteId: album.thumbnailAssetId)),
|
||||||
width: 80,
|
|
||||||
height: 80,
|
|
||||||
child: Thumbnail(imageProvider: RemoteThumbProvider(assetId: album.thumbnailAssetId!)),
|
|
||||||
),
|
|
||||||
)
|
)
|
||||||
: SizedBox(
|
: SizedBox(
|
||||||
width: 80,
|
width: 80,
|
||||||
@@ -534,7 +529,7 @@ class _GridAlbumCard extends ConsumerWidget {
|
|||||||
child: SizedBox(
|
child: SizedBox(
|
||||||
width: double.infinity,
|
width: double.infinity,
|
||||||
child: album.thumbnailAssetId != null
|
child: album.thumbnailAssetId != null
|
||||||
? Thumbnail(imageProvider: RemoteThumbProvider(assetId: album.thumbnailAssetId!))
|
? Thumbnail(remoteId: album.thumbnailAssetId)
|
||||||
: Container(
|
: Container(
|
||||||
color: context.colorScheme.surfaceContainerHighest,
|
color: context.colorScheme.surfaceContainerHighest,
|
||||||
child: const Icon(Icons.photo_album_rounded, size: 40, color: Colors.grey),
|
child: const Icon(Icons.photo_album_rounded, size: 40, color: Colors.grey),
|
||||||
|
|||||||
@@ -172,8 +172,9 @@ class _AssetViewerState extends ConsumerState<AssetViewer> {
|
|||||||
// Check if widget is still mounted before proceeding
|
// Check if widget is still mounted before proceeding
|
||||||
if (!mounted) return;
|
if (!mounted) return;
|
||||||
|
|
||||||
unawaited(_precacheImage(index - 1));
|
for (final offset in [-1, 1]) {
|
||||||
unawaited(_precacheImage(index + 1));
|
unawaited(_precacheImage(index + offset));
|
||||||
|
}
|
||||||
});
|
});
|
||||||
_delayedOperations.add(timer);
|
_delayedOperations.add(timer);
|
||||||
|
|
||||||
@@ -232,7 +233,7 @@ class _AssetViewerState extends ConsumerState<AssetViewer> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void _onDragStart(
|
void _onDragStart(
|
||||||
_,
|
BuildContext ctx,
|
||||||
DragStartDetails details,
|
DragStartDetails details,
|
||||||
PhotoViewControllerBase controller,
|
PhotoViewControllerBase controller,
|
||||||
PhotoViewScaleStateController scaleStateController,
|
PhotoViewScaleStateController scaleStateController,
|
||||||
@@ -248,7 +249,7 @@ class _AssetViewerState extends ConsumerState<AssetViewer> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void _onDragEnd(BuildContext ctx, _, __) {
|
void _onDragEnd(BuildContext ctx, DragEndDetails details, PhotoViewControllerValue value) {
|
||||||
dragInProgress = false;
|
dragInProgress = false;
|
||||||
|
|
||||||
if (shouldPopOnDrag) {
|
if (shouldPopOnDrag) {
|
||||||
@@ -279,7 +280,7 @@ class _AssetViewerState extends ConsumerState<AssetViewer> {
|
|||||||
ref.read(assetViewerProvider.notifier).setOpacity(255);
|
ref.read(assetViewerProvider.notifier).setOpacity(255);
|
||||||
}
|
}
|
||||||
|
|
||||||
void _onDragUpdate(BuildContext ctx, DragUpdateDetails details, _) {
|
void _onDragUpdate(BuildContext ctx, DragUpdateDetails details, PhotoViewControllerValue value) {
|
||||||
if (blockGestures) {
|
if (blockGestures) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -333,7 +334,7 @@ class _AssetViewerState extends ConsumerState<AssetViewer> {
|
|||||||
ref.read(assetViewerProvider.notifier).setOpacity(backgroundOpacity);
|
ref.read(assetViewerProvider.notifier).setOpacity(backgroundOpacity);
|
||||||
}
|
}
|
||||||
|
|
||||||
void _onTapDown(_, __, ___) {
|
void _onTapDown(BuildContext ctx, TapDownDetails details, PhotoViewControllerValue value) {
|
||||||
if (!showingBottomSheet) {
|
if (!showingBottomSheet) {
|
||||||
ref.read(assetViewerProvider.notifier).toggleControls();
|
ref.read(assetViewerProvider.notifier).toggleControls();
|
||||||
}
|
}
|
||||||
@@ -470,9 +471,14 @@ class _AssetViewerState extends ConsumerState<AssetViewer> {
|
|||||||
BaseAsset asset = ref.read(timelineServiceProvider).getAsset(index);
|
BaseAsset asset = ref.read(timelineServiceProvider).getAsset(index);
|
||||||
final stackChildren = ref.read(stackChildrenNotifier(asset)).valueOrNull;
|
final stackChildren = ref.read(stackChildrenNotifier(asset)).valueOrNull;
|
||||||
if (stackChildren != null && stackChildren.isNotEmpty) {
|
if (stackChildren != null && stackChildren.isNotEmpty) {
|
||||||
asset = stackChildren.elementAt(ref.read(assetViewerProvider.select((s) => s.stackIndex)));
|
asset = stackChildren.elementAt(ref.read(assetViewerProvider).stackIndex);
|
||||||
}
|
}
|
||||||
return Thumbnail.fromBaseAsset(asset: asset, fit: BoxFit.contain);
|
return Container(
|
||||||
|
width: double.infinity,
|
||||||
|
height: double.infinity,
|
||||||
|
color: backgroundColor,
|
||||||
|
child: Thumbnail(asset: asset, fit: BoxFit.contain),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
void _onScaleStateChanged(PhotoViewScaleState scaleState) {
|
void _onScaleStateChanged(PhotoViewScaleState scaleState) {
|
||||||
@@ -481,7 +487,7 @@ class _AssetViewerState extends ConsumerState<AssetViewer> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void _onLongPress(_, __, ___) {
|
void _onLongPress(BuildContext ctx, LongPressStartDetails details, PhotoViewControllerValue value) {
|
||||||
ref.read(isPlayingMotionVideoProvider.notifier).playing = true;
|
ref.read(isPlayingMotionVideoProvider.notifier).playing = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -505,7 +511,12 @@ class _AssetViewerState extends ConsumerState<AssetViewer> {
|
|||||||
final size = ctx.sizeData;
|
final size = ctx.sizeData;
|
||||||
return PhotoViewGalleryPageOptions(
|
return PhotoViewGalleryPageOptions(
|
||||||
key: ValueKey(asset.heroTag),
|
key: ValueKey(asset.heroTag),
|
||||||
imageProvider: getFullImageProvider(asset, size: size),
|
// When the bottom sheet is shown and the asset is changed,
|
||||||
|
// the cached image can have different position and scale than the normal one,
|
||||||
|
// causing incorrect animation calculations once the image provider yields a new image.
|
||||||
|
// This is a workaround to ensure the animation is handled correctly in this case.
|
||||||
|
// TODO: handle this without needing to disable caching
|
||||||
|
imageProvider: getFullImageProvider(asset, size: size, showCached: !showingBottomSheet),
|
||||||
heroAttributes: PhotoViewHeroAttributes(tag: '${asset.heroTag}_$heroOffset'),
|
heroAttributes: PhotoViewHeroAttributes(tag: '${asset.heroTag}_$heroOffset'),
|
||||||
filterQuality: FilterQuality.high,
|
filterQuality: FilterQuality.high,
|
||||||
tightMode: true,
|
tightMode: true,
|
||||||
@@ -521,7 +532,7 @@ class _AssetViewerState extends ConsumerState<AssetViewer> {
|
|||||||
width: size.width,
|
width: size.width,
|
||||||
height: size.height,
|
height: size.height,
|
||||||
color: backgroundColor,
|
color: backgroundColor,
|
||||||
child: Thumbnail.fromBaseAsset(asset: asset, fit: BoxFit.contain),
|
child: Thumbnail(asset: asset, fit: BoxFit.contain),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -75,46 +75,32 @@ class AssetViewerStateNotifier extends AutoDisposeNotifier<AssetViewerState> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void setAsset(BaseAsset? asset) {
|
void setAsset(BaseAsset? asset) {
|
||||||
if (asset != state.currentAsset) {
|
|
||||||
state = state.copyWith(currentAsset: asset, stackIndex: 0);
|
state = state.copyWith(currentAsset: asset, stackIndex: 0);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void setOpacity(int opacity) {
|
void setOpacity(int opacity) {
|
||||||
if (opacity != state.backgroundOpacity) {
|
state = state.copyWith(backgroundOpacity: opacity, showingControls: opacity == 255 ? true : state.showingControls);
|
||||||
state = state.copyWith(
|
|
||||||
backgroundOpacity: opacity,
|
|
||||||
showingControls: opacity == 255 ? true : state.showingControls,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void setBottomSheet(bool showing) {
|
void setBottomSheet(bool showing) {
|
||||||
if (showing == state.showingBottomSheet) {
|
state = state.copyWith(showingBottomSheet: showing, showingControls: showing ? true : state.showingControls);
|
||||||
return;
|
|
||||||
}
|
|
||||||
state = state.copyWith(showingBottomSheet: showing, showingControls: showing || state.showingControls);
|
|
||||||
if (showing) {
|
if (showing) {
|
||||||
ref.read(videoPlayerControlsProvider.notifier).pause();
|
ref.read(videoPlayerControlsProvider.notifier).pause();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void setControls(bool isShowing) {
|
void setControls(bool isShowing) {
|
||||||
if (isShowing != state.showingControls) {
|
|
||||||
state = state.copyWith(showingControls: isShowing);
|
state = state.copyWith(showingControls: isShowing);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void toggleControls() {
|
void toggleControls() {
|
||||||
state = state.copyWith(showingControls: !state.showingControls);
|
state = state.copyWith(showingControls: !state.showingControls);
|
||||||
}
|
}
|
||||||
|
|
||||||
void setStackIndex(int index) {
|
void setStackIndex(int index) {
|
||||||
if (index != state.stackIndex) {
|
|
||||||
state = state.copyWith(stackIndex: index);
|
state = state.copyWith(stackIndex: index);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
final assetViewerProvider = AutoDisposeNotifierProvider<AssetViewerStateNotifier, AssetViewerState>(
|
final assetViewerProvider = AutoDisposeNotifierProvider<AssetViewerStateNotifier, AssetViewerState>(
|
||||||
AssetViewerStateNotifier.new,
|
AssetViewerStateNotifier.new,
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:immich_mobile/domain/models/asset/base_asset.model.dart';
|
import 'package:immich_mobile/domain/models/asset/base_asset.model.dart';
|
||||||
import 'package:immich_mobile/presentation/widgets/images/image_provider.dart';
|
import 'package:immich_mobile/presentation/widgets/images/image_provider.dart';
|
||||||
import 'package:immich_mobile/presentation/widgets/images/thumbnail.widget.dart';
|
import 'package:immich_mobile/widgets/asset_grid/thumbnail_placeholder.dart';
|
||||||
import 'package:octo_image/octo_image.dart';
|
import 'package:octo_image/octo_image.dart';
|
||||||
|
|
||||||
class FullImage extends StatelessWidget {
|
class FullImage extends StatelessWidget {
|
||||||
@@ -9,7 +9,7 @@ class FullImage extends StatelessWidget {
|
|||||||
this.asset, {
|
this.asset, {
|
||||||
required this.size,
|
required this.size,
|
||||||
this.fit = BoxFit.cover,
|
this.fit = BoxFit.cover,
|
||||||
this.placeholder = const Thumbnail(),
|
this.placeholder = const ThumbnailPlaceholder(),
|
||||||
super.key,
|
super.key,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -5,32 +5,19 @@ import 'package:immich_mobile/domain/services/setting.service.dart';
|
|||||||
import 'package:immich_mobile/presentation/widgets/images/local_image_provider.dart';
|
import 'package:immich_mobile/presentation/widgets/images/local_image_provider.dart';
|
||||||
import 'package:immich_mobile/presentation/widgets/images/remote_image_provider.dart';
|
import 'package:immich_mobile/presentation/widgets/images/remote_image_provider.dart';
|
||||||
import 'package:immich_mobile/presentation/widgets/timeline/constants.dart';
|
import 'package:immich_mobile/presentation/widgets/timeline/constants.dart';
|
||||||
import 'package:immich_mobile/infrastructure/repositories/asset_media.repository.dart';
|
|
||||||
|
|
||||||
abstract class CancellableImageProvider {
|
ImageProvider getFullImageProvider(BaseAsset asset, {Size size = const Size(1080, 1920), bool showCached = true}) {
|
||||||
void cancel();
|
|
||||||
}
|
|
||||||
|
|
||||||
mixin class CancellableImageProviderMixin implements CancellableImageProvider {
|
|
||||||
ImageRequest? request;
|
|
||||||
|
|
||||||
@override
|
|
||||||
void cancel() {
|
|
||||||
final request = this.request;
|
|
||||||
if (request == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
this.request = null;
|
|
||||||
return request.cancel();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ImageProvider getFullImageProvider(BaseAsset asset, {Size size = const Size(1080, 1920)}) {
|
|
||||||
// Create new provider and cache it
|
// Create new provider and cache it
|
||||||
final ImageProvider provider;
|
final ImageProvider provider;
|
||||||
if (_shouldUseLocalAsset(asset)) {
|
if (_shouldUseLocalAsset(asset)) {
|
||||||
final id = asset is LocalAsset ? asset.id : (asset as RemoteAsset).localId!;
|
final id = asset is LocalAsset ? asset.id : (asset as RemoteAsset).localId!;
|
||||||
provider = LocalFullImageProvider(id: id, size: size);
|
provider = LocalFullImageProvider(
|
||||||
|
id: id,
|
||||||
|
size: size,
|
||||||
|
type: asset.type,
|
||||||
|
updatedAt: asset.updatedAt,
|
||||||
|
showCached: showCached,
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
final String assetId;
|
final String assetId;
|
||||||
if (asset is LocalAsset && asset.hasRemote) {
|
if (asset is LocalAsset && asset.hasRemote) {
|
||||||
@@ -40,7 +27,7 @@ ImageProvider getFullImageProvider(BaseAsset asset, {Size size = const Size(1080
|
|||||||
} else {
|
} else {
|
||||||
throw ArgumentError("Unsupported asset type: ${asset.runtimeType}");
|
throw ArgumentError("Unsupported asset type: ${asset.runtimeType}");
|
||||||
}
|
}
|
||||||
provider = RemoteFullImageProvider(assetId: assetId);
|
provider = RemoteFullImageProvider(assetId: assetId, showCached: showCached);
|
||||||
}
|
}
|
||||||
|
|
||||||
return provider;
|
return provider;
|
||||||
@@ -55,7 +42,7 @@ ImageProvider getThumbnailImageProvider({BaseAsset? asset, String? remoteId, Siz
|
|||||||
|
|
||||||
if (_shouldUseLocalAsset(asset!)) {
|
if (_shouldUseLocalAsset(asset!)) {
|
||||||
final id = asset is LocalAsset ? asset.id : (asset as RemoteAsset).localId!;
|
final id = asset is LocalAsset ? asset.id : (asset as RemoteAsset).localId!;
|
||||||
return LocalThumbProvider(id: id, size: size);
|
return LocalThumbProvider(id: id, updatedAt: asset.updatedAt, size: size);
|
||||||
}
|
}
|
||||||
|
|
||||||
final String assetId;
|
final String assetId;
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ class LocalAlbumThumbnail extends ConsumerWidget {
|
|||||||
|
|
||||||
return ClipRRect(
|
return ClipRRect(
|
||||||
borderRadius: const BorderRadius.all(Radius.circular(16)),
|
borderRadius: const BorderRadius.all(Radius.circular(16)),
|
||||||
child: Thumbnail.fromBaseAsset(asset: data),
|
child: Thumbnail(asset: data),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
error: (error, stack) {
|
error: (error, stack) {
|
||||||
|
|||||||
@@ -1,18 +1,37 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
import 'dart:io';
|
||||||
import 'dart:ui';
|
import 'dart:ui';
|
||||||
|
|
||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:flutter/widgets.dart';
|
import 'package:flutter/widgets.dart';
|
||||||
|
import 'package:flutter_cache_manager/flutter_cache_manager.dart';
|
||||||
|
import 'package:immich_mobile/domain/models/asset/base_asset.model.dart';
|
||||||
|
import 'package:immich_mobile/domain/models/setting.model.dart';
|
||||||
|
import 'package:immich_mobile/domain/services/setting.service.dart';
|
||||||
|
import 'package:immich_mobile/extensions/codec_extensions.dart';
|
||||||
import 'package:immich_mobile/infrastructure/repositories/asset_media.repository.dart';
|
import 'package:immich_mobile/infrastructure/repositories/asset_media.repository.dart';
|
||||||
|
import 'package:immich_mobile/infrastructure/repositories/storage.repository.dart';
|
||||||
import 'package:immich_mobile/presentation/widgets/images/image_provider.dart';
|
import 'package:immich_mobile/presentation/widgets/images/image_provider.dart';
|
||||||
import 'package:immich_mobile/presentation/widgets/images/one_frame_multi_image_stream_completer.dart';
|
import 'package:immich_mobile/presentation/widgets/images/one_frame_multi_image_stream_completer.dart';
|
||||||
import 'package:immich_mobile/presentation/widgets/timeline/constants.dart';
|
import 'package:immich_mobile/presentation/widgets/timeline/constants.dart';
|
||||||
|
import 'package:immich_mobile/providers/image/cache/thumbnail_image_cache_manager.dart';
|
||||||
|
import 'package:immich_mobile/providers/image/exceptions/image_loading_exception.dart';
|
||||||
|
import 'package:logging/logging.dart';
|
||||||
|
|
||||||
|
class LocalThumbProvider extends ImageProvider<LocalThumbProvider> {
|
||||||
|
final AssetMediaRepository _assetMediaRepository = const AssetMediaRepository();
|
||||||
|
final CacheManager? cacheManager;
|
||||||
|
|
||||||
class LocalThumbProvider extends ImageProvider<LocalThumbProvider> with CancellableImageProviderMixin {
|
|
||||||
final String id;
|
final String id;
|
||||||
|
final DateTime updatedAt;
|
||||||
final Size size;
|
final Size size;
|
||||||
|
|
||||||
LocalThumbProvider({required this.id, this.size = kThumbnailResolution});
|
const LocalThumbProvider({
|
||||||
|
required this.id,
|
||||||
|
required this.updatedAt,
|
||||||
|
this.size = kThumbnailResolution,
|
||||||
|
this.cacheManager,
|
||||||
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<LocalThumbProvider> obtainKey(ImageConfiguration configuration) {
|
Future<LocalThumbProvider> obtainKey(ImageConfiguration configuration) {
|
||||||
@@ -21,45 +40,70 @@ class LocalThumbProvider extends ImageProvider<LocalThumbProvider> with Cancella
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
ImageStreamCompleter loadImage(LocalThumbProvider key, ImageDecoderCallback decode) {
|
ImageStreamCompleter loadImage(LocalThumbProvider key, ImageDecoderCallback decode) {
|
||||||
return OneFramePlaceholderImageStreamCompleter(
|
final cache = cacheManager ?? ThumbnailImageCacheManager();
|
||||||
_codec(key, decode),
|
return MultiFrameImageStreamCompleter(
|
||||||
|
codec: _codec(key, cache, decode),
|
||||||
|
scale: 1.0,
|
||||||
informationCollector: () => <DiagnosticsNode>[
|
informationCollector: () => <DiagnosticsNode>[
|
||||||
DiagnosticsProperty<String>('Id', key.id),
|
DiagnosticsProperty<String>('Id', key.id),
|
||||||
|
DiagnosticsProperty<DateTime>('Updated at', key.updatedAt),
|
||||||
DiagnosticsProperty<Size>('Size', key.size),
|
DiagnosticsProperty<Size>('Size', key.size),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Stream<ImageInfo> _codec(LocalThumbProvider key, ImageDecoderCallback decode) async* {
|
Future<Codec> _codec(LocalThumbProvider key, CacheManager cache, ImageDecoderCallback decode) async {
|
||||||
final request = this.request = LocalImageRequest(localId: key.id, size: size);
|
final cacheKey = '${key.id}-${key.updatedAt}-${key.size.width}x${key.size.height}';
|
||||||
|
|
||||||
|
final fileFromCache = await cache.getFileFromCache(cacheKey);
|
||||||
|
if (fileFromCache != null) {
|
||||||
try {
|
try {
|
||||||
final image = await request.load(decode);
|
final buffer = await ImmutableBuffer.fromFilePath(fileFromCache.file.path);
|
||||||
if (image != null) {
|
return decode(buffer);
|
||||||
yield image;
|
} catch (_) {}
|
||||||
}
|
}
|
||||||
} finally {
|
|
||||||
this.request = null;
|
final thumbnailBytes = await _assetMediaRepository.getThumbnail(key.id, size: key.size);
|
||||||
|
if (thumbnailBytes == null) {
|
||||||
|
PaintingBinding.instance.imageCache.evict(key);
|
||||||
|
throw StateError("Loading thumb for local photo ${key.id} failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final buffer = await ImmutableBuffer.fromUint8List(thumbnailBytes);
|
||||||
|
unawaited(cache.putFile(cacheKey, thumbnailBytes));
|
||||||
|
return decode(buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
bool operator ==(Object other) {
|
bool operator ==(Object other) {
|
||||||
if (identical(this, other)) return true;
|
if (identical(this, other)) return true;
|
||||||
if (other is LocalThumbProvider) {
|
if (other is LocalThumbProvider) {
|
||||||
return id == other.id && size == other.size;
|
return id == other.id && updatedAt == other.updatedAt;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
int get hashCode => id.hashCode ^ size.hashCode;
|
int get hashCode => id.hashCode ^ updatedAt.hashCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
class LocalFullImageProvider extends ImageProvider<LocalFullImageProvider> with CancellableImageProviderMixin {
|
class LocalFullImageProvider extends ImageProvider<LocalFullImageProvider> {
|
||||||
|
final AssetMediaRepository _assetMediaRepository = const AssetMediaRepository();
|
||||||
|
final StorageRepository _storageRepository = const StorageRepository();
|
||||||
|
|
||||||
final String id;
|
final String id;
|
||||||
final Size size;
|
final Size size;
|
||||||
|
final AssetType type;
|
||||||
|
final DateTime updatedAt; // temporary, only exists to fetch cached thumbnail until local disk cache is removed
|
||||||
|
final bool showCached;
|
||||||
|
|
||||||
LocalFullImageProvider({required this.id, required this.size});
|
const LocalFullImageProvider({
|
||||||
|
required this.id,
|
||||||
|
required this.size,
|
||||||
|
required this.type,
|
||||||
|
required this.updatedAt,
|
||||||
|
this.showCached = true,
|
||||||
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<LocalFullImageProvider> obtainKey(ImageConfiguration configuration) {
|
Future<LocalFullImageProvider> obtainKey(ImageConfiguration configuration) {
|
||||||
@@ -70,41 +114,98 @@ class LocalFullImageProvider extends ImageProvider<LocalFullImageProvider> with
|
|||||||
ImageStreamCompleter loadImage(LocalFullImageProvider key, ImageDecoderCallback decode) {
|
ImageStreamCompleter loadImage(LocalFullImageProvider key, ImageDecoderCallback decode) {
|
||||||
return OneFramePlaceholderImageStreamCompleter(
|
return OneFramePlaceholderImageStreamCompleter(
|
||||||
_codec(key, decode),
|
_codec(key, decode),
|
||||||
initialImage: getCachedImage(LocalThumbProvider(id: key.id)),
|
initialImage: showCached ? getCachedImage(LocalThumbProvider(id: key.id, updatedAt: key.updatedAt)) : null,
|
||||||
informationCollector: () => <DiagnosticsNode>[
|
informationCollector: () => <DiagnosticsNode>[
|
||||||
DiagnosticsProperty<ImageProvider>('Image provider', this),
|
|
||||||
DiagnosticsProperty<String>('Id', key.id),
|
DiagnosticsProperty<String>('Id', key.id),
|
||||||
|
DiagnosticsProperty<DateTime>('Updated at', key.updatedAt),
|
||||||
DiagnosticsProperty<Size>('Size', key.size),
|
DiagnosticsProperty<Size>('Size', key.size),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Stream<ImageInfo> _codec(LocalFullImageProvider key, ImageDecoderCallback decode) async* {
|
// Streams in each stage of the image as we ask for it
|
||||||
final devicePixelRatio = PlatformDispatcher.instance.views.first.devicePixelRatio;
|
Stream<ImageInfo> _codec(LocalFullImageProvider key, ImageDecoderCallback decode) {
|
||||||
final request = this.request = LocalImageRequest(
|
|
||||||
localId: key.id,
|
|
||||||
size: Size(size.width * devicePixelRatio, size.height * devicePixelRatio),
|
|
||||||
);
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
final image = await request.load(decode);
|
return switch (key.type) {
|
||||||
if (image != null) {
|
AssetType.image => _decodeProgressive(key, decode),
|
||||||
yield image;
|
AssetType.video => _getThumbnailCodec(key, decode),
|
||||||
|
_ => throw StateError('Unsupported asset type ${key.type}'),
|
||||||
|
};
|
||||||
|
} catch (error, stack) {
|
||||||
|
Logger('ImmichLocalImageProvider').severe('Error loading local image ${key.id}', error, stack);
|
||||||
|
throw const ImageLoadingException('Could not load image from local storage');
|
||||||
}
|
}
|
||||||
} finally {
|
|
||||||
this.request = null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Stream<ImageInfo> _getThumbnailCodec(LocalFullImageProvider key, ImageDecoderCallback decode) async* {
|
||||||
|
final thumbBytes = await _assetMediaRepository.getThumbnail(key.id, size: key.size);
|
||||||
|
if (thumbBytes == null) {
|
||||||
|
throw StateError("Failed to load preview for ${key.id}");
|
||||||
|
}
|
||||||
|
final buffer = await ImmutableBuffer.fromUint8List(thumbBytes);
|
||||||
|
final codec = await decode(buffer);
|
||||||
|
yield await codec.getImageInfo();
|
||||||
|
}
|
||||||
|
|
||||||
|
Stream<ImageInfo> _decodeProgressive(LocalFullImageProvider key, ImageDecoderCallback decode) async* {
|
||||||
|
final file = await _storageRepository.getFileForAsset(key.id);
|
||||||
|
if (file == null) {
|
||||||
|
throw StateError("Opening file for asset ${key.id} failed");
|
||||||
|
}
|
||||||
|
|
||||||
|
final fileSize = await file.length();
|
||||||
|
final devicePixelRatio = PlatformDispatcher.instance.views.first.devicePixelRatio;
|
||||||
|
final isLargeFile = fileSize > 20 * 1024 * 1024; // 20MB
|
||||||
|
final isHEIC = file.path.toLowerCase().contains(RegExp(r'\.(heic|heif)$'));
|
||||||
|
final isProgressive = isLargeFile || (isHEIC && !Platform.isIOS);
|
||||||
|
|
||||||
|
if (isProgressive) {
|
||||||
|
try {
|
||||||
|
final progressiveMultiplier = devicePixelRatio >= 3.0 ? 1.3 : 1.2;
|
||||||
|
final size = Size(
|
||||||
|
(key.size.width * progressiveMultiplier).clamp(256, 1024),
|
||||||
|
(key.size.height * progressiveMultiplier).clamp(256, 1024),
|
||||||
|
);
|
||||||
|
final mediumThumb = await _assetMediaRepository.getThumbnail(key.id, size: size);
|
||||||
|
if (mediumThumb != null) {
|
||||||
|
final mediumBuffer = await ImmutableBuffer.fromUint8List(mediumThumb);
|
||||||
|
final codec = await decode(mediumBuffer);
|
||||||
|
yield await codec.getImageInfo();
|
||||||
|
}
|
||||||
|
} catch (_) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Load original only when the file is smaller or if the user wants to load original images
|
||||||
|
// Or load a slightly larger image for progressive loading
|
||||||
|
if (isProgressive && !(AppSetting.get(Setting.loadOriginal))) {
|
||||||
|
final progressiveMultiplier = devicePixelRatio >= 3.0 ? 2.0 : 1.6;
|
||||||
|
final size = Size(
|
||||||
|
(key.size.width * progressiveMultiplier).clamp(512, 2048),
|
||||||
|
(key.size.height * progressiveMultiplier).clamp(512, 2048),
|
||||||
|
);
|
||||||
|
final highThumb = await _assetMediaRepository.getThumbnail(key.id, size: size);
|
||||||
|
if (highThumb != null) {
|
||||||
|
final highBuffer = await ImmutableBuffer.fromUint8List(highThumb);
|
||||||
|
final codec = await decode(highBuffer);
|
||||||
|
yield await codec.getImageInfo();
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
final buffer = await ImmutableBuffer.fromFilePath(file.path);
|
||||||
|
final codec = await decode(buffer);
|
||||||
|
yield await codec.getImageInfo();
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
bool operator ==(Object other) {
|
bool operator ==(Object other) {
|
||||||
if (identical(this, other)) return true;
|
if (identical(this, other)) return true;
|
||||||
if (other is LocalFullImageProvider) {
|
if (other is LocalFullImageProvider) {
|
||||||
return id == other.id && size == other.size;
|
return id == other.id && size == other.size && type == other.type;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
int get hashCode => id.hashCode ^ size.hashCode;
|
int get hashCode => id.hashCode ^ size.hashCode ^ type.hashCode;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,21 +1,23 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
import 'dart:ui';
|
||||||
|
|
||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:flutter/painting.dart';
|
import 'package:flutter/painting.dart';
|
||||||
import 'package:flutter_cache_manager/flutter_cache_manager.dart';
|
import 'package:flutter_cache_manager/flutter_cache_manager.dart';
|
||||||
import 'package:immich_mobile/domain/models/setting.model.dart';
|
import 'package:immich_mobile/domain/models/setting.model.dart';
|
||||||
import 'package:immich_mobile/domain/services/setting.service.dart';
|
import 'package:immich_mobile/domain/services/setting.service.dart';
|
||||||
import 'package:immich_mobile/infrastructure/repositories/asset_media.repository.dart';
|
import 'package:immich_mobile/extensions/codec_extensions.dart';
|
||||||
import 'package:immich_mobile/presentation/widgets/images/image_provider.dart';
|
import 'package:immich_mobile/presentation/widgets/images/image_provider.dart';
|
||||||
import 'package:immich_mobile/presentation/widgets/images/one_frame_multi_image_stream_completer.dart';
|
import 'package:immich_mobile/presentation/widgets/images/one_frame_multi_image_stream_completer.dart';
|
||||||
import 'package:immich_mobile/services/api.service.dart';
|
import 'package:immich_mobile/providers/image/cache/image_loader.dart';
|
||||||
|
import 'package:immich_mobile/providers/image/cache/remote_image_cache_manager.dart';
|
||||||
import 'package:immich_mobile/utils/image_url_builder.dart';
|
import 'package:immich_mobile/utils/image_url_builder.dart';
|
||||||
|
|
||||||
class RemoteThumbProvider extends ImageProvider<RemoteThumbProvider> with CancellableImageProviderMixin {
|
class RemoteThumbProvider extends ImageProvider<RemoteThumbProvider> {
|
||||||
final String assetId;
|
final String assetId;
|
||||||
final CacheManager? cacheManager;
|
final CacheManager? cacheManager;
|
||||||
|
|
||||||
RemoteThumbProvider({required this.assetId, this.cacheManager});
|
const RemoteThumbProvider({required this.assetId, this.cacheManager});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<RemoteThumbProvider> obtainKey(ImageConfiguration configuration) {
|
Future<RemoteThumbProvider> obtainKey(ImageConfiguration configuration) {
|
||||||
@@ -24,8 +26,12 @@ class RemoteThumbProvider extends ImageProvider<RemoteThumbProvider> with Cancel
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
ImageStreamCompleter loadImage(RemoteThumbProvider key, ImageDecoderCallback decode) {
|
ImageStreamCompleter loadImage(RemoteThumbProvider key, ImageDecoderCallback decode) {
|
||||||
return OneFramePlaceholderImageStreamCompleter(
|
final cache = cacheManager ?? RemoteImageCacheManager();
|
||||||
_codec(key, decode),
|
final chunkController = StreamController<ImageChunkEvent>();
|
||||||
|
return MultiFrameImageStreamCompleter(
|
||||||
|
codec: _codec(key, cache, decode, chunkController),
|
||||||
|
scale: 1.0,
|
||||||
|
chunkEvents: chunkController.stream,
|
||||||
informationCollector: () => <DiagnosticsNode>[
|
informationCollector: () => <DiagnosticsNode>[
|
||||||
DiagnosticsProperty<ImageProvider>('Image provider', this),
|
DiagnosticsProperty<ImageProvider>('Image provider', this),
|
||||||
DiagnosticsProperty<String>('Asset Id', key.assetId),
|
DiagnosticsProperty<String>('Asset Id', key.assetId),
|
||||||
@@ -33,17 +39,20 @@ class RemoteThumbProvider extends ImageProvider<RemoteThumbProvider> with Cancel
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Stream<ImageInfo> _codec(RemoteThumbProvider key, ImageDecoderCallback decode) async* {
|
Future<Codec> _codec(
|
||||||
|
RemoteThumbProvider key,
|
||||||
|
CacheManager cache,
|
||||||
|
ImageDecoderCallback decode,
|
||||||
|
StreamController<ImageChunkEvent> chunkController,
|
||||||
|
) async {
|
||||||
final preview = getThumbnailUrlForRemoteId(key.assetId);
|
final preview = getThumbnailUrlForRemoteId(key.assetId);
|
||||||
final request = this.request = RemoteImageRequest(uri: preview, headers: ApiService.getRequestHeaders());
|
|
||||||
try {
|
return ImageLoader.loadImageFromCache(
|
||||||
final image = await request.load(decode);
|
preview,
|
||||||
if (image != null) {
|
cache: cache,
|
||||||
yield image;
|
decode: decode,
|
||||||
}
|
chunkEvents: chunkController,
|
||||||
} finally {
|
).whenComplete(chunkController.close);
|
||||||
this.request = null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -60,11 +69,12 @@ class RemoteThumbProvider extends ImageProvider<RemoteThumbProvider> with Cancel
|
|||||||
int get hashCode => assetId.hashCode;
|
int get hashCode => assetId.hashCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
class RemoteFullImageProvider extends ImageProvider<RemoteFullImageProvider> with CancellableImageProviderMixin {
|
class RemoteFullImageProvider extends ImageProvider<RemoteFullImageProvider> {
|
||||||
final String assetId;
|
final String assetId;
|
||||||
|
final bool showCached;
|
||||||
final CacheManager? cacheManager;
|
final CacheManager? cacheManager;
|
||||||
|
|
||||||
RemoteFullImageProvider({required this.assetId, this.cacheManager});
|
const RemoteFullImageProvider({required this.assetId, this.cacheManager, this.showCached = true});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<RemoteFullImageProvider> obtainKey(ImageConfiguration configuration) {
|
Future<RemoteFullImageProvider> obtainKey(ImageConfiguration configuration) {
|
||||||
@@ -73,44 +83,28 @@ class RemoteFullImageProvider extends ImageProvider<RemoteFullImageProvider> wit
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
ImageStreamCompleter loadImage(RemoteFullImageProvider key, ImageDecoderCallback decode) {
|
ImageStreamCompleter loadImage(RemoteFullImageProvider key, ImageDecoderCallback decode) {
|
||||||
|
final cache = cacheManager ?? RemoteImageCacheManager();
|
||||||
return OneFramePlaceholderImageStreamCompleter(
|
return OneFramePlaceholderImageStreamCompleter(
|
||||||
_codec(key, decode),
|
_codec(key, cache, decode),
|
||||||
initialImage: getCachedImage(RemoteThumbProvider(assetId: assetId)),
|
initialImage: showCached ? getCachedImage(RemoteThumbProvider(assetId: key.assetId)) : null,
|
||||||
informationCollector: () => <DiagnosticsNode>[
|
|
||||||
DiagnosticsProperty<ImageProvider>('Image provider', this),
|
|
||||||
DiagnosticsProperty<String>('Asset Id', key.assetId),
|
|
||||||
],
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Stream<ImageInfo> _codec(RemoteFullImageProvider key, ImageDecoderCallback decode) async* {
|
Stream<ImageInfo> _codec(RemoteFullImageProvider key, CacheManager cache, ImageDecoderCallback decode) async* {
|
||||||
try {
|
final codec = await ImageLoader.loadImageFromCache(
|
||||||
final request = this.request = RemoteImageRequest(
|
getPreviewUrlForRemoteId(key.assetId),
|
||||||
uri: getPreviewUrlForRemoteId(key.assetId),
|
cache: cache,
|
||||||
headers: ApiService.getRequestHeaders(),
|
decode: decode,
|
||||||
);
|
);
|
||||||
final image = await request.load(decode);
|
yield await codec.getImageInfo();
|
||||||
if (image == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
yield image;
|
|
||||||
} finally {
|
|
||||||
request = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (AppSetting.get(Setting.loadOriginal)) {
|
if (AppSetting.get(Setting.loadOriginal)) {
|
||||||
try {
|
final codec = await ImageLoader.loadImageFromCache(
|
||||||
final request = this.request = RemoteImageRequest(
|
getOriginalUrlForRemoteId(key.assetId),
|
||||||
uri: getOriginalUrlForRemoteId(key.assetId),
|
cache: cache,
|
||||||
headers: ApiService.getRequestHeaders(),
|
decode: decode,
|
||||||
);
|
);
|
||||||
final image = await request.load(decode);
|
yield await codec.getImageInfo();
|
||||||
if (image != null) {
|
|
||||||
yield image;
|
|
||||||
}
|
|
||||||
} finally {
|
|
||||||
request = null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,39 @@
|
|||||||
|
import 'dart:convert' hide Codec;
|
||||||
|
import 'dart:ui';
|
||||||
|
|
||||||
|
import 'package:flutter/foundation.dart';
|
||||||
|
import 'package:flutter/rendering.dart';
|
||||||
|
import 'package:thumbhash/thumbhash.dart';
|
||||||
|
|
||||||
|
class ThumbHashProvider extends ImageProvider<ThumbHashProvider> {
|
||||||
|
final String thumbHash;
|
||||||
|
|
||||||
|
const ThumbHashProvider({required this.thumbHash});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<ThumbHashProvider> obtainKey(ImageConfiguration configuration) {
|
||||||
|
return SynchronousFuture(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
ImageStreamCompleter loadImage(ThumbHashProvider key, ImageDecoderCallback decode) {
|
||||||
|
return MultiFrameImageStreamCompleter(codec: _loadCodec(key, decode), scale: 1.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<Codec> _loadCodec(ThumbHashProvider key, ImageDecoderCallback decode) async {
|
||||||
|
final image = thumbHashToRGBA(base64Decode(key.thumbHash));
|
||||||
|
return decode(await ImmutableBuffer.fromUint8List(rgbaToBmp(image)));
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool operator ==(Object other) {
|
||||||
|
if (identical(this, other)) return true;
|
||||||
|
if (other is ThumbHashProvider) {
|
||||||
|
return thumbHash == other.thumbHash;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
int get hashCode => thumbHash.hashCode;
|
||||||
|
}
|
||||||
@@ -1,372 +1,61 @@
|
|||||||
import 'dart:async';
|
|
||||||
import 'dart:convert';
|
|
||||||
import 'dart:ui' as ui;
|
|
||||||
import 'dart:ui';
|
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/scheduler.dart';
|
|
||||||
import 'package:immich_mobile/domain/models/asset/base_asset.model.dart';
|
import 'package:immich_mobile/domain/models/asset/base_asset.model.dart';
|
||||||
import 'package:immich_mobile/entities/asset.entity.dart';
|
|
||||||
import 'package:immich_mobile/extensions/build_context_extensions.dart';
|
|
||||||
import 'package:immich_mobile/extensions/theme_extensions.dart';
|
|
||||||
import 'package:immich_mobile/presentation/widgets/images/image_provider.dart';
|
import 'package:immich_mobile/presentation/widgets/images/image_provider.dart';
|
||||||
import 'package:immich_mobile/presentation/widgets/images/local_image_provider.dart';
|
import 'package:immich_mobile/presentation/widgets/images/thumb_hash_provider.dart';
|
||||||
import 'package:immich_mobile/presentation/widgets/images/remote_image_provider.dart';
|
import 'package:immich_mobile/widgets/asset_grid/thumbnail_placeholder.dart';
|
||||||
import 'package:immich_mobile/presentation/widgets/timeline/constants.dart';
|
import 'package:immich_mobile/widgets/common/fade_in_placeholder_image.dart';
|
||||||
import 'package:logging/logging.dart';
|
import 'package:logging/logging.dart';
|
||||||
import 'package:thumbhash/thumbhash.dart' as thumbhash;
|
import 'package:octo_image/octo_image.dart';
|
||||||
|
|
||||||
final log = Logger('ThumbnailWidget');
|
class Thumbnail extends StatelessWidget {
|
||||||
|
const Thumbnail({this.asset, this.remoteId, this.size = const Size.square(256), this.fit = BoxFit.cover, super.key})
|
||||||
|
: assert(asset != null || remoteId != null, 'Either asset or remoteId must be provided');
|
||||||
|
|
||||||
enum ThumbhashMode { enabled, disabled, only }
|
final BaseAsset? asset;
|
||||||
|
final String? remoteId;
|
||||||
class Thumbnail extends StatefulWidget {
|
final Size size;
|
||||||
final ImageProvider? imageProvider;
|
|
||||||
final BoxFit fit;
|
final BoxFit fit;
|
||||||
final ui.Size size;
|
|
||||||
final String? blurhash;
|
|
||||||
final ThumbhashMode thumbhashMode;
|
|
||||||
|
|
||||||
const Thumbnail({
|
|
||||||
this.imageProvider,
|
|
||||||
this.fit = BoxFit.cover,
|
|
||||||
this.size = kThumbnailResolution,
|
|
||||||
this.blurhash,
|
|
||||||
this.thumbhashMode = ThumbhashMode.enabled,
|
|
||||||
super.key,
|
|
||||||
});
|
|
||||||
|
|
||||||
Thumbnail.fromAsset({
|
|
||||||
required Asset asset,
|
|
||||||
this.fit = BoxFit.cover,
|
|
||||||
this.size = kThumbnailResolution,
|
|
||||||
this.thumbhashMode = ThumbhashMode.enabled,
|
|
||||||
super.key,
|
|
||||||
}) : blurhash = asset.thumbhash,
|
|
||||||
imageProvider = _getImageProviderFromAsset(asset, size);
|
|
||||||
|
|
||||||
Thumbnail.fromBaseAsset({
|
|
||||||
required BaseAsset? asset,
|
|
||||||
this.fit = BoxFit.cover,
|
|
||||||
this.size = kThumbnailResolution,
|
|
||||||
this.thumbhashMode = ThumbhashMode.enabled,
|
|
||||||
super.key,
|
|
||||||
}) : blurhash = switch (asset) {
|
|
||||||
RemoteAsset() => asset.thumbHash,
|
|
||||||
_ => null,
|
|
||||||
},
|
|
||||||
imageProvider = _getImageProviderFromBaseAsset(asset, size);
|
|
||||||
|
|
||||||
static ImageProvider? _getImageProviderFromAsset(Asset asset, ui.Size size) {
|
|
||||||
if (asset.localId != null) {
|
|
||||||
return LocalThumbProvider(id: asset.localId!, size: size);
|
|
||||||
} else if (asset.remoteId != null) {
|
|
||||||
return RemoteThumbProvider(assetId: asset.remoteId!);
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
static ImageProvider? _getImageProviderFromBaseAsset(BaseAsset? asset, ui.Size size) {
|
|
||||||
switch (asset) {
|
|
||||||
case RemoteAsset():
|
|
||||||
if (asset.localId != null) {
|
|
||||||
return LocalThumbProvider(id: asset.localId!, size: size);
|
|
||||||
} else {
|
|
||||||
return RemoteThumbProvider(assetId: asset.id);
|
|
||||||
}
|
|
||||||
case LocalAsset():
|
|
||||||
return LocalThumbProvider(id: asset.id, size: size);
|
|
||||||
case null:
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
State<Thumbnail> createState() => _ThumbnailState();
|
|
||||||
}
|
|
||||||
|
|
||||||
class _ThumbnailState extends State<Thumbnail> {
|
|
||||||
ui.Image? _providerImage;
|
|
||||||
ImageStream? _imageStream;
|
|
||||||
ImageStreamListener? _imageStreamListener;
|
|
||||||
|
|
||||||
static final _gradientCache = <ColorScheme, Gradient>{};
|
|
||||||
|
|
||||||
@override
|
|
||||||
void initState() {
|
|
||||||
super.initState();
|
|
||||||
_loadImage();
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
void didUpdateWidget(Thumbnail oldWidget) {
|
|
||||||
super.didUpdateWidget(oldWidget);
|
|
||||||
if (widget.imageProvider != oldWidget.imageProvider) {
|
|
||||||
return _loadImage();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_providerImage != null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((oldWidget.thumbhashMode == ThumbhashMode.disabled && widget.thumbhashMode != ThumbhashMode.disabled) ||
|
|
||||||
(oldWidget.thumbhashMode == ThumbhashMode.only && widget.thumbhashMode != ThumbhashMode.only) ||
|
|
||||||
(widget.thumbhashMode != ThumbhashMode.disabled && oldWidget.blurhash != widget.blurhash)) {
|
|
||||||
_loadImage();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
void reassemble() {
|
|
||||||
super.reassemble();
|
|
||||||
_loadImage();
|
|
||||||
}
|
|
||||||
|
|
||||||
void _loadImage() {
|
|
||||||
_stopListeningToStream();
|
|
||||||
if (widget.thumbhashMode != ThumbhashMode.only && widget.imageProvider != null) {
|
|
||||||
_loadFromProvider();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (widget.thumbhashMode != ThumbhashMode.disabled && widget.blurhash != null) {
|
|
||||||
_decodeThumbhash();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void _loadFromProvider() {
|
|
||||||
final imageProvider = widget.imageProvider;
|
|
||||||
if (imageProvider == null) return;
|
|
||||||
|
|
||||||
_imageStream = imageProvider.resolve(ImageConfiguration.empty);
|
|
||||||
_imageStreamListener = ImageStreamListener(
|
|
||||||
(ImageInfo imageInfo, bool synchronousCall) {
|
|
||||||
if (!mounted) return;
|
|
||||||
|
|
||||||
if (_providerImage != imageInfo.image) {
|
|
||||||
setState(() {
|
|
||||||
_providerImage = imageInfo.image;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
},
|
|
||||||
onError: (exception, stackTrace) {
|
|
||||||
log.severe('Error loading image: $exception', exception, stackTrace);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
_imageStream?.addListener(_imageStreamListener!);
|
|
||||||
}
|
|
||||||
|
|
||||||
void _stopListeningToStream() {
|
|
||||||
if (_imageStreamListener != null && _imageStream != null) {
|
|
||||||
_imageStream!.removeListener(_imageStreamListener!);
|
|
||||||
}
|
|
||||||
_imageStream = null;
|
|
||||||
_imageStreamListener = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> _decodeThumbhash() async {
|
|
||||||
final blurhash = widget.blurhash;
|
|
||||||
if (blurhash == null || !mounted || _providerImage != null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
final image = thumbhash.thumbHashToRGBA(base64.decode(blurhash));
|
|
||||||
final buffer = await ImmutableBuffer.fromUint8List(image.rgba);
|
|
||||||
if (!mounted || _providerImage != null) {
|
|
||||||
buffer.dispose();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
final descriptor = ImageDescriptor.raw(
|
|
||||||
buffer,
|
|
||||||
width: image.width,
|
|
||||||
height: image.height,
|
|
||||||
pixelFormat: PixelFormat.rgba8888,
|
|
||||||
);
|
|
||||||
|
|
||||||
final codec = await descriptor.instantiateCodec();
|
|
||||||
|
|
||||||
if (!mounted || _providerImage != null) {
|
|
||||||
buffer.dispose();
|
|
||||||
descriptor.dispose();
|
|
||||||
codec.dispose();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
final frame = (await codec.getNextFrame()).image;
|
|
||||||
buffer.dispose();
|
|
||||||
descriptor.dispose();
|
|
||||||
codec.dispose();
|
|
||||||
|
|
||||||
if (!mounted || _providerImage != null) {
|
|
||||||
frame.dispose();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
setState(() {
|
|
||||||
_providerImage = frame;
|
|
||||||
});
|
|
||||||
} catch (e) {
|
|
||||||
log.severe('Error decoding thumbhash: $e');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final colorScheme = context.colorScheme;
|
final thumbHash = asset is RemoteAsset ? (asset as RemoteAsset).thumbHash : null;
|
||||||
final gradient = _gradientCache[colorScheme] ??= LinearGradient(
|
final provider = getThumbnailImageProvider(asset: asset, remoteId: remoteId);
|
||||||
colors: [colorScheme.surfaceContainer, colorScheme.surfaceContainer.darken(amount: .1)],
|
|
||||||
begin: Alignment.topCenter,
|
|
||||||
end: Alignment.bottomCenter,
|
|
||||||
);
|
|
||||||
|
|
||||||
return _ThumbnailLeaf(image: _providerImage, fit: widget.fit, placeholderGradient: gradient);
|
return OctoImage.fromSet(
|
||||||
}
|
image: provider,
|
||||||
|
octoSet: OctoSet(
|
||||||
@override
|
placeholderBuilder: _blurHashPlaceholderBuilder(thumbHash, fit: fit),
|
||||||
void dispose() {
|
errorBuilder: _blurHashErrorBuilder(thumbHash, provider: provider, fit: fit, asset: asset),
|
||||||
_stopListeningToStream();
|
),
|
||||||
_providerImage?.dispose();
|
fadeOutDuration: const Duration(milliseconds: 100),
|
||||||
final imageProvider = widget.imageProvider;
|
fadeInDuration: Duration.zero,
|
||||||
if (imageProvider is CancellableImageProvider) {
|
width: size.width,
|
||||||
(imageProvider as CancellableImageProvider).cancel();
|
height: size.height,
|
||||||
}
|
fit: fit,
|
||||||
super.dispose();
|
placeholderFadeInDuration: Duration.zero,
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class _ThumbnailLeaf extends LeafRenderObjectWidget {
|
|
||||||
final ui.Image? image;
|
|
||||||
final BoxFit fit;
|
|
||||||
final Gradient placeholderGradient;
|
|
||||||
|
|
||||||
const _ThumbnailLeaf({required this.image, required this.fit, required this.placeholderGradient});
|
|
||||||
|
|
||||||
@override
|
|
||||||
RenderObject createRenderObject(BuildContext context) {
|
|
||||||
return _ThumbnailRenderBox(image: image, fit: fit, placeholderGradient: placeholderGradient);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
void updateRenderObject(BuildContext context, _ThumbnailRenderBox renderObject) {
|
|
||||||
renderObject.fit = fit;
|
|
||||||
renderObject.image = image;
|
|
||||||
renderObject.placeholderGradient = placeholderGradient;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class _ThumbnailRenderBox extends RenderBox {
|
|
||||||
ui.Image? _image;
|
|
||||||
ui.Image? _previousImage;
|
|
||||||
BoxFit _fit;
|
|
||||||
Gradient _placeholderGradient;
|
|
||||||
DateTime _lastImageRequest;
|
|
||||||
|
|
||||||
double _crossFadeProgress = 1.0;
|
|
||||||
static const _fadeDuration = Duration(milliseconds: 100);
|
|
||||||
DateTime? _fadeStartTime;
|
|
||||||
|
|
||||||
@override
|
|
||||||
bool isRepaintBoundary = true;
|
|
||||||
|
|
||||||
_ThumbnailRenderBox({required ui.Image? image, required BoxFit fit, required Gradient placeholderGradient})
|
|
||||||
: _image = image,
|
|
||||||
_fit = fit,
|
|
||||||
_placeholderGradient = placeholderGradient,
|
|
||||||
_lastImageRequest = DateTime.now();
|
|
||||||
|
|
||||||
@override
|
|
||||||
void paint(PaintingContext context, Offset offset) {
|
|
||||||
final rect = offset & size;
|
|
||||||
final canvas = context.canvas;
|
|
||||||
|
|
||||||
if (_fadeStartTime != null) {
|
|
||||||
final elapsed = DateTime.now().difference(_fadeStartTime!);
|
|
||||||
_crossFadeProgress = (elapsed.inMilliseconds / _fadeDuration.inMilliseconds).clamp(0.0, 1.0);
|
|
||||||
|
|
||||||
if (_crossFadeProgress < 1.0) {
|
|
||||||
SchedulerBinding.instance.scheduleFrameCallback((_) {
|
|
||||||
markNeedsPaint();
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
_previousImage?.dispose();
|
|
||||||
_previousImage = null;
|
|
||||||
_fadeStartTime = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_previousImage != null && _crossFadeProgress < 1.0) {
|
|
||||||
paintImage(
|
|
||||||
canvas: canvas,
|
|
||||||
rect: rect,
|
|
||||||
image: _previousImage!,
|
|
||||||
fit: _fit,
|
|
||||||
filterQuality: FilterQuality.low,
|
|
||||||
opacity: 1.0 - _crossFadeProgress,
|
|
||||||
);
|
|
||||||
} else if (_image == null) {
|
|
||||||
final paint = Paint();
|
|
||||||
paint.shader = _placeholderGradient.createShader(rect);
|
|
||||||
canvas.drawRect(rect, paint);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_image != null) {
|
|
||||||
paintImage(
|
|
||||||
canvas: canvas,
|
|
||||||
rect: rect,
|
|
||||||
image: _image!,
|
|
||||||
fit: _fit,
|
|
||||||
filterQuality: FilterQuality.low,
|
|
||||||
opacity: _crossFadeProgress,
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
OctoPlaceholderBuilder _blurHashPlaceholderBuilder(String? thumbHash, {BoxFit? fit}) {
|
||||||
void performLayout() {
|
return (context) => thumbHash == null
|
||||||
size = constraints.biggest;
|
? const ThumbnailPlaceholder()
|
||||||
|
: FadeInPlaceholderImage(
|
||||||
|
placeholder: const ThumbnailPlaceholder(),
|
||||||
|
image: ThumbHashProvider(thumbHash: thumbHash),
|
||||||
|
fit: fit ?? BoxFit.cover,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
set image(ui.Image? value) {
|
OctoErrorBuilder _blurHashErrorBuilder(String? blurhash, {BaseAsset? asset, ImageProvider? provider, BoxFit? fit}) =>
|
||||||
if (_image == value) {
|
(context, e, s) {
|
||||||
return;
|
Logger("ImThumbnail").warning("Error loading thumbnail for ${asset?.name}", e, s);
|
||||||
}
|
provider?.evict();
|
||||||
|
return Stack(
|
||||||
final time = DateTime.now();
|
alignment: Alignment.center,
|
||||||
if (time.difference(_lastImageRequest).inMilliseconds >= 16) {
|
children: [
|
||||||
_fadeStartTime = time;
|
_blurHashPlaceholderBuilder(blurhash, fit: fit)(context),
|
||||||
_previousImage = _image;
|
const Opacity(opacity: 0.75, child: Icon(Icons.error_outline_rounded)),
|
||||||
}
|
],
|
||||||
_image = value;
|
);
|
||||||
_lastImageRequest = time;
|
};
|
||||||
markNeedsPaint();
|
|
||||||
}
|
|
||||||
|
|
||||||
set fit(BoxFit value) {
|
|
||||||
if (_fit == value) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
_fit = value;
|
|
||||||
if (_image != null) {
|
|
||||||
markNeedsPaint();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
set placeholderGradient(Gradient value) {
|
|
||||||
if (_placeholderGradient == value) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
_placeholderGradient = value;
|
|
||||||
if (_image == null) {
|
|
||||||
markNeedsPaint();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
dispose() {
|
|
||||||
_previousImage?.dispose();
|
|
||||||
super.dispose();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -7,15 +7,13 @@ import 'package:immich_mobile/extensions/build_context_extensions.dart';
|
|||||||
import 'package:immich_mobile/extensions/duration_extensions.dart';
|
import 'package:immich_mobile/extensions/duration_extensions.dart';
|
||||||
import 'package:immich_mobile/extensions/theme_extensions.dart';
|
import 'package:immich_mobile/extensions/theme_extensions.dart';
|
||||||
import 'package:immich_mobile/presentation/widgets/images/thumbnail.widget.dart';
|
import 'package:immich_mobile/presentation/widgets/images/thumbnail.widget.dart';
|
||||||
import 'package:immich_mobile/presentation/widgets/timeline/constants.dart';
|
|
||||||
import 'package:immich_mobile/providers/infrastructure/setting.provider.dart';
|
import 'package:immich_mobile/providers/infrastructure/setting.provider.dart';
|
||||||
import 'package:immich_mobile/presentation/widgets/timeline/timeline.state.dart';
|
|
||||||
import 'package:immich_mobile/providers/timeline/multiselect.provider.dart';
|
import 'package:immich_mobile/providers/timeline/multiselect.provider.dart';
|
||||||
|
|
||||||
class ThumbnailTile extends ConsumerWidget {
|
class ThumbnailTile extends ConsumerWidget {
|
||||||
const ThumbnailTile(
|
const ThumbnailTile(
|
||||||
this.asset, {
|
this.asset, {
|
||||||
this.size = kTimelineFixedTileExtent,
|
this.size = const Size.square(256),
|
||||||
this.fit = BoxFit.cover,
|
this.fit = BoxFit.cover,
|
||||||
this.showStorageIndicator,
|
this.showStorageIndicator,
|
||||||
this.lockSelection = false,
|
this.lockSelection = false,
|
||||||
@@ -23,7 +21,7 @@ class ThumbnailTile extends ConsumerWidget {
|
|||||||
super.key,
|
super.key,
|
||||||
});
|
});
|
||||||
|
|
||||||
final BaseAsset? asset;
|
final BaseAsset asset;
|
||||||
final Size size;
|
final Size size;
|
||||||
final BoxFit fit;
|
final BoxFit fit;
|
||||||
final bool? showStorageIndicator;
|
final bool? showStorageIndicator;
|
||||||
@@ -32,7 +30,6 @@ class ThumbnailTile extends ConsumerWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context, WidgetRef ref) {
|
Widget build(BuildContext context, WidgetRef ref) {
|
||||||
final asset = this.asset;
|
|
||||||
final heroIndex = heroOffset ?? TabsRouterScope.of(context)?.controller.activeIndex ?? 0;
|
final heroIndex = heroOffset ?? TabsRouterScope.of(context)?.controller.activeIndex ?? 0;
|
||||||
|
|
||||||
final assetContainerColor = context.isDarkTheme
|
final assetContainerColor = context.isDarkTheme
|
||||||
@@ -42,7 +39,6 @@ class ThumbnailTile extends ConsumerWidget {
|
|||||||
final isSelected = ref.watch(
|
final isSelected = ref.watch(
|
||||||
multiSelectProvider.select((multiselect) => multiselect.selectedAssets.contains(asset)),
|
multiSelectProvider.select((multiselect) => multiselect.selectedAssets.contains(asset)),
|
||||||
);
|
);
|
||||||
final isScrubbing = ref.watch(timelineStateProvider.select((state) => state.isScrubbing));
|
|
||||||
|
|
||||||
final borderStyle = lockSelection
|
final borderStyle = lockSelection
|
||||||
? BoxDecoration(
|
? BoxDecoration(
|
||||||
@@ -56,6 +52,8 @@ class ThumbnailTile extends ConsumerWidget {
|
|||||||
)
|
)
|
||||||
: const BoxDecoration();
|
: const BoxDecoration();
|
||||||
|
|
||||||
|
final hasStack = asset is RemoteAsset && (asset as RemoteAsset).stackId != null;
|
||||||
|
|
||||||
final bool storageIndicator =
|
final bool storageIndicator =
|
||||||
showStorageIndicator ?? ref.watch(settingsProvider.select((s) => s.get(Setting.showStorageIndicator)));
|
showStorageIndicator ?? ref.watch(settingsProvider.select((s) => s.get(Setting.showStorageIndicator)));
|
||||||
|
|
||||||
@@ -73,34 +71,19 @@ class ThumbnailTile extends ConsumerWidget {
|
|||||||
children: [
|
children: [
|
||||||
Positioned.fill(
|
Positioned.fill(
|
||||||
child: Hero(
|
child: Hero(
|
||||||
tag: '${asset?.heroTag ?? ''}_$heroIndex',
|
tag: '${asset.heroTag}_$heroIndex',
|
||||||
child: Thumbnail.fromBaseAsset(
|
child: Thumbnail(asset: asset, fit: fit, size: size),
|
||||||
asset: asset,
|
|
||||||
thumbhashMode: isScrubbing
|
|
||||||
? ThumbhashMode.only
|
|
||||||
: asset != null && asset.hasLocal
|
|
||||||
? ThumbhashMode.disabled
|
|
||||||
: ThumbhashMode.enabled,
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
if (hasStack)
|
||||||
if (asset is RemoteAsset && asset.stackId != null)
|
Align(
|
||||||
asset.isVideo
|
|
||||||
? const Align(
|
|
||||||
alignment: Alignment.topRight,
|
alignment: Alignment.topRight,
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: EdgeInsets.only(right: 10.0, top: 24.0),
|
padding: EdgeInsets.only(right: 10.0, top: asset.isVideo ? 24.0 : 6.0),
|
||||||
child: _TileOverlayIcon(Icons.burst_mode_rounded),
|
child: const _TileOverlayIcon(Icons.burst_mode_rounded),
|
||||||
),
|
|
||||||
)
|
|
||||||
: const Align(
|
|
||||||
alignment: Alignment.topRight,
|
|
||||||
child: Padding(
|
|
||||||
padding: EdgeInsets.only(right: 10.0, top: 6.0),
|
|
||||||
child: _TileOverlayIcon(Icons.burst_mode_rounded),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
if (asset != null && asset.isVideo)
|
if (asset.isVideo)
|
||||||
Align(
|
Align(
|
||||||
alignment: Alignment.topRight,
|
alignment: Alignment.topRight,
|
||||||
child: Padding(
|
child: Padding(
|
||||||
@@ -108,7 +91,7 @@ class ThumbnailTile extends ConsumerWidget {
|
|||||||
child: _VideoIndicator(asset.duration),
|
child: _VideoIndicator(asset.duration),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
if (storageIndicator && asset != null)
|
if (storageIndicator)
|
||||||
switch (asset.storage) {
|
switch (asset.storage) {
|
||||||
AssetState.local => const Align(
|
AssetState.local => const Align(
|
||||||
alignment: Alignment.bottomRight,
|
alignment: Alignment.bottomRight,
|
||||||
@@ -132,7 +115,7 @@ class ThumbnailTile extends ConsumerWidget {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
if (asset != null && asset.isFavorite)
|
if (asset.isFavorite)
|
||||||
const Align(
|
const Align(
|
||||||
alignment: Alignment.bottomLeft,
|
alignment: Alignment.bottomLeft,
|
||||||
child: Padding(
|
child: Padding(
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import 'package:immich_mobile/extensions/build_context_extensions.dart';
|
|||||||
import 'package:immich_mobile/presentation/widgets/asset_viewer/video_viewer.widget.dart';
|
import 'package:immich_mobile/presentation/widgets/asset_viewer/video_viewer.widget.dart';
|
||||||
import 'package:immich_mobile/presentation/widgets/images/full_image.widget.dart';
|
import 'package:immich_mobile/presentation/widgets/images/full_image.widget.dart';
|
||||||
import 'package:immich_mobile/presentation/widgets/images/image_provider.dart';
|
import 'package:immich_mobile/presentation/widgets/images/image_provider.dart';
|
||||||
import 'package:immich_mobile/presentation/widgets/images/thumbnail.widget.dart';
|
import 'package:immich_mobile/utils/hooks/blurhash_hook.dart';
|
||||||
|
|
||||||
class DriftMemoryCard extends StatelessWidget {
|
class DriftMemoryCard extends StatelessWidget {
|
||||||
final RemoteAsset asset;
|
final RemoteAsset asset;
|
||||||
@@ -88,26 +88,31 @@ class _BlurredBackdrop extends HookWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final blurhash = asset.thumbHash;
|
final blurhash = useDriftBlurHashRef(asset).value;
|
||||||
if (blurhash != null) {
|
if (blurhash != null) {
|
||||||
// Use a nice cheap blur hash image decoration
|
// Use a nice cheap blur hash image decoration
|
||||||
return Thumbnail(blurhash: blurhash);
|
return Container(
|
||||||
}
|
decoration: BoxDecoration(
|
||||||
|
image: DecorationImage(image: MemoryImage(blurhash), fit: BoxFit.cover),
|
||||||
|
),
|
||||||
|
child: Container(color: Colors.black.withValues(alpha: 0.2)),
|
||||||
|
);
|
||||||
|
} else {
|
||||||
// Fall back to using a more expensive image filtered
|
// Fall back to using a more expensive image filtered
|
||||||
// Since the ImmichImage is already precached, we can
|
// Since the ImmichImage is already precached, we can
|
||||||
// safely use that as the image provider
|
// safely use that as the image provider
|
||||||
return ImageFiltered(
|
return ImageFiltered(
|
||||||
imageFilter: ImageFilter.blur(sigmaX: 30, sigmaY: 30),
|
imageFilter: ImageFilter.blur(sigmaX: 30, sigmaY: 30),
|
||||||
child: DecoratedBox(
|
child: Container(
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
image: DecorationImage(
|
image: DecorationImage(
|
||||||
image: getFullImageProvider(asset, size: Size(context.width, context.height)),
|
image: getFullImageProvider(asset, size: Size(context.width, context.height)),
|
||||||
fit: BoxFit.cover,
|
fit: BoxFit.cover,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
child: const ColoredBox(color: Color.fromRGBO(0, 0, 0, 0.2)),
|
child: Container(color: Colors.black.withValues(alpha: 0.2)),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -58,7 +58,11 @@ class DriftMemoryCard extends ConsumerWidget {
|
|||||||
children: [
|
children: [
|
||||||
ColorFiltered(
|
ColorFiltered(
|
||||||
colorFilter: ColorFilter.mode(Colors.black.withValues(alpha: 0.2), BlendMode.darken),
|
colorFilter: ColorFilter.mode(Colors.black.withValues(alpha: 0.2), BlendMode.darken),
|
||||||
child: SizedBox(width: 205, height: 200, child: Thumbnail.fromBaseAsset(asset: memory.assets[0])),
|
child: SizedBox(
|
||||||
|
width: 205,
|
||||||
|
height: 200,
|
||||||
|
child: Thumbnail(remoteId: memory.assets[0].id, fit: BoxFit.cover),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
Positioned(
|
Positioned(
|
||||||
bottom: 16,
|
bottom: 16,
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import 'dart:ui';
|
|||||||
|
|
||||||
const double kTimelineHeaderExtent = 80.0;
|
const double kTimelineHeaderExtent = 80.0;
|
||||||
const Size kTimelineFixedTileExtent = Size.square(256);
|
const Size kTimelineFixedTileExtent = Size.square(256);
|
||||||
const Size kThumbnailResolution = Size.square(384);
|
const Size kThumbnailResolution = kTimelineFixedTileExtent;
|
||||||
const double kTimelineSpacing = 2.0;
|
const double kTimelineSpacing = 2.0;
|
||||||
const int kTimelineColumnCount = 3;
|
const int kTimelineColumnCount = 3;
|
||||||
|
|
||||||
|
|||||||
@@ -4,19 +4,16 @@ import 'package:auto_route/auto_route.dart';
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||||
import 'package:immich_mobile/domain/models/asset/base_asset.model.dart';
|
import 'package:immich_mobile/domain/models/asset/base_asset.model.dart';
|
||||||
import 'package:immich_mobile/domain/models/timeline.model.dart';
|
|
||||||
import 'package:immich_mobile/domain/services/timeline.service.dart';
|
import 'package:immich_mobile/domain/services/timeline.service.dart';
|
||||||
import 'package:immich_mobile/presentation/widgets/asset_viewer/asset_viewer.state.dart';
|
|
||||||
import 'package:immich_mobile/presentation/widgets/images/thumbnail_tile.widget.dart';
|
import 'package:immich_mobile/presentation/widgets/images/thumbnail_tile.widget.dart';
|
||||||
import 'package:immich_mobile/presentation/widgets/timeline/fixed/row.dart';
|
import 'package:immich_mobile/presentation/widgets/timeline/fixed/row.dart';
|
||||||
import 'package:immich_mobile/presentation/widgets/timeline/header.widget.dart';
|
import 'package:immich_mobile/presentation/widgets/timeline/header.widget.dart';
|
||||||
import 'package:immich_mobile/presentation/widgets/timeline/segment.model.dart';
|
import 'package:immich_mobile/presentation/widgets/timeline/segment.model.dart';
|
||||||
|
import 'package:immich_mobile/presentation/widgets/timeline/segment_builder.dart';
|
||||||
|
import 'package:immich_mobile/presentation/widgets/timeline/timeline.state.dart';
|
||||||
import 'package:immich_mobile/presentation/widgets/timeline/timeline_drag_region.dart';
|
import 'package:immich_mobile/presentation/widgets/timeline/timeline_drag_region.dart';
|
||||||
import 'package:immich_mobile/providers/asset_viewer/is_motion_video_playing.provider.dart';
|
import 'package:immich_mobile/providers/asset_viewer/is_motion_video_playing.provider.dart';
|
||||||
import 'package:immich_mobile/providers/asset_viewer/video_player_controls_provider.dart';
|
|
||||||
import 'package:immich_mobile/providers/asset_viewer/video_player_value_provider.dart';
|
|
||||||
import 'package:immich_mobile/providers/haptic_feedback.provider.dart';
|
import 'package:immich_mobile/providers/haptic_feedback.provider.dart';
|
||||||
import 'package:immich_mobile/providers/infrastructure/asset_viewer/current_asset.provider.dart';
|
|
||||||
import 'package:immich_mobile/providers/infrastructure/timeline.provider.dart';
|
import 'package:immich_mobile/providers/infrastructure/timeline.provider.dart';
|
||||||
import 'package:immich_mobile/providers/timeline/multiselect.provider.dart';
|
import 'package:immich_mobile/providers/timeline/multiselect.provider.dart';
|
||||||
import 'package:immich_mobile/routing/router.dart';
|
import 'package:immich_mobile/routing/router.dart';
|
||||||
@@ -79,21 +76,6 @@ class FixedSegment extends Segment {
|
|||||||
spacing: spacing,
|
spacing: spacing,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const FixedSegment.empty()
|
|
||||||
: this(
|
|
||||||
firstIndex: 0,
|
|
||||||
lastIndex: 0,
|
|
||||||
startOffset: 0,
|
|
||||||
endOffset: 0,
|
|
||||||
firstAssetIndex: 0,
|
|
||||||
bucket: const Bucket(assetCount: 0),
|
|
||||||
tileHeight: 1,
|
|
||||||
columnCount: 0,
|
|
||||||
headerExtent: 0,
|
|
||||||
spacing: 0,
|
|
||||||
header: HeaderType.none,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class _FixedSegmentRow extends ConsumerWidget {
|
class _FixedSegmentRow extends ConsumerWidget {
|
||||||
@@ -111,45 +93,58 @@ class _FixedSegmentRow extends ConsumerWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context, WidgetRef ref) {
|
Widget build(BuildContext context, WidgetRef ref) {
|
||||||
|
final isScrubbing = ref.watch(timelineStateProvider.select((s) => s.isScrubbing));
|
||||||
final timelineService = ref.read(timelineServiceProvider);
|
final timelineService = ref.read(timelineServiceProvider);
|
||||||
try {
|
|
||||||
final assets = timelineService.getAssets(assetIndex, assetCount);
|
if (isScrubbing) {
|
||||||
return _buildAssetRow(context, assets, timelineService);
|
return _buildPlaceholder(context);
|
||||||
} catch (e) {
|
}
|
||||||
|
|
||||||
|
if (timelineService.hasRange(assetIndex, assetCount)) {
|
||||||
|
return _buildAssetRow(context, timelineService.getAssets(assetIndex, assetCount), timelineService);
|
||||||
|
}
|
||||||
|
|
||||||
return FutureBuilder<List<BaseAsset>>(
|
return FutureBuilder<List<BaseAsset>>(
|
||||||
future: timelineService.loadAssets(assetIndex, assetCount),
|
future: timelineService.loadAssets(assetIndex, assetCount),
|
||||||
builder: (context, snapshot) {
|
builder: (context, snapshot) {
|
||||||
return _buildAssetRow(context, snapshot.data, timelineService);
|
if (snapshot.connectionState != ConnectionState.done) {
|
||||||
|
return _buildPlaceholder(context);
|
||||||
|
}
|
||||||
|
return _buildAssetRow(context, snapshot.requireData, timelineService);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Widget _buildPlaceholder(BuildContext context) {
|
||||||
|
return SegmentBuilder.buildPlaceholder(context, assetCount, size: Size.square(tileHeight), spacing: spacing);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildAssetRow(BuildContext context, List<BaseAsset>? assets, TimelineService timelineService) {
|
Widget _buildAssetRow(BuildContext context, List<BaseAsset> assets, TimelineService timelineService) {
|
||||||
final assetIndex = this.assetIndex;
|
|
||||||
return FixedTimelineRow(
|
return FixedTimelineRow(
|
||||||
dimension: tileHeight,
|
dimension: tileHeight,
|
||||||
spacing: spacing,
|
spacing: spacing,
|
||||||
textDirection: Directionality.of(context),
|
textDirection: Directionality.of(context),
|
||||||
children: List.generate(assetCount, (i) {
|
children: [
|
||||||
final curAssetIndex = assetIndex + i;
|
for (int i = 0; i < assets.length; i++)
|
||||||
return TimelineAssetIndexWrapper(
|
TimelineAssetIndexWrapper(
|
||||||
// this key is intentionally generic to preserve the state of the widget and its subtree
|
assetIndex: assetIndex + i,
|
||||||
key: ValueKey(i.hashCode ^ timelineService.hashCode),
|
|
||||||
assetIndex: curAssetIndex,
|
|
||||||
segmentIndex: 0, // For simplicity, using 0 for now
|
segmentIndex: 0, // For simplicity, using 0 for now
|
||||||
child: _AssetTileWidget(asset: assets?[i], assetIndex: curAssetIndex),
|
child: _AssetTileWidget(
|
||||||
);
|
key: ValueKey(Object.hash(assets[i].heroTag, assetIndex + i, timelineService.hashCode)),
|
||||||
}, growable: false),
|
asset: assets[i],
|
||||||
|
assetIndex: assetIndex + i,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class _AssetTileWidget extends ConsumerWidget {
|
class _AssetTileWidget extends ConsumerWidget {
|
||||||
final BaseAsset? asset;
|
final BaseAsset asset;
|
||||||
final int assetIndex;
|
final int assetIndex;
|
||||||
|
|
||||||
const _AssetTileWidget({required this.asset, required this.assetIndex});
|
const _AssetTileWidget({super.key, required this.asset, required this.assetIndex});
|
||||||
|
|
||||||
Future _handleOnTap(BuildContext ctx, WidgetRef ref, int assetIndex, BaseAsset asset, int? heroOffset) async {
|
Future _handleOnTap(BuildContext ctx, WidgetRef ref, int assetIndex, BaseAsset asset, int? heroOffset) async {
|
||||||
final multiSelectState = ref.read(multiSelectProvider);
|
final multiSelectState = ref.read(multiSelectProvider);
|
||||||
@@ -159,12 +154,6 @@ class _AssetTileWidget extends ConsumerWidget {
|
|||||||
} else {
|
} else {
|
||||||
await ref.read(timelineServiceProvider).loadAssets(assetIndex, 1);
|
await ref.read(timelineServiceProvider).loadAssets(assetIndex, 1);
|
||||||
ref.read(isPlayingMotionVideoProvider.notifier).playing = false;
|
ref.read(isPlayingMotionVideoProvider.notifier).playing = false;
|
||||||
ref.read(assetViewerProvider.notifier).setAsset(asset);
|
|
||||||
ref.read(currentAssetNotifier.notifier).setAsset(asset);
|
|
||||||
if (asset.isVideo || asset.isMotionPhoto) {
|
|
||||||
ref.read(videoPlaybackValueProvider.notifier).reset();
|
|
||||||
ref.read(videoPlayerControlsProvider.notifier).pause();
|
|
||||||
}
|
|
||||||
ctx.pushRoute(
|
ctx.pushRoute(
|
||||||
AssetViewerRoute(
|
AssetViewerRoute(
|
||||||
initialIndex: assetIndex,
|
initialIndex: assetIndex,
|
||||||
@@ -201,17 +190,18 @@ class _AssetTileWidget extends ConsumerWidget {
|
|||||||
|
|
||||||
final lockSelection = _getLockSelectionStatus(ref);
|
final lockSelection = _getLockSelectionStatus(ref);
|
||||||
final showStorageIndicator = ref.watch(timelineArgsProvider.select((args) => args.showStorageIndicator));
|
final showStorageIndicator = ref.watch(timelineArgsProvider.select((args) => args.showStorageIndicator));
|
||||||
final asset = this.asset;
|
|
||||||
|
|
||||||
return GestureDetector(
|
return RepaintBoundary(
|
||||||
onTap: () => lockSelection || asset == null ? null : _handleOnTap(context, ref, assetIndex, asset, heroOffset),
|
child: GestureDetector(
|
||||||
onLongPress: () => lockSelection || asset == null ? null : _handleOnLongPress(ref, asset),
|
onTap: () => lockSelection ? null : _handleOnTap(context, ref, assetIndex, asset, heroOffset),
|
||||||
|
onLongPress: () => lockSelection ? null : _handleOnLongPress(ref, asset),
|
||||||
child: ThumbnailTile(
|
child: ThumbnailTile(
|
||||||
asset,
|
asset,
|
||||||
lockSelection: lockSelection,
|
lockSelection: lockSelection,
|
||||||
showStorageIndicator: showStorageIndicator,
|
showStorageIndicator: showStorageIndicator,
|
||||||
heroOffset: heroOffset,
|
heroOffset: heroOffset,
|
||||||
),
|
),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import 'package:immich_mobile/domain/models/timeline.model.dart';
|
import 'package:immich_mobile/domain/models/timeline.model.dart';
|
||||||
import 'package:immich_mobile/extensions/datetime_extensions.dart';
|
|
||||||
import 'package:immich_mobile/presentation/widgets/timeline/fixed/segment.model.dart';
|
import 'package:immich_mobile/presentation/widgets/timeline/fixed/segment.model.dart';
|
||||||
import 'package:immich_mobile/presentation/widgets/timeline/segment.model.dart';
|
import 'package:immich_mobile/presentation/widgets/timeline/segment.model.dart';
|
||||||
import 'package:immich_mobile/presentation/widgets/timeline/segment_builder.dart';
|
import 'package:immich_mobile/presentation/widgets/timeline/segment_builder.dart';
|
||||||
@@ -7,7 +6,6 @@ import 'package:immich_mobile/presentation/widgets/timeline/segment_builder.dart
|
|||||||
class FixedSegmentBuilder extends SegmentBuilder {
|
class FixedSegmentBuilder extends SegmentBuilder {
|
||||||
final double tileHeight;
|
final double tileHeight;
|
||||||
final int columnCount;
|
final int columnCount;
|
||||||
static final DateTime _dummyDate = DateTime.fromMicrosecondsSinceEpoch(0);
|
|
||||||
|
|
||||||
const FixedSegmentBuilder({
|
const FixedSegmentBuilder({
|
||||||
required super.buckets,
|
required super.buckets,
|
||||||
@@ -18,11 +16,12 @@ class FixedSegmentBuilder extends SegmentBuilder {
|
|||||||
});
|
});
|
||||||
|
|
||||||
List<Segment> generate() {
|
List<Segment> generate() {
|
||||||
final segments = List.filled(buckets.length, const FixedSegment.empty());
|
final segments = <Segment>[];
|
||||||
int firstIndex = 0;
|
int firstIndex = 0;
|
||||||
double startOffset = 0;
|
double startOffset = 0;
|
||||||
int assetIndex = 0;
|
int assetIndex = 0;
|
||||||
DateTime previousDate = _dummyDate;
|
DateTime? previousDate;
|
||||||
|
|
||||||
for (int i = 0; i < buckets.length; i++) {
|
for (int i = 0; i < buckets.length; i++) {
|
||||||
final bucket = buckets[i];
|
final bucket = buckets[i];
|
||||||
|
|
||||||
@@ -33,10 +32,11 @@ class FixedSegmentBuilder extends SegmentBuilder {
|
|||||||
final segmentFirstIndex = firstIndex;
|
final segmentFirstIndex = firstIndex;
|
||||||
firstIndex += segmentCount;
|
firstIndex += segmentCount;
|
||||||
final segmentLastIndex = firstIndex - 1;
|
final segmentLastIndex = firstIndex - 1;
|
||||||
|
|
||||||
final timelineHeader = switch (groupBy) {
|
final timelineHeader = switch (groupBy) {
|
||||||
GroupAssetsBy.month => HeaderType.month,
|
GroupAssetsBy.month => HeaderType.month,
|
||||||
GroupAssetsBy.day || GroupAssetsBy.auto =>
|
GroupAssetsBy.day || GroupAssetsBy.auto =>
|
||||||
bucket is TimeBucket && !previousDate.isSameMonth(bucket.date) ? HeaderType.monthAndDay : HeaderType.day,
|
bucket is TimeBucket && bucket.date.month != previousDate?.month ? HeaderType.monthAndDay : HeaderType.day,
|
||||||
GroupAssetsBy.none => HeaderType.none,
|
GroupAssetsBy.none => HeaderType.none,
|
||||||
};
|
};
|
||||||
final headerExtent = SegmentBuilder.headerExtent(timelineHeader);
|
final headerExtent = SegmentBuilder.headerExtent(timelineHeader);
|
||||||
@@ -45,7 +45,8 @@ class FixedSegmentBuilder extends SegmentBuilder {
|
|||||||
startOffset += headerExtent + (tileHeight * numberOfRows) + spacing * (numberOfRows - 1);
|
startOffset += headerExtent + (tileHeight * numberOfRows) + spacing * (numberOfRows - 1);
|
||||||
final segmentEndOffset = startOffset;
|
final segmentEndOffset = startOffset;
|
||||||
|
|
||||||
segments[i] = FixedSegment(
|
segments.add(
|
||||||
|
FixedSegment(
|
||||||
firstIndex: segmentFirstIndex,
|
firstIndex: segmentFirstIndex,
|
||||||
lastIndex: segmentLastIndex,
|
lastIndex: segmentLastIndex,
|
||||||
startOffset: segmentStartOffset,
|
startOffset: segmentStartOffset,
|
||||||
@@ -57,6 +58,7 @@ class FixedSegmentBuilder extends SegmentBuilder {
|
|||||||
headerExtent: headerExtent,
|
headerExtent: headerExtent,
|
||||||
spacing: spacing,
|
spacing: spacing,
|
||||||
header: timelineHeader,
|
header: timelineHeader,
|
||||||
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
assetIndex += assetCount;
|
assetIndex += assetCount;
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
|
import 'package:flutter/widgets.dart';
|
||||||
import 'package:immich_mobile/domain/models/timeline.model.dart';
|
import 'package:immich_mobile/domain/models/timeline.model.dart';
|
||||||
import 'package:immich_mobile/presentation/widgets/timeline/constants.dart';
|
import 'package:immich_mobile/presentation/widgets/timeline/constants.dart';
|
||||||
|
import 'package:immich_mobile/presentation/widgets/timeline/fixed/row.dart';
|
||||||
|
import 'package:immich_mobile/widgets/asset_grid/thumbnail_placeholder.dart';
|
||||||
|
|
||||||
abstract class SegmentBuilder {
|
abstract class SegmentBuilder {
|
||||||
final List<Bucket> buckets;
|
final List<Bucket> buckets;
|
||||||
@@ -14,4 +17,18 @@ abstract class SegmentBuilder {
|
|||||||
HeaderType.monthAndDay => kTimelineHeaderExtent * 1.6,
|
HeaderType.monthAndDay => kTimelineHeaderExtent * 1.6,
|
||||||
HeaderType.none => 0.0,
|
HeaderType.none => 0.0,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static Widget buildPlaceholder(
|
||||||
|
BuildContext context,
|
||||||
|
int count, {
|
||||||
|
Size size = kTimelineFixedTileExtent,
|
||||||
|
double spacing = kTimelineSpacing,
|
||||||
|
}) => RepaintBoundary(
|
||||||
|
child: FixedTimelineRow(
|
||||||
|
dimension: size.height,
|
||||||
|
spacing: spacing,
|
||||||
|
textDirection: Directionality.of(context),
|
||||||
|
children: List.generate(count, (_) => ThumbnailPlaceholder(width: size.width, height: size.height)),
|
||||||
|
),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ import 'package:hooks_riverpod/hooks_riverpod.dart';
|
|||||||
|
|
||||||
import 'package:immich_mobile/constants/constants.dart';
|
import 'package:immich_mobile/constants/constants.dart';
|
||||||
import 'package:immich_mobile/services/upload.service.dart';
|
import 'package:immich_mobile/services/upload.service.dart';
|
||||||
import 'package:logging/logging.dart';
|
|
||||||
|
|
||||||
class EnqueueStatus {
|
class EnqueueStatus {
|
||||||
final int enqueueCount;
|
final int enqueueCount;
|
||||||
@@ -214,7 +213,6 @@ class DriftBackupNotifier extends StateNotifier<DriftBackupState> {
|
|||||||
final UploadService _uploadService;
|
final UploadService _uploadService;
|
||||||
StreamSubscription<TaskStatusUpdate>? _statusSubscription;
|
StreamSubscription<TaskStatusUpdate>? _statusSubscription;
|
||||||
StreamSubscription<TaskProgressUpdate>? _progressSubscription;
|
StreamSubscription<TaskProgressUpdate>? _progressSubscription;
|
||||||
final _logger = Logger("DriftBackupNotifier");
|
|
||||||
|
|
||||||
/// Remove upload item from state
|
/// Remove upload item from state
|
||||||
void _removeUploadItem(String taskId) {
|
void _removeUploadItem(String taskId) {
|
||||||
@@ -335,18 +333,18 @@ class DriftBackupNotifier extends StateNotifier<DriftBackupState> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<void> handleBackupResume(String userId) async {
|
Future<void> handleBackupResume(String userId) async {
|
||||||
_logger.info("Resuming backup tasks...");
|
debugPrint("handleBackupResume");
|
||||||
final tasks = await _uploadService.getActiveTasks(kBackupGroup);
|
final tasks = await _uploadService.getActiveTasks(kBackupGroup);
|
||||||
_logger.info("Found ${tasks.length} tasks");
|
debugPrint("Found ${tasks.length} tasks");
|
||||||
|
|
||||||
if (tasks.isEmpty) {
|
if (tasks.isEmpty) {
|
||||||
// Start a new backup queue
|
// Start a new backup queue
|
||||||
_logger.info("Start a new backup queue");
|
debugPrint("Start a new backup queue");
|
||||||
return startBackup(userId);
|
await startBackup(userId);
|
||||||
}
|
}
|
||||||
|
|
||||||
_logger.info("Tasks to resume: ${tasks.length}");
|
debugPrint("Tasks to resume: ${tasks.length}");
|
||||||
return _uploadService.resumeBackup();
|
await _uploadService.resumeBackup();
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
|||||||
@@ -31,6 +31,5 @@ class CurrentAlbumNotifier extends AutoDisposeNotifier<RemoteAlbum?> {
|
|||||||
void dispose() {
|
void dispose() {
|
||||||
_keepAliveLink?.close();
|
_keepAliveLink?.close();
|
||||||
_assetSubscription?.cancel();
|
_assetSubscription?.cancel();
|
||||||
state = null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,4 @@
|
|||||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||||
import 'package:immich_mobile/platform/native_sync_api.g.dart';
|
import 'package:immich_mobile/platform/native_sync_api.g.dart';
|
||||||
import 'package:immich_mobile/platform/thumbnail_api.g.dart';
|
|
||||||
|
|
||||||
final nativeSyncApiProvider = Provider<NativeSyncApi>((_) => NativeSyncApi());
|
final nativeSyncApiProvider = Provider<NativeSyncApi>((_) => NativeSyncApi());
|
||||||
|
|
||||||
final thumbnailApi = ThumbnailApi();
|
|
||||||
|
|||||||
@@ -0,0 +1,26 @@
|
|||||||
|
import 'dart:convert';
|
||||||
|
import 'dart:typed_data';
|
||||||
|
import 'package:flutter_hooks/flutter_hooks.dart';
|
||||||
|
import 'package:immich_mobile/domain/models/asset/base_asset.model.dart';
|
||||||
|
import 'package:immich_mobile/entities/asset.entity.dart';
|
||||||
|
import 'package:thumbhash/thumbhash.dart' as thumbhash;
|
||||||
|
|
||||||
|
ObjectRef<Uint8List?> useBlurHashRef(Asset? asset) {
|
||||||
|
if (asset?.thumbhash == null) {
|
||||||
|
return useRef(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
final rbga = thumbhash.thumbHashToRGBA(base64Decode(asset!.thumbhash!));
|
||||||
|
|
||||||
|
return useRef(thumbhash.rgbaToBmp(rbga));
|
||||||
|
}
|
||||||
|
|
||||||
|
ObjectRef<Uint8List?> useDriftBlurHashRef(RemoteAsset? asset) {
|
||||||
|
if (asset?.thumbHash == null) {
|
||||||
|
return useRef(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
final rbga = thumbhash.thumbHashToRGBA(base64Decode(asset!.thumbHash!));
|
||||||
|
|
||||||
|
return useRef(thumbhash.rgbaToBmp(rbga));
|
||||||
|
}
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:immich_mobile/widgets/common/transparent_image.dart';
|
||||||
|
|
||||||
|
class FadeInPlaceholderImage extends StatelessWidget {
|
||||||
|
final Widget placeholder;
|
||||||
|
final ImageProvider image;
|
||||||
|
final Duration duration;
|
||||||
|
final BoxFit fit;
|
||||||
|
|
||||||
|
const FadeInPlaceholderImage({
|
||||||
|
super.key,
|
||||||
|
required this.placeholder,
|
||||||
|
required this.image,
|
||||||
|
this.duration = const Duration(milliseconds: 100),
|
||||||
|
this.fit = BoxFit.cover,
|
||||||
|
});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return SizedBox.expand(
|
||||||
|
child: Stack(
|
||||||
|
fit: StackFit.expand,
|
||||||
|
children: [
|
||||||
|
placeholder,
|
||||||
|
FadeInImage(fadeInDuration: duration, image: image, fit: fit, placeholder: MemoryImage(kTransparentImage)),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -40,12 +40,9 @@ class ImmichAppBar extends ConsumerWidget implements PreferredSizeWidget {
|
|||||||
showDialog(context: context, useRootNavigator: false, builder: (ctx) => const ImmichAppBarDialog()),
|
showDialog(context: context, useRootNavigator: false, builder: (ctx) => const ImmichAppBarDialog()),
|
||||||
borderRadius: const BorderRadius.all(Radius.circular(12)),
|
borderRadius: const BorderRadius.all(Radius.circular(12)),
|
||||||
child: Badge(
|
child: Badge(
|
||||||
label: const DecoratedBox(
|
label: Container(
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(color: Colors.black, borderRadius: BorderRadius.circular(widgetSize / 2)),
|
||||||
color: Colors.black,
|
child: const Icon(Icons.info, color: Color.fromARGB(255, 243, 188, 106), size: widgetSize / 2),
|
||||||
borderRadius: BorderRadius.all(Radius.circular(widgetSize / 2)),
|
|
||||||
),
|
|
||||||
child: Icon(Icons.info, color: Color.fromARGB(255, 243, 188, 106), size: widgetSize / 2),
|
|
||||||
),
|
),
|
||||||
backgroundColor: Colors.transparent,
|
backgroundColor: Colors.transparent,
|
||||||
alignment: Alignment.bottomRight,
|
alignment: Alignment.bottomRight,
|
||||||
|
|||||||
@@ -3,9 +3,9 @@ import 'package:immich_mobile/domain/models/store.model.dart';
|
|||||||
import 'package:immich_mobile/entities/asset.entity.dart';
|
import 'package:immich_mobile/entities/asset.entity.dart';
|
||||||
import 'package:immich_mobile/entities/store.entity.dart';
|
import 'package:immich_mobile/entities/store.entity.dart';
|
||||||
import 'package:immich_mobile/extensions/build_context_extensions.dart';
|
import 'package:immich_mobile/extensions/build_context_extensions.dart';
|
||||||
import 'package:immich_mobile/presentation/widgets/images/thumbnail.widget.dart';
|
|
||||||
import 'package:immich_mobile/providers/image/immich_local_image_provider.dart';
|
import 'package:immich_mobile/providers/image/immich_local_image_provider.dart';
|
||||||
import 'package:immich_mobile/providers/image/immich_remote_image_provider.dart';
|
import 'package:immich_mobile/providers/image/immich_remote_image_provider.dart';
|
||||||
|
import 'package:immich_mobile/widgets/asset_grid/thumbnail_placeholder.dart';
|
||||||
import 'package:octo_image/octo_image.dart';
|
import 'package:octo_image/octo_image.dart';
|
||||||
|
|
||||||
class ImmichImage extends StatelessWidget {
|
class ImmichImage extends StatelessWidget {
|
||||||
@@ -14,7 +14,7 @@ class ImmichImage extends StatelessWidget {
|
|||||||
this.width,
|
this.width,
|
||||||
this.height,
|
this.height,
|
||||||
this.fit = BoxFit.cover,
|
this.fit = BoxFit.cover,
|
||||||
this.placeholder = const Thumbnail(),
|
this.placeholder = const ThumbnailPlaceholder(),
|
||||||
super.key,
|
super.key,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,11 @@
|
|||||||
|
import 'dart:typed_data';
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||||
import 'package:immich_mobile/providers/image/immich_local_thumbnail_provider.dart';
|
import 'package:immich_mobile/providers/image/immich_local_thumbnail_provider.dart';
|
||||||
import 'package:immich_mobile/providers/image/immich_remote_thumbnail_provider.dart';
|
import 'package:immich_mobile/providers/image/immich_remote_thumbnail_provider.dart';
|
||||||
import 'package:immich_mobile/entities/asset.entity.dart';
|
import 'package:immich_mobile/entities/asset.entity.dart';
|
||||||
|
import 'package:immich_mobile/utils/hooks/blurhash_hook.dart';
|
||||||
import 'package:immich_mobile/utils/thumbnail_utils.dart';
|
import 'package:immich_mobile/utils/thumbnail_utils.dart';
|
||||||
import 'package:immich_mobile/widgets/common/immich_image.dart';
|
import 'package:immich_mobile/widgets/common/immich_image.dart';
|
||||||
import 'package:immich_mobile/widgets/common/thumbhash_placeholder.dart';
|
import 'package:immich_mobile/widgets/common/thumbhash_placeholder.dart';
|
||||||
@@ -39,6 +42,7 @@ class ImmichThumbnail extends HookConsumerWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context, WidgetRef ref) {
|
Widget build(BuildContext context, WidgetRef ref) {
|
||||||
|
Uint8List? blurhash = useBlurHashRef(asset).value;
|
||||||
final userId = ref.watch(currentUserProvider)?.id;
|
final userId = ref.watch(currentUserProvider)?.id;
|
||||||
|
|
||||||
if (asset == null) {
|
if (asset == null) {
|
||||||
@@ -50,14 +54,14 @@ class ImmichThumbnail extends HookConsumerWidget {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
final assetAltText = getAltText(asset!.exifInfo, asset!.fileCreatedAt, asset!.type, const []);
|
final assetAltText = getAltText(asset!.exifInfo, asset!.fileCreatedAt, asset!.type, []);
|
||||||
|
|
||||||
final thumbnailProviderInstance = ImmichThumbnail.imageProvider(asset: asset, userId: userId);
|
final thumbnailProviderInstance = ImmichThumbnail.imageProvider(asset: asset, userId: userId);
|
||||||
|
|
||||||
customErrorBuilder(BuildContext ctx, Object error, StackTrace? stackTrace) {
|
customErrorBuilder(BuildContext ctx, Object error, StackTrace? stackTrace) {
|
||||||
thumbnailProviderInstance.evict();
|
thumbnailProviderInstance.evict();
|
||||||
|
|
||||||
final originalErrorWidgetBuilder = blurHashErrorBuilder(asset?.thumbhash, fit: fit);
|
final originalErrorWidgetBuilder = blurHashErrorBuilder(blurhash, fit: fit);
|
||||||
return originalErrorWidgetBuilder(ctx, error, stackTrace);
|
return originalErrorWidgetBuilder(ctx, error, stackTrace);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -68,7 +72,7 @@ class ImmichThumbnail extends HookConsumerWidget {
|
|||||||
fadeInDuration: Duration.zero,
|
fadeInDuration: Duration.zero,
|
||||||
fadeOutDuration: const Duration(milliseconds: 100),
|
fadeOutDuration: const Duration(milliseconds: 100),
|
||||||
octoSet: OctoSet(
|
octoSet: OctoSet(
|
||||||
placeholderBuilder: blurHashPlaceholderBuilder(asset?.thumbhash, fit: fit),
|
placeholderBuilder: blurHashPlaceholderBuilder(blurhash, fit: fit),
|
||||||
errorBuilder: customErrorBuilder,
|
errorBuilder: customErrorBuilder,
|
||||||
),
|
),
|
||||||
image: thumbnailProviderInstance,
|
image: thumbnailProviderInstance,
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import 'package:immich_mobile/extensions/build_context_extensions.dart';
|
|||||||
import 'package:immich_mobile/extensions/datetime_extensions.dart';
|
import 'package:immich_mobile/extensions/datetime_extensions.dart';
|
||||||
import 'package:immich_mobile/extensions/translate_extensions.dart';
|
import 'package:immich_mobile/extensions/translate_extensions.dart';
|
||||||
import 'package:immich_mobile/presentation/widgets/images/image_provider.dart';
|
import 'package:immich_mobile/presentation/widgets/images/image_provider.dart';
|
||||||
|
import 'package:immich_mobile/providers/infrastructure/album.provider.dart';
|
||||||
import 'package:immich_mobile/providers/infrastructure/current_album.provider.dart';
|
import 'package:immich_mobile/providers/infrastructure/current_album.provider.dart';
|
||||||
import 'package:immich_mobile/providers/infrastructure/remote_album.provider.dart';
|
import 'package:immich_mobile/providers/infrastructure/remote_album.provider.dart';
|
||||||
import 'package:immich_mobile/providers/infrastructure/timeline.provider.dart';
|
import 'package:immich_mobile/providers/infrastructure/timeline.provider.dart';
|
||||||
@@ -73,15 +74,14 @@ class _MesmerizingSliverAppBarState extends ConsumerState<RemoteAlbumSliverAppBa
|
|||||||
const Shadow(offset: Offset(0, 2), blurRadius: 0, color: Colors.transparent),
|
const Shadow(offset: Offset(0, 2), blurRadius: 0, color: Colors.transparent),
|
||||||
];
|
];
|
||||||
|
|
||||||
if (isMultiSelectEnabled) {
|
return isMultiSelectEnabled
|
||||||
return SliverToBoxAdapter(
|
? SliverToBoxAdapter(
|
||||||
child: switch (_scrollProgress) {
|
child: switch (_scrollProgress) {
|
||||||
< 0.8 => const SizedBox(height: 120),
|
< 0.8 => const SizedBox(height: 120),
|
||||||
_ => const SizedBox(height: 452),
|
_ => const SizedBox(height: 452),
|
||||||
},
|
},
|
||||||
);
|
)
|
||||||
} else {
|
: SliverAppBar(
|
||||||
return SliverAppBar(
|
|
||||||
expandedHeight: 400.0,
|
expandedHeight: 400.0,
|
||||||
floating: false,
|
floating: false,
|
||||||
pinned: true,
|
pinned: true,
|
||||||
@@ -93,7 +93,10 @@ class _MesmerizingSliverAppBarState extends ConsumerState<RemoteAlbumSliverAppBa
|
|||||||
color: actionIconColor,
|
color: actionIconColor,
|
||||||
shadows: actionIconShadows,
|
shadows: actionIconShadows,
|
||||||
),
|
),
|
||||||
onPressed: () => context.navigateTo(const TabShellRoute(children: [DriftAlbumsRoute()])),
|
onPressed: () {
|
||||||
|
ref.read(remoteAlbumProvider.notifier).refresh();
|
||||||
|
context.navigateTo(const TabShellRoute(children: [DriftAlbumsRoute()]));
|
||||||
|
},
|
||||||
),
|
),
|
||||||
actions: [
|
actions: [
|
||||||
if (widget.onToggleAlbumOrder != null)
|
if (widget.onToggleAlbumOrder != null)
|
||||||
@@ -143,7 +146,6 @@ class _MesmerizingSliverAppBarState extends ConsumerState<RemoteAlbumSliverAppBa
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
class _ExpandedBackground extends ConsumerStatefulWidget {
|
class _ExpandedBackground extends ConsumerStatefulWidget {
|
||||||
final double scrollProgress;
|
final double scrollProgress;
|
||||||
|
|||||||
@@ -1,14 +1,31 @@
|
|||||||
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:immich_mobile/presentation/widgets/images/thumbnail.widget.dart';
|
import 'package:immich_mobile/widgets/asset_grid/thumbnail_placeholder.dart';
|
||||||
|
import 'package:immich_mobile/widgets/common/fade_in_placeholder_image.dart';
|
||||||
import 'package:octo_image/octo_image.dart';
|
import 'package:octo_image/octo_image.dart';
|
||||||
|
|
||||||
OctoPlaceholderBuilder blurHashPlaceholderBuilder(String? blurhash, {required BoxFit fit}) {
|
/// Simple set to show [OctoPlaceholder.circularProgressIndicator] as
|
||||||
return (context) => Thumbnail(blurhash: blurhash, fit: fit);
|
/// placeholder and [OctoError.icon] as error.
|
||||||
|
OctoSet blurHashOrPlaceholder(Uint8List? blurhash, {BoxFit? fit, Text? errorMessage}) {
|
||||||
|
return OctoSet(
|
||||||
|
placeholderBuilder: blurHashPlaceholderBuilder(blurhash, fit: fit),
|
||||||
|
errorBuilder: blurHashErrorBuilder(blurhash, fit: fit, message: errorMessage),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
OctoPlaceholderBuilder blurHashPlaceholderBuilder(Uint8List? blurhash, {BoxFit? fit}) {
|
||||||
|
return (context) => blurhash == null
|
||||||
|
? const ThumbnailPlaceholder()
|
||||||
|
: FadeInPlaceholderImage(
|
||||||
|
placeholder: const ThumbnailPlaceholder(),
|
||||||
|
image: MemoryImage(blurhash),
|
||||||
|
fit: fit ?? BoxFit.cover,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
OctoErrorBuilder blurHashErrorBuilder(
|
OctoErrorBuilder blurHashErrorBuilder(
|
||||||
String? blurhash, {
|
Uint8List? blurhash, {
|
||||||
BoxFit fit = BoxFit.cover,
|
BoxFit? fit,
|
||||||
Text? message,
|
Text? message,
|
||||||
IconData? icon,
|
IconData? icon,
|
||||||
Color? iconColor,
|
Color? iconColor,
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import 'package:flutter_hooks/flutter_hooks.dart';
|
|||||||
import 'package:immich_mobile/entities/asset.entity.dart';
|
import 'package:immich_mobile/entities/asset.entity.dart';
|
||||||
import 'package:immich_mobile/extensions/build_context_extensions.dart';
|
import 'package:immich_mobile/extensions/build_context_extensions.dart';
|
||||||
import 'package:immich_mobile/pages/common/native_video_viewer.page.dart';
|
import 'package:immich_mobile/pages/common/native_video_viewer.page.dart';
|
||||||
import 'package:immich_mobile/presentation/widgets/images/thumbnail.widget.dart';
|
import 'package:immich_mobile/utils/hooks/blurhash_hook.dart';
|
||||||
import 'package:immich_mobile/widgets/common/immich_image.dart';
|
import 'package:immich_mobile/widgets/common/immich_image.dart';
|
||||||
|
|
||||||
class MemoryCard extends StatelessWidget {
|
class MemoryCard extends StatelessWidget {
|
||||||
@@ -87,26 +87,31 @@ class _BlurredBackdrop extends HookWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final blurhash = asset.thumbhash;
|
final blurhash = useBlurHashRef(asset).value;
|
||||||
if (blurhash != null) {
|
if (blurhash != null) {
|
||||||
// Use a nice cheap blur hash image decoration
|
// Use a nice cheap blur hash image decoration
|
||||||
return Thumbnail(blurhash: blurhash, fit: BoxFit.cover);
|
return Container(
|
||||||
}
|
decoration: BoxDecoration(
|
||||||
|
image: DecorationImage(image: MemoryImage(blurhash), fit: BoxFit.cover),
|
||||||
|
),
|
||||||
|
child: Container(color: Colors.black.withValues(alpha: 0.2)),
|
||||||
|
);
|
||||||
|
} else {
|
||||||
// Fall back to using a more expensive image filtered
|
// Fall back to using a more expensive image filtered
|
||||||
// Since the ImmichImage is already precached, we can
|
// Since the ImmichImage is already precached, we can
|
||||||
// safely use that as the image provider
|
// safely use that as the image provider
|
||||||
return ImageFiltered(
|
return ImageFiltered(
|
||||||
imageFilter: ImageFilter.blur(sigmaX: 30, sigmaY: 30),
|
imageFilter: ImageFilter.blur(sigmaX: 30, sigmaY: 30),
|
||||||
child: DecoratedBox(
|
child: Container(
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
image: DecorationImage(
|
image: DecorationImage(
|
||||||
image: ImmichImage.imageProvider(asset: asset, height: context.height, width: context.width),
|
image: ImmichImage.imageProvider(asset: asset, height: context.height, width: context.width),
|
||||||
fit: BoxFit.cover,
|
fit: BoxFit.cover,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
child: const ColoredBox(color: Color.fromRGBO(0, 0, 0, 0.2)),
|
child: Container(color: Colors.black.withValues(alpha: 0.2)),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -421,7 +421,6 @@ class PhotoViewCoreState extends State<PhotoViewCore>
|
|||||||
filterQuality: widget.filterQuality,
|
filterQuality: widget.filterQuality,
|
||||||
width: scaleBoundaries.childSize.width * scale,
|
width: scaleBoundaries.childSize.width * scale,
|
||||||
fit: BoxFit.cover,
|
fit: BoxFit.cover,
|
||||||
isAntiAlias: widget.filterQuality == FilterQuality.high,
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,9 +7,7 @@ build:
|
|||||||
|
|
||||||
pigeon:
|
pigeon:
|
||||||
dart run pigeon --input pigeon/native_sync_api.dart
|
dart run pigeon --input pigeon/native_sync_api.dart
|
||||||
dart run pigeon --input pigeon/thumbnail_api.dart
|
|
||||||
dart format lib/platform/native_sync_api.g.dart
|
dart format lib/platform/native_sync_api.g.dart
|
||||||
dart format lib/platform/thumbnail_api.g.dart
|
|
||||||
|
|
||||||
watch:
|
watch:
|
||||||
dart run build_runner watch --delete-conflicting-outputs
|
dart run build_runner watch --delete-conflicting-outputs
|
||||||
@@ -27,7 +25,6 @@ migration:
|
|||||||
dart run drift_dev make-migrations
|
dart run drift_dev make-migrations
|
||||||
|
|
||||||
translation:
|
translation:
|
||||||
npm --prefix ../web run format:i18n
|
|
||||||
dart run easy_localization:generate -S ../i18n
|
dart run easy_localization:generate -S ../i18n
|
||||||
dart run bin/generate_keys.dart
|
dart run bin/generate_keys.dart
|
||||||
dart format lib/generated/codegen_loader.g.dart
|
dart format lib/generated/codegen_loader.g.dart
|
||||||
|
|||||||
Generated
-1
@@ -108,7 +108,6 @@ Class | Method | HTTP request | Description
|
|||||||
*AssetsApi* | [**updateAssets**](doc//AssetsApi.md#updateassets) | **PUT** /assets |
|
*AssetsApi* | [**updateAssets**](doc//AssetsApi.md#updateassets) | **PUT** /assets |
|
||||||
*AssetsApi* | [**uploadAsset**](doc//AssetsApi.md#uploadasset) | **POST** /assets |
|
*AssetsApi* | [**uploadAsset**](doc//AssetsApi.md#uploadasset) | **POST** /assets |
|
||||||
*AssetsApi* | [**viewAsset**](doc//AssetsApi.md#viewasset) | **GET** /assets/{id}/thumbnail |
|
*AssetsApi* | [**viewAsset**](doc//AssetsApi.md#viewasset) | **GET** /assets/{id}/thumbnail |
|
||||||
*AuthAdminApi* | [**unlinkAllOAuthAccountsAdmin**](doc//AuthAdminApi.md#unlinkalloauthaccountsadmin) | **POST** /admin/auth/unlink-all |
|
|
||||||
*AuthenticationApi* | [**changePassword**](doc//AuthenticationApi.md#changepassword) | **POST** /auth/change-password |
|
*AuthenticationApi* | [**changePassword**](doc//AuthenticationApi.md#changepassword) | **POST** /auth/change-password |
|
||||||
*AuthenticationApi* | [**changePinCode**](doc//AuthenticationApi.md#changepincode) | **PUT** /auth/pin-code |
|
*AuthenticationApi* | [**changePinCode**](doc//AuthenticationApi.md#changepincode) | **PUT** /auth/pin-code |
|
||||||
*AuthenticationApi* | [**getAuthStatus**](doc//AuthenticationApi.md#getauthstatus) | **GET** /auth/status |
|
*AuthenticationApi* | [**getAuthStatus**](doc//AuthenticationApi.md#getauthstatus) | **GET** /auth/status |
|
||||||
|
|||||||
Generated
-1
@@ -34,7 +34,6 @@ part 'api/api_keys_api.dart';
|
|||||||
part 'api/activities_api.dart';
|
part 'api/activities_api.dart';
|
||||||
part 'api/albums_api.dart';
|
part 'api/albums_api.dart';
|
||||||
part 'api/assets_api.dart';
|
part 'api/assets_api.dart';
|
||||||
part 'api/auth_admin_api.dart';
|
|
||||||
part 'api/authentication_api.dart';
|
part 'api/authentication_api.dart';
|
||||||
part 'api/deprecated_api.dart';
|
part 'api/deprecated_api.dart';
|
||||||
part 'api/download_api.dart';
|
part 'api/download_api.dart';
|
||||||
|
|||||||
-54
@@ -1,54 +0,0 @@
|
|||||||
//
|
|
||||||
// AUTO-GENERATED FILE, DO NOT MODIFY!
|
|
||||||
//
|
|
||||||
// @dart=2.18
|
|
||||||
|
|
||||||
// ignore_for_file: unused_element, unused_import
|
|
||||||
// ignore_for_file: always_put_required_named_parameters_first
|
|
||||||
// ignore_for_file: constant_identifier_names
|
|
||||||
// ignore_for_file: lines_longer_than_80_chars
|
|
||||||
|
|
||||||
part of openapi.api;
|
|
||||||
|
|
||||||
|
|
||||||
class AuthAdminApi {
|
|
||||||
AuthAdminApi([ApiClient? apiClient]) : apiClient = apiClient ?? defaultApiClient;
|
|
||||||
|
|
||||||
final ApiClient apiClient;
|
|
||||||
|
|
||||||
/// This endpoint is an admin-only route, and requires the `adminAuth.unlinkAll` permission.
|
|
||||||
///
|
|
||||||
/// Note: This method returns the HTTP [Response].
|
|
||||||
Future<Response> unlinkAllOAuthAccountsAdminWithHttpInfo() async {
|
|
||||||
// ignore: prefer_const_declarations
|
|
||||||
final apiPath = r'/admin/auth/unlink-all';
|
|
||||||
|
|
||||||
// ignore: prefer_final_locals
|
|
||||||
Object? postBody;
|
|
||||||
|
|
||||||
final queryParams = <QueryParam>[];
|
|
||||||
final headerParams = <String, String>{};
|
|
||||||
final formParams = <String, String>{};
|
|
||||||
|
|
||||||
const contentTypes = <String>[];
|
|
||||||
|
|
||||||
|
|
||||||
return apiClient.invokeAPI(
|
|
||||||
apiPath,
|
|
||||||
'POST',
|
|
||||||
queryParams,
|
|
||||||
postBody,
|
|
||||||
headerParams,
|
|
||||||
formParams,
|
|
||||||
contentTypes.isEmpty ? null : contentTypes.first,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// This endpoint is an admin-only route, and requires the `adminAuth.unlinkAll` permission.
|
|
||||||
Future<void> unlinkAllOAuthAccountsAdmin() async {
|
|
||||||
final response = await unlinkAllOAuthAccountsAdminWithHttpInfo();
|
|
||||||
if (response.statusCode >= HttpStatus.badRequest) {
|
|
||||||
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Generated
-3
@@ -150,7 +150,6 @@ class Permission {
|
|||||||
static const adminUserPeriodRead = Permission._(r'adminUser.read');
|
static const adminUserPeriodRead = Permission._(r'adminUser.read');
|
||||||
static const adminUserPeriodUpdate = Permission._(r'adminUser.update');
|
static const adminUserPeriodUpdate = Permission._(r'adminUser.update');
|
||||||
static const adminUserPeriodDelete = Permission._(r'adminUser.delete');
|
static const adminUserPeriodDelete = Permission._(r'adminUser.delete');
|
||||||
static const adminAuthPeriodUnlinkAll = Permission._(r'adminAuth.unlinkAll');
|
|
||||||
|
|
||||||
/// List of all possible values in this [enum][Permission].
|
/// List of all possible values in this [enum][Permission].
|
||||||
static const values = <Permission>[
|
static const values = <Permission>[
|
||||||
@@ -281,7 +280,6 @@ class Permission {
|
|||||||
adminUserPeriodRead,
|
adminUserPeriodRead,
|
||||||
adminUserPeriodUpdate,
|
adminUserPeriodUpdate,
|
||||||
adminUserPeriodDelete,
|
adminUserPeriodDelete,
|
||||||
adminAuthPeriodUnlinkAll,
|
|
||||||
];
|
];
|
||||||
|
|
||||||
static Permission? fromJson(dynamic value) => PermissionTypeTransformer().decode(value);
|
static Permission? fromJson(dynamic value) => PermissionTypeTransformer().decode(value);
|
||||||
@@ -447,7 +445,6 @@ class PermissionTypeTransformer {
|
|||||||
case r'adminUser.read': return Permission.adminUserPeriodRead;
|
case r'adminUser.read': return Permission.adminUserPeriodRead;
|
||||||
case r'adminUser.update': return Permission.adminUserPeriodUpdate;
|
case r'adminUser.update': return Permission.adminUserPeriodUpdate;
|
||||||
case r'adminUser.delete': return Permission.adminUserPeriodDelete;
|
case r'adminUser.delete': return Permission.adminUserPeriodDelete;
|
||||||
case r'adminAuth.unlinkAll': return Permission.adminAuthPeriodUnlinkAll;
|
|
||||||
default:
|
default:
|
||||||
if (!allowNull) {
|
if (!allowNull) {
|
||||||
throw ArgumentError('Unknown enum value to decode: $data');
|
throw ArgumentError('Unknown enum value to decode: $data');
|
||||||
|
|||||||
@@ -1,21 +0,0 @@
|
|||||||
import 'package:pigeon/pigeon.dart';
|
|
||||||
|
|
||||||
@ConfigurePigeon(
|
|
||||||
PigeonOptions(
|
|
||||||
dartOut: 'lib/platform/thumbnail_api.g.dart',
|
|
||||||
swiftOut: 'ios/Runner/Images/Thumbnails.g.swift',
|
|
||||||
swiftOptions: SwiftOptions(includeErrorClass: false),
|
|
||||||
kotlinOut:
|
|
||||||
'android/app/src/main/kotlin/app/alextran/immich/images/Thumbnails.g.kt',
|
|
||||||
kotlinOptions: KotlinOptions(package: 'app.alextran.immich.images'),
|
|
||||||
dartOptions: DartOptions(),
|
|
||||||
dartPackageName: 'immich_mobile',
|
|
||||||
),
|
|
||||||
)
|
|
||||||
@HostApi()
|
|
||||||
abstract class ThumbnailApi {
|
|
||||||
@async
|
|
||||||
Map<String, int> requestImage(String assetId, {required int requestId, required int width, required int height});
|
|
||||||
|
|
||||||
void cancelImageRequest(int requestId);
|
|
||||||
}
|
|
||||||
+1
-1
@@ -514,7 +514,7 @@ packages:
|
|||||||
source: hosted
|
source: hosted
|
||||||
version: "1.3.3"
|
version: "1.3.3"
|
||||||
ffi:
|
ffi:
|
||||||
dependency: "direct main"
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: ffi
|
name: ffi
|
||||||
sha256: "289279317b4b16eb2bb7e271abccd4bf84ec9bdcbe999e278a94b804f5630418"
|
sha256: "289279317b4b16eb2bb7e271abccd4bf84ec9bdcbe999e278a94b804f5630418"
|
||||||
|
|||||||
@@ -73,7 +73,6 @@ dependencies:
|
|||||||
wakelock_plus: ^1.2.10
|
wakelock_plus: ^1.2.10
|
||||||
worker_manager: ^7.2.3
|
worker_manager: ^7.2.3
|
||||||
scroll_date_picker: ^3.8.0
|
scroll_date_picker: ^3.8.0
|
||||||
ffi: ^2.1.4
|
|
||||||
|
|
||||||
native_video_player:
|
native_video_player:
|
||||||
git:
|
git:
|
||||||
|
|||||||
@@ -214,34 +214,6 @@
|
|||||||
"description": "This endpoint requires the `activity.delete` permission."
|
"description": "This endpoint requires the `activity.delete` permission."
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"/admin/auth/unlink-all": {
|
|
||||||
"post": {
|
|
||||||
"operationId": "unlinkAllOAuthAccountsAdmin",
|
|
||||||
"parameters": [],
|
|
||||||
"responses": {
|
|
||||||
"204": {
|
|
||||||
"description": ""
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"security": [
|
|
||||||
{
|
|
||||||
"bearer": []
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"cookie": []
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"api_key": []
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"tags": [
|
|
||||||
"Auth (admin)"
|
|
||||||
],
|
|
||||||
"x-immich-admin-only": true,
|
|
||||||
"x-immich-permission": "adminAuth.unlinkAll",
|
|
||||||
"description": "This endpoint is an admin-only route, and requires the `adminAuth.unlinkAll` permission."
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"/admin/notifications": {
|
"/admin/notifications": {
|
||||||
"post": {
|
"post": {
|
||||||
"operationId": "createNotification",
|
"operationId": "createNotification",
|
||||||
@@ -989,7 +961,7 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"responses": {
|
"responses": {
|
||||||
"204": {
|
"200": {
|
||||||
"description": ""
|
"description": ""
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -1280,7 +1252,7 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"responses": {
|
"responses": {
|
||||||
"204": {
|
"200": {
|
||||||
"description": ""
|
"description": ""
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -1333,7 +1305,7 @@
|
|||||||
"required": true
|
"required": true
|
||||||
},
|
},
|
||||||
"responses": {
|
"responses": {
|
||||||
"204": {
|
"200": {
|
||||||
"description": ""
|
"description": ""
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -2568,7 +2540,7 @@
|
|||||||
"required": true
|
"required": true
|
||||||
},
|
},
|
||||||
"responses": {
|
"responses": {
|
||||||
"204": {
|
"200": {
|
||||||
"description": ""
|
"description": ""
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -2603,7 +2575,7 @@
|
|||||||
"required": true
|
"required": true
|
||||||
},
|
},
|
||||||
"responses": {
|
"responses": {
|
||||||
"204": {
|
"201": {
|
||||||
"description": ""
|
"description": ""
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -2638,7 +2610,7 @@
|
|||||||
"required": true
|
"required": true
|
||||||
},
|
},
|
||||||
"responses": {
|
"responses": {
|
||||||
"204": {
|
"200": {
|
||||||
"description": ""
|
"description": ""
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -2665,7 +2637,7 @@
|
|||||||
"operationId": "lockAuthSession",
|
"operationId": "lockAuthSession",
|
||||||
"parameters": [],
|
"parameters": [],
|
||||||
"responses": {
|
"responses": {
|
||||||
"204": {
|
"200": {
|
||||||
"description": ""
|
"description": ""
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -2700,7 +2672,7 @@
|
|||||||
"required": true
|
"required": true
|
||||||
},
|
},
|
||||||
"responses": {
|
"responses": {
|
||||||
"204": {
|
"200": {
|
||||||
"description": ""
|
"description": ""
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -2922,7 +2894,7 @@
|
|||||||
"required": true
|
"required": true
|
||||||
},
|
},
|
||||||
"responses": {
|
"responses": {
|
||||||
"204": {
|
"200": {
|
||||||
"description": ""
|
"description": ""
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -2994,7 +2966,7 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"responses": {
|
"responses": {
|
||||||
"204": {
|
"200": {
|
||||||
"description": ""
|
"description": ""
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -3123,7 +3095,7 @@
|
|||||||
"required": true
|
"required": true
|
||||||
},
|
},
|
||||||
"responses": {
|
"responses": {
|
||||||
"204": {
|
"200": {
|
||||||
"description": ""
|
"description": ""
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -3245,7 +3217,7 @@
|
|||||||
"required": true
|
"required": true
|
||||||
},
|
},
|
||||||
"responses": {
|
"responses": {
|
||||||
"204": {
|
"201": {
|
||||||
"description": ""
|
"description": ""
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -4252,7 +4224,7 @@
|
|||||||
"required": true
|
"required": true
|
||||||
},
|
},
|
||||||
"responses": {
|
"responses": {
|
||||||
"204": {
|
"200": {
|
||||||
"description": ""
|
"description": ""
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -4356,7 +4328,7 @@
|
|||||||
"required": true
|
"required": true
|
||||||
},
|
},
|
||||||
"responses": {
|
"responses": {
|
||||||
"204": {
|
"200": {
|
||||||
"description": ""
|
"description": ""
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -4393,7 +4365,7 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"responses": {
|
"responses": {
|
||||||
"204": {
|
"200": {
|
||||||
"description": ""
|
"description": ""
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -4586,7 +4558,7 @@
|
|||||||
"required": true
|
"required": true
|
||||||
},
|
},
|
||||||
"responses": {
|
"responses": {
|
||||||
"200": {
|
"201": {
|
||||||
"content": {
|
"content": {
|
||||||
"application/json": {
|
"application/json": {
|
||||||
"schema": {
|
"schema": {
|
||||||
@@ -4720,7 +4692,7 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"responses": {
|
"responses": {
|
||||||
"204": {
|
"200": {
|
||||||
"description": ""
|
"description": ""
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -5198,7 +5170,7 @@
|
|||||||
"required": true
|
"required": true
|
||||||
},
|
},
|
||||||
"responses": {
|
"responses": {
|
||||||
"200": {
|
"201": {
|
||||||
"content": {
|
"content": {
|
||||||
"application/json": {
|
"application/json": {
|
||||||
"schema": {
|
"schema": {
|
||||||
@@ -6250,7 +6222,7 @@
|
|||||||
"operationId": "deleteServerLicense",
|
"operationId": "deleteServerLicense",
|
||||||
"parameters": [],
|
"parameters": [],
|
||||||
"responses": {
|
"responses": {
|
||||||
"204": {
|
"200": {
|
||||||
"description": ""
|
"description": ""
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -6963,7 +6935,7 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"responses": {
|
"responses": {
|
||||||
"204": {
|
"200": {
|
||||||
"description": ""
|
"description": ""
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -8984,7 +8956,7 @@
|
|||||||
"operationId": "deleteUserLicense",
|
"operationId": "deleteUserLicense",
|
||||||
"parameters": [],
|
"parameters": [],
|
||||||
"responses": {
|
"responses": {
|
||||||
"204": {
|
"200": {
|
||||||
"description": ""
|
"description": ""
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -9085,7 +9057,7 @@
|
|||||||
"operationId": "deleteUserOnboarding",
|
"operationId": "deleteUserOnboarding",
|
||||||
"parameters": [],
|
"parameters": [],
|
||||||
"responses": {
|
"responses": {
|
||||||
"204": {
|
"200": {
|
||||||
"description": ""
|
"description": ""
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -12715,8 +12687,7 @@
|
|||||||
"adminUser.create",
|
"adminUser.create",
|
||||||
"adminUser.read",
|
"adminUser.read",
|
||||||
"adminUser.update",
|
"adminUser.update",
|
||||||
"adminUser.delete",
|
"adminUser.delete"
|
||||||
"adminAuth.unlinkAll"
|
|
||||||
],
|
],
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1646,15 +1646,6 @@ export function deleteActivity({ id }: {
|
|||||||
method: "DELETE"
|
method: "DELETE"
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* This endpoint is an admin-only route, and requires the `adminAuth.unlinkAll` permission.
|
|
||||||
*/
|
|
||||||
export function unlinkAllOAuthAccountsAdmin(opts?: Oazapfts.RequestOpts) {
|
|
||||||
return oazapfts.ok(oazapfts.fetchText("/admin/auth/unlink-all", {
|
|
||||||
...opts,
|
|
||||||
method: "POST"
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
export function createNotification({ notificationCreateDto }: {
|
export function createNotification({ notificationCreateDto }: {
|
||||||
notificationCreateDto: NotificationCreateDto;
|
notificationCreateDto: NotificationCreateDto;
|
||||||
}, opts?: Oazapfts.RequestOpts) {
|
}, opts?: Oazapfts.RequestOpts) {
|
||||||
@@ -2978,7 +2969,7 @@ export function linkOAuthAccount({ oAuthCallbackDto }: {
|
|||||||
oAuthCallbackDto: OAuthCallbackDto;
|
oAuthCallbackDto: OAuthCallbackDto;
|
||||||
}, opts?: Oazapfts.RequestOpts) {
|
}, opts?: Oazapfts.RequestOpts) {
|
||||||
return oazapfts.ok(oazapfts.fetchJson<{
|
return oazapfts.ok(oazapfts.fetchJson<{
|
||||||
status: 200;
|
status: 201;
|
||||||
data: UserAdminResponseDto;
|
data: UserAdminResponseDto;
|
||||||
}>("/oauth/link", oazapfts.json({
|
}>("/oauth/link", oazapfts.json({
|
||||||
...opts,
|
...opts,
|
||||||
@@ -3169,7 +3160,7 @@ export function mergePerson({ id, mergePersonDto }: {
|
|||||||
mergePersonDto: MergePersonDto;
|
mergePersonDto: MergePersonDto;
|
||||||
}, opts?: Oazapfts.RequestOpts) {
|
}, opts?: Oazapfts.RequestOpts) {
|
||||||
return oazapfts.ok(oazapfts.fetchJson<{
|
return oazapfts.ok(oazapfts.fetchJson<{
|
||||||
status: 200;
|
status: 201;
|
||||||
data: BulkIdResponseDto[];
|
data: BulkIdResponseDto[];
|
||||||
}>(`/people/${encodeURIComponent(id)}/merge`, oazapfts.json({
|
}>(`/people/${encodeURIComponent(id)}/merge`, oazapfts.json({
|
||||||
...opts,
|
...opts,
|
||||||
@@ -4678,8 +4669,7 @@ export enum Permission {
|
|||||||
AdminUserCreate = "adminUser.create",
|
AdminUserCreate = "adminUser.create",
|
||||||
AdminUserRead = "adminUser.read",
|
AdminUserRead = "adminUser.read",
|
||||||
AdminUserUpdate = "adminUser.update",
|
AdminUserUpdate = "adminUser.update",
|
||||||
AdminUserDelete = "adminUser.delete",
|
AdminUserDelete = "adminUser.delete"
|
||||||
AdminAuthUnlinkAll = "adminAuth.unlinkAll"
|
|
||||||
}
|
}
|
||||||
export enum AssetMediaStatus {
|
export enum AssetMediaStatus {
|
||||||
Created = "created",
|
Created = "created",
|
||||||
|
|||||||
+3
-1
@@ -18,7 +18,7 @@ ENTRYPOINT ["tini", "--", "/bin/bash", "-c"]
|
|||||||
FROM dev AS dev-container-server
|
FROM dev AS dev-container-server
|
||||||
|
|
||||||
RUN rm -rf /usr/src/app
|
RUN rm -rf /usr/src/app
|
||||||
RUN apt-get update --allow-releaseinfo-change && \
|
RUN apt-get update && \
|
||||||
apt-get install sudo inetutils-ping openjdk-11-jre-headless \
|
apt-get install sudo inetutils-ping openjdk-11-jre-headless \
|
||||||
vim nano \
|
vim nano \
|
||||||
-y --no-install-recommends --fix-missing
|
-y --no-install-recommends --fix-missing
|
||||||
@@ -69,6 +69,8 @@ RUN sudo apt-get update \
|
|||||||
&& sudo apt-get update \
|
&& sudo apt-get update \
|
||||||
&& sudo apt-get install dcm -y
|
&& sudo apt-get install dcm -y
|
||||||
|
|
||||||
|
COPY --chmod=777 ../.devcontainer/mobile/container-mobile-post-create.sh /immich-devcontainer/container-mobile-post-create.sh
|
||||||
|
|
||||||
RUN dart --disable-analytics
|
RUN dart --disable-analytics
|
||||||
|
|
||||||
FROM dev AS prod
|
FROM dev AS prod
|
||||||
|
|||||||
@@ -46,8 +46,8 @@ export class ActivityController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Delete(':id')
|
@Delete(':id')
|
||||||
@Authenticated({ permission: Permission.ActivityDelete })
|
|
||||||
@HttpCode(HttpStatus.NO_CONTENT)
|
@HttpCode(HttpStatus.NO_CONTENT)
|
||||||
|
@Authenticated({ permission: Permission.ActivityDelete })
|
||||||
deleteActivity(@Auth() auth: AuthDto, @Param() { id }: UUIDParamDto): Promise<void> {
|
deleteActivity(@Auth() auth: AuthDto, @Param() { id }: UUIDParamDto): Promise<void> {
|
||||||
return this.service.delete(auth, id);
|
return this.service.delete(auth, id);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { Body, Controller, Delete, Get, HttpCode, HttpStatus, Param, Patch, Post, Put, Query } from '@nestjs/common';
|
import { Body, Controller, Delete, Get, Param, Patch, Post, Put, Query } from '@nestjs/common';
|
||||||
import { ApiTags } from '@nestjs/swagger';
|
import { ApiTags } from '@nestjs/swagger';
|
||||||
import {
|
import {
|
||||||
AddUsersDto,
|
AddUsersDto,
|
||||||
@@ -62,7 +62,6 @@ export class AlbumController {
|
|||||||
|
|
||||||
@Delete(':id')
|
@Delete(':id')
|
||||||
@Authenticated({ permission: Permission.AlbumDelete })
|
@Authenticated({ permission: Permission.AlbumDelete })
|
||||||
@HttpCode(HttpStatus.NO_CONTENT)
|
|
||||||
deleteAlbum(@Auth() auth: AuthDto, @Param() { id }: UUIDParamDto) {
|
deleteAlbum(@Auth() auth: AuthDto, @Param() { id }: UUIDParamDto) {
|
||||||
return this.service.delete(auth, id);
|
return this.service.delete(auth, id);
|
||||||
}
|
}
|
||||||
@@ -99,7 +98,6 @@ export class AlbumController {
|
|||||||
|
|
||||||
@Put(':id/user/:userId')
|
@Put(':id/user/:userId')
|
||||||
@Authenticated({ permission: Permission.AlbumUserUpdate })
|
@Authenticated({ permission: Permission.AlbumUserUpdate })
|
||||||
@HttpCode(HttpStatus.NO_CONTENT)
|
|
||||||
updateAlbumUser(
|
updateAlbumUser(
|
||||||
@Auth() auth: AuthDto,
|
@Auth() auth: AuthDto,
|
||||||
@Param() { id }: UUIDParamDto,
|
@Param() { id }: UUIDParamDto,
|
||||||
@@ -111,12 +109,11 @@ export class AlbumController {
|
|||||||
|
|
||||||
@Delete(':id/user/:userId')
|
@Delete(':id/user/:userId')
|
||||||
@Authenticated({ permission: Permission.AlbumUserDelete })
|
@Authenticated({ permission: Permission.AlbumUserDelete })
|
||||||
@HttpCode(HttpStatus.NO_CONTENT)
|
|
||||||
removeUserFromAlbum(
|
removeUserFromAlbum(
|
||||||
@Auth() auth: AuthDto,
|
@Auth() auth: AuthDto,
|
||||||
@Param() { id }: UUIDParamDto,
|
@Param() { id }: UUIDParamDto,
|
||||||
@Param('userId', new ParseMeUUIDPipe({ version: '4' })) userId: string,
|
@Param('userId', new ParseMeUUIDPipe({ version: '4' })) userId: string,
|
||||||
): Promise<void> {
|
) {
|
||||||
return this.service.removeUser(auth, id, userId);
|
return this.service.removeUser(auth, id, userId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,8 +41,8 @@ export class APIKeyController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Delete(':id')
|
@Delete(':id')
|
||||||
@Authenticated({ permission: Permission.ApiKeyDelete })
|
|
||||||
@HttpCode(HttpStatus.NO_CONTENT)
|
@HttpCode(HttpStatus.NO_CONTENT)
|
||||||
|
@Authenticated({ permission: Permission.ApiKeyDelete })
|
||||||
deleteApiKey(@Auth() auth: AuthDto, @Param() { id }: UUIDParamDto): Promise<void> {
|
deleteApiKey(@Auth() auth: AuthDto, @Param() { id }: UUIDParamDto): Promise<void> {
|
||||||
return this.service.delete(auth, id);
|
return this.service.delete(auth, id);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -171,12 +171,12 @@ export class AssetMediaController {
|
|||||||
* Checks if multiple assets exist on the server and returns all existing - used by background backup
|
* Checks if multiple assets exist on the server and returns all existing - used by background backup
|
||||||
*/
|
*/
|
||||||
@Post('exist')
|
@Post('exist')
|
||||||
@Authenticated()
|
@HttpCode(HttpStatus.OK)
|
||||||
@ApiOperation({
|
@ApiOperation({
|
||||||
summary: 'checkExistingAssets',
|
summary: 'checkExistingAssets',
|
||||||
description: 'Checks if multiple assets exist on the server and returns all existing - used by background backup',
|
description: 'Checks if multiple assets exist on the server and returns all existing - used by background backup',
|
||||||
})
|
})
|
||||||
@HttpCode(HttpStatus.OK)
|
@Authenticated()
|
||||||
checkExistingAssets(
|
checkExistingAssets(
|
||||||
@Auth() auth: AuthDto,
|
@Auth() auth: AuthDto,
|
||||||
@Body() dto: CheckExistingAssetsDto,
|
@Body() dto: CheckExistingAssetsDto,
|
||||||
@@ -188,12 +188,12 @@ export class AssetMediaController {
|
|||||||
* Checks if assets exist by checksums
|
* Checks if assets exist by checksums
|
||||||
*/
|
*/
|
||||||
@Post('bulk-upload-check')
|
@Post('bulk-upload-check')
|
||||||
@Authenticated()
|
@HttpCode(HttpStatus.OK)
|
||||||
@ApiOperation({
|
@ApiOperation({
|
||||||
summary: 'checkBulkUpload',
|
summary: 'checkBulkUpload',
|
||||||
description: 'Checks if assets exist by checksums',
|
description: 'Checks if assets exist by checksums',
|
||||||
})
|
})
|
||||||
@HttpCode(HttpStatus.OK)
|
@Authenticated()
|
||||||
checkBulkUpload(
|
checkBulkUpload(
|
||||||
@Auth() auth: AuthDto,
|
@Auth() auth: AuthDto,
|
||||||
@Body() dto: AssetBulkUploadCheckDto,
|
@Body() dto: AssetBulkUploadCheckDto,
|
||||||
|
|||||||
@@ -57,15 +57,15 @@ export class AssetController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Put()
|
@Put()
|
||||||
@Authenticated({ permission: Permission.AssetUpdate })
|
|
||||||
@HttpCode(HttpStatus.NO_CONTENT)
|
@HttpCode(HttpStatus.NO_CONTENT)
|
||||||
|
@Authenticated({ permission: Permission.AssetUpdate })
|
||||||
updateAssets(@Auth() auth: AuthDto, @Body() dto: AssetBulkUpdateDto): Promise<void> {
|
updateAssets(@Auth() auth: AuthDto, @Body() dto: AssetBulkUpdateDto): Promise<void> {
|
||||||
return this.service.updateAll(auth, dto);
|
return this.service.updateAll(auth, dto);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Delete()
|
@Delete()
|
||||||
@Authenticated({ permission: Permission.AssetDelete })
|
|
||||||
@HttpCode(HttpStatus.NO_CONTENT)
|
@HttpCode(HttpStatus.NO_CONTENT)
|
||||||
|
@Authenticated({ permission: Permission.AssetDelete })
|
||||||
deleteAssets(@Auth() auth: AuthDto, @Body() dto: AssetBulkDeleteDto): Promise<void> {
|
deleteAssets(@Auth() auth: AuthDto, @Body() dto: AssetBulkDeleteDto): Promise<void> {
|
||||||
return this.service.deleteAll(auth, dto);
|
return this.service.deleteAll(auth, dto);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,18 +0,0 @@
|
|||||||
import { Controller, HttpCode, HttpStatus, Post } from '@nestjs/common';
|
|
||||||
import { ApiTags } from '@nestjs/swagger';
|
|
||||||
import { AuthDto } from 'src/dtos/auth.dto';
|
|
||||||
import { Permission } from 'src/enum';
|
|
||||||
import { Auth, Authenticated } from 'src/middleware/auth.guard';
|
|
||||||
import { AuthAdminService } from 'src/services/auth-admin.service';
|
|
||||||
|
|
||||||
@ApiTags('Auth (admin)')
|
|
||||||
@Controller('admin/auth')
|
|
||||||
export class AuthAdminController {
|
|
||||||
constructor(private service: AuthAdminService) {}
|
|
||||||
@Post('unlink-all')
|
|
||||||
@Authenticated({ permission: Permission.AdminAuthUnlinkAll, admin: true })
|
|
||||||
@HttpCode(HttpStatus.NO_CONTENT)
|
|
||||||
unlinkAllOAuthAccountsAdmin(@Auth() auth: AuthDto): Promise<void> {
|
|
||||||
return this.service.unlinkAll(auth);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -49,22 +49,22 @@ export class AuthController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Post('validateToken')
|
@Post('validateToken')
|
||||||
@Authenticated()
|
|
||||||
@HttpCode(HttpStatus.OK)
|
@HttpCode(HttpStatus.OK)
|
||||||
|
@Authenticated()
|
||||||
validateAccessToken(): ValidateAccessTokenResponseDto {
|
validateAccessToken(): ValidateAccessTokenResponseDto {
|
||||||
return { authStatus: true };
|
return { authStatus: true };
|
||||||
}
|
}
|
||||||
|
|
||||||
@Post('change-password')
|
@Post('change-password')
|
||||||
@Authenticated({ permission: Permission.AuthChangePassword })
|
|
||||||
@HttpCode(HttpStatus.OK)
|
@HttpCode(HttpStatus.OK)
|
||||||
|
@Authenticated({ permission: Permission.AuthChangePassword })
|
||||||
changePassword(@Auth() auth: AuthDto, @Body() dto: ChangePasswordDto): Promise<UserAdminResponseDto> {
|
changePassword(@Auth() auth: AuthDto, @Body() dto: ChangePasswordDto): Promise<UserAdminResponseDto> {
|
||||||
return this.service.changePassword(auth, dto);
|
return this.service.changePassword(auth, dto);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Post('logout')
|
@Post('logout')
|
||||||
@Authenticated()
|
|
||||||
@HttpCode(HttpStatus.OK)
|
@HttpCode(HttpStatus.OK)
|
||||||
|
@Authenticated()
|
||||||
async logout(
|
async logout(
|
||||||
@Req() request: Request,
|
@Req() request: Request,
|
||||||
@Res({ passthrough: true }) res: Response,
|
@Res({ passthrough: true }) res: Response,
|
||||||
@@ -88,35 +88,32 @@ export class AuthController {
|
|||||||
|
|
||||||
@Post('pin-code')
|
@Post('pin-code')
|
||||||
@Authenticated({ permission: Permission.PinCodeCreate })
|
@Authenticated({ permission: Permission.PinCodeCreate })
|
||||||
@HttpCode(HttpStatus.NO_CONTENT)
|
|
||||||
setupPinCode(@Auth() auth: AuthDto, @Body() dto: PinCodeSetupDto): Promise<void> {
|
setupPinCode(@Auth() auth: AuthDto, @Body() dto: PinCodeSetupDto): Promise<void> {
|
||||||
return this.service.setupPinCode(auth, dto);
|
return this.service.setupPinCode(auth, dto);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Put('pin-code')
|
@Put('pin-code')
|
||||||
@Authenticated({ permission: Permission.PinCodeUpdate })
|
@Authenticated({ permission: Permission.PinCodeUpdate })
|
||||||
@HttpCode(HttpStatus.NO_CONTENT)
|
|
||||||
async changePinCode(@Auth() auth: AuthDto, @Body() dto: PinCodeChangeDto): Promise<void> {
|
async changePinCode(@Auth() auth: AuthDto, @Body() dto: PinCodeChangeDto): Promise<void> {
|
||||||
return this.service.changePinCode(auth, dto);
|
return this.service.changePinCode(auth, dto);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Delete('pin-code')
|
@Delete('pin-code')
|
||||||
@Authenticated({ permission: Permission.PinCodeDelete })
|
@Authenticated({ permission: Permission.PinCodeDelete })
|
||||||
@HttpCode(HttpStatus.NO_CONTENT)
|
|
||||||
async resetPinCode(@Auth() auth: AuthDto, @Body() dto: PinCodeResetDto): Promise<void> {
|
async resetPinCode(@Auth() auth: AuthDto, @Body() dto: PinCodeResetDto): Promise<void> {
|
||||||
return this.service.resetPinCode(auth, dto);
|
return this.service.resetPinCode(auth, dto);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Post('session/unlock')
|
@Post('session/unlock')
|
||||||
|
@HttpCode(HttpStatus.OK)
|
||||||
@Authenticated()
|
@Authenticated()
|
||||||
@HttpCode(HttpStatus.NO_CONTENT)
|
|
||||||
async unlockAuthSession(@Auth() auth: AuthDto, @Body() dto: SessionUnlockDto): Promise<void> {
|
async unlockAuthSession(@Auth() auth: AuthDto, @Body() dto: SessionUnlockDto): Promise<void> {
|
||||||
return this.service.unlockSession(auth, dto);
|
return this.service.unlockSession(auth, dto);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Post('session/lock')
|
@Post('session/lock')
|
||||||
|
@HttpCode(HttpStatus.OK)
|
||||||
@Authenticated()
|
@Authenticated()
|
||||||
@HttpCode(HttpStatus.NO_CONTENT)
|
|
||||||
async lockAuthSession(@Auth() auth: AuthDto): Promise<void> {
|
async lockAuthSession(@Auth() auth: AuthDto): Promise<void> {
|
||||||
return this.service.lockSession(auth);
|
return this.service.lockSession(auth);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,9 +20,9 @@ export class DownloadController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Post('archive')
|
@Post('archive')
|
||||||
@Authenticated({ permission: Permission.AssetDownload, sharedLink: true })
|
|
||||||
@FileResponse()
|
|
||||||
@HttpCode(HttpStatus.OK)
|
@HttpCode(HttpStatus.OK)
|
||||||
|
@FileResponse()
|
||||||
|
@Authenticated({ permission: Permission.AssetDownload, sharedLink: true })
|
||||||
downloadArchive(@Auth() auth: AuthDto, @Body() dto: AssetIdsDto): Promise<StreamableFile> {
|
downloadArchive(@Auth() auth: AuthDto, @Body() dto: AssetIdsDto): Promise<StreamableFile> {
|
||||||
return this.service.downloadArchive(auth, dto).then(asStreamableFile);
|
return this.service.downloadArchive(auth, dto).then(asStreamableFile);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { Body, Controller, Delete, Get, HttpCode, HttpStatus, Param } from '@nestjs/common';
|
import { Body, Controller, Delete, Get, Param } from '@nestjs/common';
|
||||||
import { ApiTags } from '@nestjs/swagger';
|
import { ApiTags } from '@nestjs/swagger';
|
||||||
import { BulkIdsDto } from 'src/dtos/asset-ids.response.dto';
|
import { BulkIdsDto } from 'src/dtos/asset-ids.response.dto';
|
||||||
import { AuthDto } from 'src/dtos/auth.dto';
|
import { AuthDto } from 'src/dtos/auth.dto';
|
||||||
@@ -21,14 +21,12 @@ export class DuplicateController {
|
|||||||
|
|
||||||
@Delete()
|
@Delete()
|
||||||
@Authenticated({ permission: Permission.DuplicateDelete })
|
@Authenticated({ permission: Permission.DuplicateDelete })
|
||||||
@HttpCode(HttpStatus.NO_CONTENT)
|
|
||||||
deleteDuplicates(@Auth() auth: AuthDto, @Body() dto: BulkIdsDto): Promise<void> {
|
deleteDuplicates(@Auth() auth: AuthDto, @Body() dto: BulkIdsDto): Promise<void> {
|
||||||
return this.service.deleteAll(auth, dto);
|
return this.service.deleteAll(auth, dto);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Delete(':id')
|
@Delete(':id')
|
||||||
@Authenticated({ permission: Permission.DuplicateDelete })
|
@Authenticated({ permission: Permission.DuplicateDelete })
|
||||||
@HttpCode(HttpStatus.NO_CONTENT)
|
|
||||||
deleteDuplicate(@Auth() auth: AuthDto, @Param() { id }: UUIDParamDto): Promise<void> {
|
deleteDuplicate(@Auth() auth: AuthDto, @Param() { id }: UUIDParamDto): Promise<void> {
|
||||||
return this.service.delete(auth, id);
|
return this.service.delete(auth, id);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { Body, Controller, Delete, Get, HttpCode, HttpStatus, Param, Post, Put, Query } from '@nestjs/common';
|
import { Body, Controller, Delete, Get, Param, Post, Put, Query } from '@nestjs/common';
|
||||||
import { ApiTags } from '@nestjs/swagger';
|
import { ApiTags } from '@nestjs/swagger';
|
||||||
import { AuthDto } from 'src/dtos/auth.dto';
|
import { AuthDto } from 'src/dtos/auth.dto';
|
||||||
import {
|
import {
|
||||||
@@ -42,8 +42,7 @@ export class FaceController {
|
|||||||
|
|
||||||
@Delete(':id')
|
@Delete(':id')
|
||||||
@Authenticated({ permission: Permission.FaceDelete })
|
@Authenticated({ permission: Permission.FaceDelete })
|
||||||
@HttpCode(HttpStatus.NO_CONTENT)
|
deleteFace(@Auth() auth: AuthDto, @Param() { id }: UUIDParamDto, @Body() dto: AssetFaceDeleteDto) {
|
||||||
deleteFace(@Auth() auth: AuthDto, @Param() { id }: UUIDParamDto, @Body() dto: AssetFaceDeleteDto): Promise<void> {
|
|
||||||
return this.service.deleteFace(auth, id, dto);
|
return this.service.deleteFace(auth, id, dto);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import { APIKeyController } from 'src/controllers/api-key.controller';
|
|||||||
import { AppController } from 'src/controllers/app.controller';
|
import { AppController } from 'src/controllers/app.controller';
|
||||||
import { AssetMediaController } from 'src/controllers/asset-media.controller';
|
import { AssetMediaController } from 'src/controllers/asset-media.controller';
|
||||||
import { AssetController } from 'src/controllers/asset.controller';
|
import { AssetController } from 'src/controllers/asset.controller';
|
||||||
import { AuthAdminController } from 'src/controllers/auth-admin.controller';
|
|
||||||
import { AuthController } from 'src/controllers/auth.controller';
|
import { AuthController } from 'src/controllers/auth.controller';
|
||||||
import { DownloadController } from 'src/controllers/download.controller';
|
import { DownloadController } from 'src/controllers/download.controller';
|
||||||
import { DuplicateController } from 'src/controllers/duplicate.controller';
|
import { DuplicateController } from 'src/controllers/duplicate.controller';
|
||||||
@@ -41,7 +40,6 @@ export const controllers = [
|
|||||||
AssetController,
|
AssetController,
|
||||||
AssetMediaController,
|
AssetMediaController,
|
||||||
AuthController,
|
AuthController,
|
||||||
AuthAdminController,
|
|
||||||
DownloadController,
|
DownloadController,
|
||||||
DuplicateController,
|
DuplicateController,
|
||||||
FaceController,
|
FaceController,
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { Body, Controller, Get, HttpCode, HttpStatus, Param, Post, Put } from '@nestjs/common';
|
import { Body, Controller, Get, Param, Post, Put } from '@nestjs/common';
|
||||||
import { ApiTags } from '@nestjs/swagger';
|
import { ApiTags } from '@nestjs/swagger';
|
||||||
import { AllJobStatusResponseDto, JobCommandDto, JobCreateDto, JobIdParamDto, JobStatusDto } from 'src/dtos/job.dto';
|
import { AllJobStatusResponseDto, JobCommandDto, JobCreateDto, JobIdParamDto, JobStatusDto } from 'src/dtos/job.dto';
|
||||||
import { Permission } from 'src/enum';
|
import { Permission } from 'src/enum';
|
||||||
@@ -18,7 +18,6 @@ export class JobController {
|
|||||||
|
|
||||||
@Post()
|
@Post()
|
||||||
@Authenticated({ permission: Permission.JobCreate, admin: true })
|
@Authenticated({ permission: Permission.JobCreate, admin: true })
|
||||||
@HttpCode(HttpStatus.NO_CONTENT)
|
|
||||||
createJob(@Body() dto: JobCreateDto): Promise<void> {
|
createJob(@Body() dto: JobCreateDto): Promise<void> {
|
||||||
return this.service.create(dto);
|
return this.service.create(dto);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,15 +43,15 @@ export class LibraryController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Delete(':id')
|
@Delete(':id')
|
||||||
@Authenticated({ permission: Permission.LibraryDelete, admin: true })
|
|
||||||
@HttpCode(HttpStatus.NO_CONTENT)
|
@HttpCode(HttpStatus.NO_CONTENT)
|
||||||
|
@Authenticated({ permission: Permission.LibraryDelete, admin: true })
|
||||||
deleteLibrary(@Param() { id }: UUIDParamDto): Promise<void> {
|
deleteLibrary(@Param() { id }: UUIDParamDto): Promise<void> {
|
||||||
return this.service.delete(id);
|
return this.service.delete(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Post(':id/validate')
|
@Post(':id/validate')
|
||||||
|
@HttpCode(200)
|
||||||
@Authenticated({ admin: true })
|
@Authenticated({ admin: true })
|
||||||
@HttpCode(HttpStatus.OK)
|
|
||||||
// TODO: change endpoint to validate current settings instead
|
// TODO: change endpoint to validate current settings instead
|
||||||
validate(@Param() { id }: UUIDParamDto, @Body() dto: ValidateLibraryDto): Promise<ValidateLibraryResponseDto> {
|
validate(@Param() { id }: UUIDParamDto, @Body() dto: ValidateLibraryDto): Promise<ValidateLibraryResponseDto> {
|
||||||
return this.service.validate(id, dto);
|
return this.service.validate(id, dto);
|
||||||
@@ -64,9 +64,9 @@ export class LibraryController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Post(':id/scan')
|
@Post(':id/scan')
|
||||||
@Authenticated({ permission: Permission.LibraryUpdate, admin: true })
|
|
||||||
@HttpCode(HttpStatus.NO_CONTENT)
|
@HttpCode(HttpStatus.NO_CONTENT)
|
||||||
scanLibrary(@Param() { id }: UUIDParamDto): Promise<void> {
|
@Authenticated({ permission: Permission.LibraryUpdate, admin: true })
|
||||||
|
scanLibrary(@Param() { id }: UUIDParamDto) {
|
||||||
return this.service.queueScan(id);
|
return this.service.queueScan(id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -54,8 +54,8 @@ export class MemoryController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Delete(':id')
|
@Delete(':id')
|
||||||
@Authenticated({ permission: Permission.MemoryDelete })
|
|
||||||
@HttpCode(HttpStatus.NO_CONTENT)
|
@HttpCode(HttpStatus.NO_CONTENT)
|
||||||
|
@Authenticated({ permission: Permission.MemoryDelete })
|
||||||
deleteMemory(@Auth() auth: AuthDto, @Param() { id }: UUIDParamDto): Promise<void> {
|
deleteMemory(@Auth() auth: AuthDto, @Param() { id }: UUIDParamDto): Promise<void> {
|
||||||
return this.service.remove(auth, id);
|
return this.service.remove(auth, id);
|
||||||
}
|
}
|
||||||
@@ -71,8 +71,8 @@ export class MemoryController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Delete(':id/assets')
|
@Delete(':id/assets')
|
||||||
@Authenticated({ permission: Permission.MemoryAssetDelete })
|
|
||||||
@HttpCode(HttpStatus.OK)
|
@HttpCode(HttpStatus.OK)
|
||||||
|
@Authenticated({ permission: Permission.MemoryAssetDelete })
|
||||||
removeMemoryAssets(
|
removeMemoryAssets(
|
||||||
@Auth() auth: AuthDto,
|
@Auth() auth: AuthDto,
|
||||||
@Body() dto: BulkIdsDto,
|
@Body() dto: BulkIdsDto,
|
||||||
|
|||||||
@@ -25,15 +25,15 @@ export class NotificationAdminController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Post('test-email')
|
@Post('test-email')
|
||||||
@Authenticated({ admin: true })
|
|
||||||
@HttpCode(HttpStatus.OK)
|
@HttpCode(HttpStatus.OK)
|
||||||
|
@Authenticated({ admin: true })
|
||||||
sendTestEmailAdmin(@Auth() auth: AuthDto, @Body() dto: SystemConfigSmtpDto): Promise<TestEmailResponseDto> {
|
sendTestEmailAdmin(@Auth() auth: AuthDto, @Body() dto: SystemConfigSmtpDto): Promise<TestEmailResponseDto> {
|
||||||
return this.service.sendTestEmail(auth.user.id, dto);
|
return this.service.sendTestEmail(auth.user.id, dto);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Post('templates/:name')
|
@Post('templates/:name')
|
||||||
@Authenticated({ admin: true })
|
|
||||||
@HttpCode(HttpStatus.OK)
|
@HttpCode(HttpStatus.OK)
|
||||||
|
@Authenticated({ admin: true })
|
||||||
getNotificationTemplateAdmin(
|
getNotificationTemplateAdmin(
|
||||||
@Auth() auth: AuthDto,
|
@Auth() auth: AuthDto,
|
||||||
@Param('name') name: EmailTemplate,
|
@Param('name') name: EmailTemplate,
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { Body, Controller, Delete, Get, HttpCode, HttpStatus, Param, Put, Query } from '@nestjs/common';
|
import { Body, Controller, Delete, Get, Param, Put, Query } from '@nestjs/common';
|
||||||
import { ApiTags } from '@nestjs/swagger';
|
import { ApiTags } from '@nestjs/swagger';
|
||||||
import { AuthDto } from 'src/dtos/auth.dto';
|
import { AuthDto } from 'src/dtos/auth.dto';
|
||||||
import {
|
import {
|
||||||
@@ -26,14 +26,12 @@ export class NotificationController {
|
|||||||
|
|
||||||
@Put()
|
@Put()
|
||||||
@Authenticated({ permission: Permission.NotificationUpdate })
|
@Authenticated({ permission: Permission.NotificationUpdate })
|
||||||
@HttpCode(HttpStatus.NO_CONTENT)
|
|
||||||
updateNotifications(@Auth() auth: AuthDto, @Body() dto: NotificationUpdateAllDto): Promise<void> {
|
updateNotifications(@Auth() auth: AuthDto, @Body() dto: NotificationUpdateAllDto): Promise<void> {
|
||||||
return this.service.updateAll(auth, dto);
|
return this.service.updateAll(auth, dto);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Delete()
|
@Delete()
|
||||||
@Authenticated({ permission: Permission.NotificationDelete })
|
@Authenticated({ permission: Permission.NotificationDelete })
|
||||||
@HttpCode(HttpStatus.NO_CONTENT)
|
|
||||||
deleteNotifications(@Auth() auth: AuthDto, @Body() dto: NotificationDeleteAllDto): Promise<void> {
|
deleteNotifications(@Auth() auth: AuthDto, @Body() dto: NotificationDeleteAllDto): Promise<void> {
|
||||||
return this.service.deleteAll(auth, dto);
|
return this.service.deleteAll(auth, dto);
|
||||||
}
|
}
|
||||||
@@ -56,7 +54,6 @@ export class NotificationController {
|
|||||||
|
|
||||||
@Delete(':id')
|
@Delete(':id')
|
||||||
@Authenticated({ permission: Permission.NotificationDelete })
|
@Authenticated({ permission: Permission.NotificationDelete })
|
||||||
@HttpCode(HttpStatus.NO_CONTENT)
|
|
||||||
deleteNotification(@Auth() auth: AuthDto, @Param() { id }: UUIDParamDto): Promise<void> {
|
deleteNotification(@Auth() auth: AuthDto, @Param() { id }: UUIDParamDto): Promise<void> {
|
||||||
return this.service.delete(auth, id);
|
return this.service.delete(auth, id);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -70,7 +70,6 @@ export class OAuthController {
|
|||||||
|
|
||||||
@Post('link')
|
@Post('link')
|
||||||
@Authenticated()
|
@Authenticated()
|
||||||
@HttpCode(HttpStatus.OK)
|
|
||||||
linkOAuthAccount(
|
linkOAuthAccount(
|
||||||
@Req() request: Request,
|
@Req() request: Request,
|
||||||
@Auth() auth: AuthDto,
|
@Auth() auth: AuthDto,
|
||||||
@@ -80,8 +79,8 @@ export class OAuthController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Post('unlink')
|
@Post('unlink')
|
||||||
@Authenticated()
|
|
||||||
@HttpCode(HttpStatus.OK)
|
@HttpCode(HttpStatus.OK)
|
||||||
|
@Authenticated()
|
||||||
unlinkOAuthAccount(@Auth() auth: AuthDto): Promise<UserAdminResponseDto> {
|
unlinkOAuthAccount(@Auth() auth: AuthDto): Promise<UserAdminResponseDto> {
|
||||||
return this.service.unlink(auth);
|
return this.service.unlink(auth);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { Body, Controller, Delete, Get, HttpCode, HttpStatus, Param, Post, Put, Query } from '@nestjs/common';
|
import { Body, Controller, Delete, Get, Param, Post, Put, Query } from '@nestjs/common';
|
||||||
import { ApiTags } from '@nestjs/swagger';
|
import { ApiTags } from '@nestjs/swagger';
|
||||||
import { AuthDto } from 'src/dtos/auth.dto';
|
import { AuthDto } from 'src/dtos/auth.dto';
|
||||||
import { PartnerResponseDto, PartnerSearchDto, UpdatePartnerDto } from 'src/dtos/partner.dto';
|
import { PartnerResponseDto, PartnerSearchDto, UpdatePartnerDto } from 'src/dtos/partner.dto';
|
||||||
@@ -36,7 +36,6 @@ export class PartnerController {
|
|||||||
|
|
||||||
@Delete(':id')
|
@Delete(':id')
|
||||||
@Authenticated({ permission: Permission.PartnerDelete })
|
@Authenticated({ permission: Permission.PartnerDelete })
|
||||||
@HttpCode(HttpStatus.NO_CONTENT)
|
|
||||||
removePartner(@Auth() auth: AuthDto, @Param() { id }: UUIDParamDto): Promise<void> {
|
removePartner(@Auth() auth: AuthDto, @Param() { id }: UUIDParamDto): Promise<void> {
|
||||||
return this.service.remove(auth, id);
|
return this.service.remove(auth, id);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -63,8 +63,8 @@ export class PersonController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Delete()
|
@Delete()
|
||||||
@Authenticated({ permission: Permission.PersonDelete })
|
|
||||||
@HttpCode(HttpStatus.NO_CONTENT)
|
@HttpCode(HttpStatus.NO_CONTENT)
|
||||||
|
@Authenticated({ permission: Permission.PersonDelete })
|
||||||
deletePeople(@Auth() auth: AuthDto, @Body() dto: BulkIdsDto): Promise<void> {
|
deletePeople(@Auth() auth: AuthDto, @Body() dto: BulkIdsDto): Promise<void> {
|
||||||
return this.service.deleteAll(auth, dto);
|
return this.service.deleteAll(auth, dto);
|
||||||
}
|
}
|
||||||
@@ -86,8 +86,8 @@ export class PersonController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Delete(':id')
|
@Delete(':id')
|
||||||
@Authenticated({ permission: Permission.PersonDelete })
|
|
||||||
@HttpCode(HttpStatus.NO_CONTENT)
|
@HttpCode(HttpStatus.NO_CONTENT)
|
||||||
|
@Authenticated({ permission: Permission.PersonDelete })
|
||||||
deletePerson(@Auth() auth: AuthDto, @Param() { id }: UUIDParamDto): Promise<void> {
|
deletePerson(@Auth() auth: AuthDto, @Param() { id }: UUIDParamDto): Promise<void> {
|
||||||
return this.service.delete(auth, id);
|
return this.service.delete(auth, id);
|
||||||
}
|
}
|
||||||
@@ -122,7 +122,6 @@ export class PersonController {
|
|||||||
|
|
||||||
@Post(':id/merge')
|
@Post(':id/merge')
|
||||||
@Authenticated({ permission: Permission.PersonMerge })
|
@Authenticated({ permission: Permission.PersonMerge })
|
||||||
@HttpCode(HttpStatus.OK)
|
|
||||||
mergePerson(
|
mergePerson(
|
||||||
@Auth() auth: AuthDto,
|
@Auth() auth: AuthDto,
|
||||||
@Param() { id }: UUIDParamDto,
|
@Param() { id }: UUIDParamDto,
|
||||||
|
|||||||
@@ -27,36 +27,36 @@ export class SearchController {
|
|||||||
constructor(private service: SearchService) {}
|
constructor(private service: SearchService) {}
|
||||||
|
|
||||||
@Post('metadata')
|
@Post('metadata')
|
||||||
@Authenticated({ permission: Permission.AssetRead })
|
|
||||||
@HttpCode(HttpStatus.OK)
|
@HttpCode(HttpStatus.OK)
|
||||||
|
@Authenticated({ permission: Permission.AssetRead })
|
||||||
searchAssets(@Auth() auth: AuthDto, @Body() dto: MetadataSearchDto): Promise<SearchResponseDto> {
|
searchAssets(@Auth() auth: AuthDto, @Body() dto: MetadataSearchDto): Promise<SearchResponseDto> {
|
||||||
return this.service.searchMetadata(auth, dto);
|
return this.service.searchMetadata(auth, dto);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Post('statistics')
|
@Post('statistics')
|
||||||
@Authenticated({ permission: Permission.AssetStatistics })
|
|
||||||
@HttpCode(HttpStatus.OK)
|
@HttpCode(HttpStatus.OK)
|
||||||
|
@Authenticated({ permission: Permission.AssetStatistics })
|
||||||
searchAssetStatistics(@Auth() auth: AuthDto, @Body() dto: StatisticsSearchDto): Promise<SearchStatisticsResponseDto> {
|
searchAssetStatistics(@Auth() auth: AuthDto, @Body() dto: StatisticsSearchDto): Promise<SearchStatisticsResponseDto> {
|
||||||
return this.service.searchStatistics(auth, dto);
|
return this.service.searchStatistics(auth, dto);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Post('random')
|
@Post('random')
|
||||||
@Authenticated({ permission: Permission.AssetRead })
|
|
||||||
@HttpCode(HttpStatus.OK)
|
@HttpCode(HttpStatus.OK)
|
||||||
|
@Authenticated({ permission: Permission.AssetRead })
|
||||||
searchRandom(@Auth() auth: AuthDto, @Body() dto: RandomSearchDto): Promise<AssetResponseDto[]> {
|
searchRandom(@Auth() auth: AuthDto, @Body() dto: RandomSearchDto): Promise<AssetResponseDto[]> {
|
||||||
return this.service.searchRandom(auth, dto);
|
return this.service.searchRandom(auth, dto);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Post('large-assets')
|
@Post('large-assets')
|
||||||
@Authenticated({ permission: Permission.AssetRead })
|
|
||||||
@HttpCode(HttpStatus.OK)
|
@HttpCode(HttpStatus.OK)
|
||||||
|
@Authenticated({ permission: Permission.AssetRead })
|
||||||
searchLargeAssets(@Auth() auth: AuthDto, @Query() dto: LargeAssetSearchDto): Promise<AssetResponseDto[]> {
|
searchLargeAssets(@Auth() auth: AuthDto, @Query() dto: LargeAssetSearchDto): Promise<AssetResponseDto[]> {
|
||||||
return this.service.searchLargeAssets(auth, dto);
|
return this.service.searchLargeAssets(auth, dto);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Post('smart')
|
@Post('smart')
|
||||||
@Authenticated({ permission: Permission.AssetRead })
|
|
||||||
@HttpCode(HttpStatus.OK)
|
@HttpCode(HttpStatus.OK)
|
||||||
|
@Authenticated({ permission: Permission.AssetRead })
|
||||||
searchSmart(@Auth() auth: AuthDto, @Body() dto: SmartSearchDto): Promise<SearchResponseDto> {
|
searchSmart(@Auth() auth: AuthDto, @Body() dto: SmartSearchDto): Promise<SearchResponseDto> {
|
||||||
return this.service.searchSmart(auth, dto);
|
return this.service.searchSmart(auth, dto);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { Body, Controller, Delete, Get, HttpCode, HttpStatus, Put } from '@nestjs/common';
|
import { Body, Controller, Delete, Get, Put } from '@nestjs/common';
|
||||||
import { ApiNotFoundResponse, ApiTags } from '@nestjs/swagger';
|
import { ApiNotFoundResponse, ApiTags } from '@nestjs/swagger';
|
||||||
import { LicenseKeyDto, LicenseResponseDto } from 'src/dtos/license.dto';
|
import { LicenseKeyDto, LicenseResponseDto } from 'src/dtos/license.dto';
|
||||||
import {
|
import {
|
||||||
@@ -104,7 +104,6 @@ export class ServerController {
|
|||||||
|
|
||||||
@Delete('license')
|
@Delete('license')
|
||||||
@Authenticated({ permission: Permission.ServerLicenseDelete, admin: true })
|
@Authenticated({ permission: Permission.ServerLicenseDelete, admin: true })
|
||||||
@HttpCode(HttpStatus.NO_CONTENT)
|
|
||||||
deleteServerLicense(): Promise<void> {
|
deleteServerLicense(): Promise<void> {
|
||||||
return this.service.deleteLicense();
|
return this.service.deleteLicense();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,18 +1,4 @@
|
|||||||
import {
|
import { Body, Controller, Delete, Get, Param, Patch, Post, Put, Query, Req, Res } from '@nestjs/common';
|
||||||
Body,
|
|
||||||
Controller,
|
|
||||||
Delete,
|
|
||||||
Get,
|
|
||||||
HttpCode,
|
|
||||||
HttpStatus,
|
|
||||||
Param,
|
|
||||||
Patch,
|
|
||||||
Post,
|
|
||||||
Put,
|
|
||||||
Query,
|
|
||||||
Req,
|
|
||||||
Res,
|
|
||||||
} from '@nestjs/common';
|
|
||||||
import { ApiTags } from '@nestjs/swagger';
|
import { ApiTags } from '@nestjs/swagger';
|
||||||
import { Request, Response } from 'express';
|
import { Request, Response } from 'express';
|
||||||
import { AssetIdsResponseDto } from 'src/dtos/asset-ids.response.dto';
|
import { AssetIdsResponseDto } from 'src/dtos/asset-ids.response.dto';
|
||||||
@@ -87,7 +73,6 @@ export class SharedLinkController {
|
|||||||
|
|
||||||
@Delete(':id')
|
@Delete(':id')
|
||||||
@Authenticated({ permission: Permission.SharedLinkDelete })
|
@Authenticated({ permission: Permission.SharedLinkDelete })
|
||||||
@HttpCode(HttpStatus.NO_CONTENT)
|
|
||||||
removeSharedLink(@Auth() auth: AuthDto, @Param() { id }: UUIDParamDto): Promise<void> {
|
removeSharedLink(@Auth() auth: AuthDto, @Param() { id }: UUIDParamDto): Promise<void> {
|
||||||
return this.service.remove(auth, id);
|
return this.service.remove(auth, id);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,8 +49,8 @@ export class StackController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Delete(':id')
|
@Delete(':id')
|
||||||
@Authenticated({ permission: Permission.StackDelete })
|
|
||||||
@HttpCode(HttpStatus.NO_CONTENT)
|
@HttpCode(HttpStatus.NO_CONTENT)
|
||||||
|
@Authenticated({ permission: Permission.StackDelete })
|
||||||
deleteStack(@Auth() auth: AuthDto, @Param() { id }: UUIDParamDto): Promise<void> {
|
deleteStack(@Auth() auth: AuthDto, @Param() { id }: UUIDParamDto): Promise<void> {
|
||||||
return this.service.delete(auth, id);
|
return this.service.delete(auth, id);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,23 +26,23 @@ export class SyncController {
|
|||||||
) {}
|
) {}
|
||||||
|
|
||||||
@Post('full-sync')
|
@Post('full-sync')
|
||||||
@Authenticated()
|
|
||||||
@HttpCode(HttpStatus.OK)
|
@HttpCode(HttpStatus.OK)
|
||||||
|
@Authenticated()
|
||||||
getFullSyncForUser(@Auth() auth: AuthDto, @Body() dto: AssetFullSyncDto): Promise<AssetResponseDto[]> {
|
getFullSyncForUser(@Auth() auth: AuthDto, @Body() dto: AssetFullSyncDto): Promise<AssetResponseDto[]> {
|
||||||
return this.service.getFullSync(auth, dto);
|
return this.service.getFullSync(auth, dto);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Post('delta-sync')
|
@Post('delta-sync')
|
||||||
@Authenticated()
|
|
||||||
@HttpCode(HttpStatus.OK)
|
@HttpCode(HttpStatus.OK)
|
||||||
|
@Authenticated()
|
||||||
getDeltaSync(@Auth() auth: AuthDto, @Body() dto: AssetDeltaSyncDto): Promise<AssetDeltaSyncResponseDto> {
|
getDeltaSync(@Auth() auth: AuthDto, @Body() dto: AssetDeltaSyncDto): Promise<AssetDeltaSyncResponseDto> {
|
||||||
return this.service.getDeltaSync(auth, dto);
|
return this.service.getDeltaSync(auth, dto);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Post('stream')
|
@Post('stream')
|
||||||
@Authenticated({ permission: Permission.SyncStream })
|
|
||||||
@Header('Content-Type', 'application/jsonlines+json')
|
@Header('Content-Type', 'application/jsonlines+json')
|
||||||
@HttpCode(HttpStatus.OK)
|
@HttpCode(HttpStatus.OK)
|
||||||
|
@Authenticated({ permission: Permission.SyncStream })
|
||||||
async getSyncStream(@Auth() auth: AuthDto, @Res() res: Response, @Body() dto: SyncStreamDto) {
|
async getSyncStream(@Auth() auth: AuthDto, @Res() res: Response, @Body() dto: SyncStreamDto) {
|
||||||
try {
|
try {
|
||||||
await this.service.stream(auth, res, dto);
|
await this.service.stream(auth, res, dto);
|
||||||
@@ -59,16 +59,16 @@ export class SyncController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Post('ack')
|
@Post('ack')
|
||||||
@Authenticated({ permission: Permission.SyncCheckpointUpdate })
|
|
||||||
@HttpCode(HttpStatus.NO_CONTENT)
|
@HttpCode(HttpStatus.NO_CONTENT)
|
||||||
|
@Authenticated({ permission: Permission.SyncCheckpointUpdate })
|
||||||
sendSyncAck(@Auth() auth: AuthDto, @Body() dto: SyncAckSetDto) {
|
sendSyncAck(@Auth() auth: AuthDto, @Body() dto: SyncAckSetDto) {
|
||||||
return this.service.setAcks(auth, dto);
|
return this.service.setAcks(auth, dto);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Delete('ack')
|
@Delete('ack')
|
||||||
@Authenticated({ permission: Permission.SyncCheckpointDelete })
|
|
||||||
@HttpCode(HttpStatus.NO_CONTENT)
|
@HttpCode(HttpStatus.NO_CONTENT)
|
||||||
deleteSyncAck(@Auth() auth: AuthDto, @Body() dto: SyncAckDeleteDto): Promise<void> {
|
@Authenticated({ permission: Permission.SyncCheckpointDelete })
|
||||||
|
deleteSyncAck(@Auth() auth: AuthDto, @Body() dto: SyncAckDeleteDto) {
|
||||||
return this.service.deleteAcks(auth, dto);
|
return this.service.deleteAcks(auth, dto);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,8 +21,8 @@ export class SystemMetadataController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Post('admin-onboarding')
|
@Post('admin-onboarding')
|
||||||
@Authenticated({ permission: Permission.SystemMetadataUpdate, admin: true })
|
|
||||||
@HttpCode(HttpStatus.NO_CONTENT)
|
@HttpCode(HttpStatus.NO_CONTENT)
|
||||||
|
@Authenticated({ permission: Permission.SystemMetadataUpdate, admin: true })
|
||||||
updateAdminOnboarding(@Body() dto: AdminOnboardingUpdateDto): Promise<void> {
|
updateAdminOnboarding(@Body() dto: AdminOnboardingUpdateDto): Promise<void> {
|
||||||
return this.service.updateAdminOnboarding(dto);
|
return this.service.updateAdminOnboarding(dto);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -57,8 +57,8 @@ export class TagController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Delete(':id')
|
@Delete(':id')
|
||||||
@Authenticated({ permission: Permission.TagDelete })
|
|
||||||
@HttpCode(HttpStatus.NO_CONTENT)
|
@HttpCode(HttpStatus.NO_CONTENT)
|
||||||
|
@Authenticated({ permission: Permission.TagDelete })
|
||||||
deleteTag(@Auth() auth: AuthDto, @Param() { id }: UUIDParamDto): Promise<void> {
|
deleteTag(@Auth() auth: AuthDto, @Param() { id }: UUIDParamDto): Promise<void> {
|
||||||
return this.service.remove(auth, id);
|
return this.service.remove(auth, id);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,22 +13,22 @@ export class TrashController {
|
|||||||
constructor(private service: TrashService) {}
|
constructor(private service: TrashService) {}
|
||||||
|
|
||||||
@Post('empty')
|
@Post('empty')
|
||||||
@Authenticated({ permission: Permission.AssetDelete })
|
|
||||||
@HttpCode(HttpStatus.OK)
|
@HttpCode(HttpStatus.OK)
|
||||||
|
@Authenticated({ permission: Permission.AssetDelete })
|
||||||
emptyTrash(@Auth() auth: AuthDto): Promise<TrashResponseDto> {
|
emptyTrash(@Auth() auth: AuthDto): Promise<TrashResponseDto> {
|
||||||
return this.service.empty(auth);
|
return this.service.empty(auth);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Post('restore')
|
@Post('restore')
|
||||||
@Authenticated({ permission: Permission.AssetDelete })
|
|
||||||
@HttpCode(HttpStatus.OK)
|
@HttpCode(HttpStatus.OK)
|
||||||
|
@Authenticated({ permission: Permission.AssetDelete })
|
||||||
restoreTrash(@Auth() auth: AuthDto): Promise<TrashResponseDto> {
|
restoreTrash(@Auth() auth: AuthDto): Promise<TrashResponseDto> {
|
||||||
return this.service.restore(auth);
|
return this.service.restore(auth);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Post('restore/assets')
|
@Post('restore/assets')
|
||||||
@Authenticated({ permission: Permission.AssetDelete })
|
|
||||||
@HttpCode(HttpStatus.OK)
|
@HttpCode(HttpStatus.OK)
|
||||||
|
@Authenticated({ permission: Permission.AssetDelete })
|
||||||
restoreAssets(@Auth() auth: AuthDto, @Body() dto: BulkIdsDto): Promise<TrashResponseDto> {
|
restoreAssets(@Auth() auth: AuthDto, @Body() dto: BulkIdsDto): Promise<TrashResponseDto> {
|
||||||
return this.service.restoreAssets(auth, dto);
|
return this.service.restoreAssets(auth, dto);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -84,7 +84,6 @@ export class UserController {
|
|||||||
|
|
||||||
@Delete('me/license')
|
@Delete('me/license')
|
||||||
@Authenticated({ permission: Permission.UserLicenseDelete })
|
@Authenticated({ permission: Permission.UserLicenseDelete })
|
||||||
@HttpCode(HttpStatus.NO_CONTENT)
|
|
||||||
async deleteUserLicense(@Auth() auth: AuthDto): Promise<void> {
|
async deleteUserLicense(@Auth() auth: AuthDto): Promise<void> {
|
||||||
await this.service.deleteLicense(auth);
|
await this.service.deleteLicense(auth);
|
||||||
}
|
}
|
||||||
@@ -103,7 +102,6 @@ export class UserController {
|
|||||||
|
|
||||||
@Delete('me/onboarding')
|
@Delete('me/onboarding')
|
||||||
@Authenticated({ permission: Permission.UserOnboardingDelete })
|
@Authenticated({ permission: Permission.UserOnboardingDelete })
|
||||||
@HttpCode(HttpStatus.NO_CONTENT)
|
|
||||||
async deleteUserOnboarding(@Auth() auth: AuthDto): Promise<void> {
|
async deleteUserOnboarding(@Auth() auth: AuthDto): Promise<void> {
|
||||||
await this.service.deleteOnboarding(auth);
|
await this.service.deleteOnboarding(auth);
|
||||||
}
|
}
|
||||||
@@ -114,11 +112,11 @@ export class UserController {
|
|||||||
return this.service.get(id);
|
return this.service.get(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Post('profile-image')
|
|
||||||
@Authenticated({ permission: Permission.UserProfileImageUpdate })
|
|
||||||
@UseInterceptors(FileUploadInterceptor)
|
@UseInterceptors(FileUploadInterceptor)
|
||||||
@ApiConsumes('multipart/form-data')
|
@ApiConsumes('multipart/form-data')
|
||||||
@ApiBody({ description: 'A new avatar for the user', type: CreateProfileImageDto })
|
@ApiBody({ description: 'A new avatar for the user', type: CreateProfileImageDto })
|
||||||
|
@Post('profile-image')
|
||||||
|
@Authenticated({ permission: Permission.UserProfileImageUpdate })
|
||||||
createProfileImage(
|
createProfileImage(
|
||||||
@Auth() auth: AuthDto,
|
@Auth() auth: AuthDto,
|
||||||
@UploadedFile() fileInfo: Express.Multer.File,
|
@UploadedFile() fileInfo: Express.Multer.File,
|
||||||
@@ -127,8 +125,8 @@ export class UserController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Delete('profile-image')
|
@Delete('profile-image')
|
||||||
@Authenticated({ permission: Permission.UserProfileImageDelete })
|
|
||||||
@HttpCode(HttpStatus.NO_CONTENT)
|
@HttpCode(HttpStatus.NO_CONTENT)
|
||||||
|
@Authenticated({ permission: Permission.UserProfileImageDelete })
|
||||||
deleteProfileImage(@Auth() auth: AuthDto): Promise<void> {
|
deleteProfileImage(@Auth() auth: AuthDto): Promise<void> {
|
||||||
return this.service.deleteProfileImage(auth);
|
return this.service.deleteProfileImage(auth);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -235,8 +235,6 @@ export enum Permission {
|
|||||||
AdminUserRead = 'adminUser.read',
|
AdminUserRead = 'adminUser.read',
|
||||||
AdminUserUpdate = 'adminUser.update',
|
AdminUserUpdate = 'adminUser.update',
|
||||||
AdminUserDelete = 'adminUser.delete',
|
AdminUserDelete = 'adminUser.delete',
|
||||||
|
|
||||||
AdminAuthUnlinkAll = 'adminAuth.unlinkAll',
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum SharedLinkType {
|
export enum SharedLinkType {
|
||||||
|
|||||||
@@ -194,10 +194,6 @@ export class UserRepository {
|
|||||||
.executeTakeFirstOrThrow();
|
.executeTakeFirstOrThrow();
|
||||||
}
|
}
|
||||||
|
|
||||||
async updateAll(dto: Updateable<UserTable>) {
|
|
||||||
await this.db.updateTable('user').set(dto).execute();
|
|
||||||
}
|
|
||||||
|
|
||||||
restore(id: string) {
|
restore(id: string) {
|
||||||
return this.db
|
return this.db
|
||||||
.updateTable('user')
|
.updateTable('user')
|
||||||
|
|||||||
@@ -1,11 +0,0 @@
|
|||||||
import { Injectable } from '@nestjs/common';
|
|
||||||
import { AuthDto } from 'src/dtos/auth.dto';
|
|
||||||
import { BaseService } from 'src/services/base.service';
|
|
||||||
|
|
||||||
@Injectable()
|
|
||||||
export class AuthAdminService extends BaseService {
|
|
||||||
async unlinkAll(_auth: AuthDto) {
|
|
||||||
// TODO replace '' with null
|
|
||||||
await this.userRepository.updateAll({ oauthId: '' });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -5,7 +5,6 @@ import { ApiService } from 'src/services/api.service';
|
|||||||
import { AssetMediaService } from 'src/services/asset-media.service';
|
import { AssetMediaService } from 'src/services/asset-media.service';
|
||||||
import { AssetService } from 'src/services/asset.service';
|
import { AssetService } from 'src/services/asset.service';
|
||||||
import { AuditService } from 'src/services/audit.service';
|
import { AuditService } from 'src/services/audit.service';
|
||||||
import { AuthAdminService } from 'src/services/auth-admin.service';
|
|
||||||
import { AuthService } from 'src/services/auth.service';
|
import { AuthService } from 'src/services/auth.service';
|
||||||
import { BackupService } from 'src/services/backup.service';
|
import { BackupService } from 'src/services/backup.service';
|
||||||
import { CliService } from 'src/services/cli.service';
|
import { CliService } from 'src/services/cli.service';
|
||||||
@@ -50,7 +49,6 @@ export const services = [
|
|||||||
AssetService,
|
AssetService,
|
||||||
AuditService,
|
AuditService,
|
||||||
AuthService,
|
AuthService,
|
||||||
AuthAdminService,
|
|
||||||
BackupService,
|
BackupService,
|
||||||
CliService,
|
CliService,
|
||||||
DatabaseService,
|
DatabaseService,
|
||||||
|
|||||||
@@ -62,23 +62,6 @@ describe('compareColumns', () => {
|
|||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should detect a change in default', () => {
|
|
||||||
const source: DatabaseColumn = { ...testColumn, nullable: true };
|
|
||||||
const target: DatabaseColumn = { ...testColumn, nullable: true, default: "''" };
|
|
||||||
const reason = `default is different (null vs '')`;
|
|
||||||
expect(compareColumns.onCompare(source, target)).toEqual([
|
|
||||||
{
|
|
||||||
columnName: 'test',
|
|
||||||
tableName: 'table1',
|
|
||||||
type: 'ColumnAlter',
|
|
||||||
changes: {
|
|
||||||
default: 'NULL',
|
|
||||||
},
|
|
||||||
reason,
|
|
||||||
},
|
|
||||||
]);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should detect a comment change', () => {
|
it('should detect a comment change', () => {
|
||||||
const source: DatabaseColumn = { ...testColumn, comment: 'new comment' };
|
const source: DatabaseColumn = { ...testColumn, comment: 'new comment' };
|
||||||
const target: DatabaseColumn = { ...testColumn, comment: 'old comment' };
|
const target: DatabaseColumn = { ...testColumn, comment: 'old comment' };
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user