Skip to content

Commit 3d0e38f

Browse files
committed
Disable linked device edit/remove for non-primary devices
Fixes #647
1 parent 55bf67e commit 3d0e38f

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

app/src/main/java/org/thoughtcrime/securesms/linkdevice/LinkDeviceFragment.kt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,7 @@ fun DeviceListScreen(
450450
)
451451
} else {
452452
state.devices.forEach { device ->
453-
DeviceRow(device, onDeviceSelectedForRemoval, onEditDevice)
453+
DeviceRow(device, onDeviceSelectedForRemoval, onEditDevice, canLinkDevices = state.canLinkDevices)
454454
}
455455
}
456456
}
@@ -494,7 +494,7 @@ fun DeviceListScreen(
494494
}
495495

496496
@Composable
497-
fun DeviceRow(device: Device, setDeviceToRemove: (Device) -> Unit, onEditDevice: (Device) -> Unit) {
497+
fun DeviceRow(device: Device, setDeviceToRemove: (Device) -> Unit, onEditDevice: (Device) -> Unit, canLinkDevices: Boolean) {
498498
val titleString = if (device.name.isNullOrEmpty()) stringResource(R.string.DeviceListItem_unnamed_device) else device.name
499499
val linkedDate = device.createdMillis?.let { DateUtils.getDayPrecisionTimeSpanString(LocalContext.current, Locale.getDefault(), device.createdMillis) }
500500
val lastActive = DateUtils.getDayPrecisionTimeSpanString(LocalContext.current, Locale.getDefault(), device.lastSeenMillis)
@@ -559,6 +559,7 @@ fun DeviceRow(device: Device, setDeviceToRemove: (Device) -> Unit, onEditDevice:
559559
)
560560
}
561561
},
562+
enabled = canLinkDevices,
562563
onClick = {
563564
setDeviceToRemove(device)
564565
controller.hide()
@@ -583,7 +584,7 @@ fun DeviceRow(device: Device, setDeviceToRemove: (Device) -> Unit, onEditDevice:
583584
)
584585
}
585586
},
586-
enabled = device.canRename,
587+
enabled = device.canRename && canLinkDevices,
587588
onClick = {
588589
onEditDevice(device)
589590
controller.hide()

0 commit comments

Comments
 (0)