Skip to content

Commit 75bc32b

Browse files
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 <[email protected]> --------- Co-authored-by: Alex <[email protected]>
1 parent fdbe6d6 commit 75bc32b

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

mobile/lib/widgets/asset_viewer/description_input.dart

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,17 +34,24 @@ class DescriptionInput extends HookConsumerWidget {
3434
final owner = ref.watch(currentUserProvider);
3535
final hasError = useState(false);
3636
final assetWithExif = ref.watch(assetDetailProvider(asset));
37+
final hasDescription = useState(false);
38+
final isOwner = fastHash(owner?.id ?? '') == asset.ownerId;
3739

3840
useEffect(
3941
() {
40-
assetService
41-
.getDescription(asset)
42-
.then((value) => controller.text = value);
42+
assetService.getDescription(asset).then((value) {
43+
controller.text = value;
44+
hasDescription.value = value.isNotEmpty;
45+
});
4346
return null;
4447
},
4548
[assetWithExif.value],
4649
);
4750

51+
if (!isOwner && !hasDescription.value) {
52+
return const SizedBox.shrink();
53+
}
54+
4855
submitDescription(String description) async {
4956
hasError.value = false;
5057
try {
@@ -82,7 +89,7 @@ class DescriptionInput extends HookConsumerWidget {
8289
}
8390

8491
return TextField(
85-
enabled: fastHash(owner?.id ?? '') == asset.ownerId,
92+
enabled: isOwner,
8693
focusNode: focusNode,
8794
onTap: () => isFocus.value = true,
8895
onChanged: (value) {

0 commit comments

Comments
 (0)