Skip to content

Commit

Permalink
fix calendar di
Browse files Browse the repository at this point in the history
  • Loading branch information
crc-32 committed Nov 12, 2024
1 parent 39192af commit af16a4e
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 10 deletions.
3 changes: 2 additions & 1 deletion android/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ android.defaults.buildfeatures.buildconfig=true
android.nonTransitiveRClass=false
android.nonFinalResIds=false
kotlin.code.style=official
kotlin.native.disableCompilerDaemon = true
kotlin.native.disableCompilerDaemon = true
kapt.use.k2=false
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ val androidModule = module {
single { AndroidJobScheduler() }
single { FlutterPreferences() }
singleOf<PlatformNotificationActionExecutor>(::AndroidNotificationActionExecutor)
singleOf<PlatformCalendarActionExecutor>(::AndroidCalendarActionExecutor)
factory<PlatformCalendarActionExecutor> { params ->
AndroidCalendarActionExecutor(params.get())
}

factory<Set<CobbleHandler>>(named("deviceHandlers")) { params ->
val pebbleDevice: PebbleDevice = params.get()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,9 @@ import org.koin.core.component.KoinComponent
import org.koin.core.component.inject
import kotlin.time.Duration.Companion.days

class AndroidCalendarActionExecutor: PlatformCalendarActionExecutor, KoinComponent {
class AndroidCalendarActionExecutor(private val watchTimelineSyncer: WatchTimelineSyncer): PlatformCalendarActionExecutor, KoinComponent {
private val platformContext: PlatformContext by inject()
private val calendarDao: CalendarDao by inject()
private val watchTimelineSyncer: WatchTimelineSyncer by inject()

override suspend fun handlePlatformAction(action: CalendarAction, pin: TimelinePin): TimelineService.ActionResponse {
val instanceId = pin.backingId ?: run {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ import org.koin.dsl.module

val calendarModule = module {
singleOf(::PhoneCalendarSyncer)
singleOf(::WatchTimelineSyncer)
singleOf(::TimelineActionManager)
factory { params ->
TimelineActionManager(params.get())
}
single {
CalendarSync(CoroutineScope(SupervisorJob() + get<GlobalExceptionHandler>() + CoroutineName("CalendarSync")))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import io.rebble.cobble.shared.Logging
import io.rebble.cobble.shared.domain.appmessage.AppMessageTransactionSequence
import io.rebble.cobble.shared.domain.state.ConnectionState
import io.rebble.cobble.shared.domain.state.ConnectionStateManager
import io.rebble.cobble.shared.domain.timeline.TimelineActionManager
import io.rebble.cobble.shared.domain.voice.VoiceSession
import io.rebble.cobble.shared.handlers.CobbleHandler
import io.rebble.cobble.shared.handlers.OutgoingMessage
Expand Down Expand Up @@ -80,6 +81,7 @@ open class PebbleDevice(
val audioStreamService: AudioStreamService by inject {parametersOf(protocolHandler)}

val putBytesController: PutBytesController by inject {parametersOf(this)}
val timelineActionManager: TimelineActionManager by inject {parametersOf(this)}

override fun close() {
negotiationScope.cancel("PebbleDevice closed")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package io.rebble.cobble.shared.handlers

import com.benasher44.uuid.Uuid
import io.ktor.http.parametersOf
import io.rebble.cobble.shared.Logging
import io.rebble.cobble.shared.database.NextSyncAction
import io.rebble.cobble.shared.database.dao.TimelinePinDao
Expand All @@ -17,16 +18,16 @@ import kotlinx.coroutines.flow.*
import kotlinx.coroutines.launch
import org.koin.core.component.KoinComponent
import org.koin.core.component.inject
import org.koin.core.parameter.parametersOf

class CalendarActionHandler(private val pebbleDevice: PebbleDevice): KoinComponent, CobbleHandler {
private val timelineActionManager: TimelineActionManager by inject()
private val timelineActionManager = pebbleDevice.timelineActionManager
private val timelinePinDao: TimelinePinDao by inject()
private val calendarActionExecutor: PlatformCalendarActionExecutor by inject()
private val timelineSyncer = WatchTimelineSyncer(pebbleDevice.blobDBService)
private val calendarActionExecutor: PlatformCalendarActionExecutor by inject() { parametersOf(timelineSyncer) }

private val calendarActionFlow = timelineActionManager.actionFlowForApp(calendarWatchappId)

private val timelineSyncer = WatchTimelineSyncer(pebbleDevice.blobDBService)

init {
pebbleDevice.negotiationScope.launch {
val deviceScope = pebbleDevice.connectionScope.filterNotNull().first()
Expand Down

0 comments on commit af16a4e

Please sign in to comment.