Skip to content

Commit

Permalink
Get Reset (truly "Reconnect") button working
Browse files Browse the repository at this point in the history
I can't find out how to soft-reset the session,
so I am just hard-resetting it by disconnecting and reconnecting.
  • Loading branch information
paulpv committed Jan 23, 2025
1 parent f2837a0 commit 9d56f3f
Showing 1 changed file with 10 additions and 14 deletions.
24 changes: 10 additions & 14 deletions mobile/src/main/java/com/swooby/alfredai/PushToTalkActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,11 @@ fun PushToTalkScreen(pushToTalkViewModel: PushToTalkViewModel? = null) {
val debugForceDontAutoConnect = BuildConfig.DEBUG && false
@Suppress(
"SimplifyBooleanWithConstants",
"KotlinConstantConditions",
"KotlinConstantConditions")
val debugConnectDelayMillis = if (BuildConfig.DEBUG && false) 10_000L else 0L
@Suppress(
"SimplifyBooleanWithConstants",
//"KotlinConstantConditions",
)
val debugLogConversation = BuildConfig.DEBUG && true
@Suppress(
Expand Down Expand Up @@ -249,11 +253,8 @@ fun PushToTalkScreen(pushToTalkViewModel: PushToTalkViewModel? = null) {
isConnectingOrConnected = true
conversationItems.clear()
jobConnect = CoroutineScope(Dispatchers.IO).launch {
@Suppress("SimplifyBooleanWithConstants", "KotlinConstantConditions")
val debugDelay = BuildConfig.DEBUG && false
@Suppress("KotlinConstantConditions")
if (debugDelay) {
delay(10_000)
if (debugConnectDelayMillis > 0) {
delay(debugConnectDelayMillis)
}
val ephemeralApiKey = realtimeClient.connect()
Log.d(TAG, "ephemeralApiKey: $ephemeralApiKey")
Expand Down Expand Up @@ -921,14 +922,9 @@ fun PushToTalkScreen(pushToTalkViewModel: PushToTalkViewModel? = null) {
IconButton(
enabled = isConnected && !isCancelingResponse,
onClick = {
if (true) {
showToast(context, "Reset Not Yet Implemented", Toast.LENGTH_SHORT)
} else {
pushToTalkViewModel?.realtimeClient?.also { realtimeClient ->
realtimeClient.dataSendInputAudioBufferClear()
}
conversationItems.clear()
}
disconnect()
connect()
showToast(context = context, text = "Reconnecting", forceInvokeOnMain = true)
},
modifier = Modifier
.size(66.dp)
Expand Down

0 comments on commit 9d56f3f

Please sign in to comment.