mirror of
https://github.com/immich-app/immich.git
synced 2025-05-24 01:12:58 -04:00
fix(mobile): hide asset description text field if user is not owner (#17442)
* fix(mobile): hide asset description text field if user is not owner * If user is not the owner and asset has no description then hide the text field * Apply suggestions from code review Co-authored-by: Alex <alex.tran1502@gmail.com> --------- Co-authored-by: Alex <alex.tran1502@gmail.com>
This commit is contained in:
parent
fdbe6d649f
commit
75bc32b47b
@ -34,17 +34,24 @@ class DescriptionInput extends HookConsumerWidget {
|
|||||||
final owner = ref.watch(currentUserProvider);
|
final owner = ref.watch(currentUserProvider);
|
||||||
final hasError = useState(false);
|
final hasError = useState(false);
|
||||||
final assetWithExif = ref.watch(assetDetailProvider(asset));
|
final assetWithExif = ref.watch(assetDetailProvider(asset));
|
||||||
|
final hasDescription = useState(false);
|
||||||
|
final isOwner = fastHash(owner?.id ?? '') == asset.ownerId;
|
||||||
|
|
||||||
useEffect(
|
useEffect(
|
||||||
() {
|
() {
|
||||||
assetService
|
assetService.getDescription(asset).then((value) {
|
||||||
.getDescription(asset)
|
controller.text = value;
|
||||||
.then((value) => controller.text = value);
|
hasDescription.value = value.isNotEmpty;
|
||||||
|
});
|
||||||
return null;
|
return null;
|
||||||
},
|
},
|
||||||
[assetWithExif.value],
|
[assetWithExif.value],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (!isOwner && !hasDescription.value) {
|
||||||
|
return const SizedBox.shrink();
|
||||||
|
}
|
||||||
|
|
||||||
submitDescription(String description) async {
|
submitDescription(String description) async {
|
||||||
hasError.value = false;
|
hasError.value = false;
|
||||||
try {
|
try {
|
||||||
@ -82,7 +89,7 @@ class DescriptionInput extends HookConsumerWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return TextField(
|
return TextField(
|
||||||
enabled: fastHash(owner?.id ?? '') == asset.ownerId,
|
enabled: isOwner,
|
||||||
focusNode: focusNode,
|
focusNode: focusNode,
|
||||||
onTap: () => isFocus.value = true,
|
onTap: () => isFocus.value = true,
|
||||||
onChanged: (value) {
|
onChanged: (value) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user