@@ -66,18 +66,21 @@ internal fun HistoryCard(
6666 val canExpand = ! entry.success && ! entry.errorMessage.isNullOrBlank()
6767 val clipboardManager = LocalClipboardManager .current
6868 val context = LocalContext .current
69+
70+ val launchIntent = remember(entry.packageName) {
71+ if (entry.success) context.packageManager.getLaunchIntentForPackage(entry.packageName) else null
72+ }
6973
7074 Card (
7175 modifier = modifier
7276 .fillMaxWidth()
7377 .animateContentSize()
7478 .clip(MaterialTheme .shapes.large)
7579 .background(MaterialTheme .colorScheme.surfaceContainerLow)
76- .clickable(enabled = if (entry.success) true else canExpand) {
80+ .clickable(enabled = if (entry.success) launchIntent != null else canExpand) {
7781 if (entry.success) {
78- val intent = context.packageManager.getLaunchIntentForPackage(entry.packageName)
79- if (intent != null ) {
80- context.startActivity(intent)
82+ if (launchIntent != null ) {
83+ context.startActivity(launchIntent)
8184 } else {
8285 Toast .makeText(context, " Cannot open app" , Toast .LENGTH_SHORT ).show()
8386 }
@@ -152,15 +155,10 @@ internal fun HistoryCard(
152155 }
153156
154157 // Status badge / Open button
155- if (entry.success) {
158+ if (entry.success && launchIntent != null ) {
156159 IconButton (
157160 onClick = {
158- val intent = context.packageManager.getLaunchIntentForPackage(entry.packageName)
159- if (intent != null ) {
160- context.startActivity(intent)
161- } else {
162- Toast .makeText(context, " Cannot open app" , Toast .LENGTH_SHORT ).show()
163- }
161+ context.startActivity(launchIntent)
164162 },
165163 modifier = Modifier .size(36 .dp)
166164 ) {
0 commit comments