-
Notifications
You must be signed in to change notification settings - Fork 173
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hide join call button when the user is already in the call #3815
Changes from 4 commits
58e6696
1c78f96
12e7172
4c96628
2b5acb3
db4b4d3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* | ||
* Copyright 2024 New Vector Ltd. | ||
* | ||
* SPDX-License-Identifier: AGPL-3.0-only | ||
* Please see LICENSE in the repository root for full details. | ||
*/ | ||
|
||
package io.element.android.features.call.api | ||
|
||
import io.element.android.libraries.matrix.api.core.RoomId | ||
|
||
/** | ||
* Value for the local current call. | ||
*/ | ||
sealed interface CurrentCall { | ||
data object None : CurrentCall | ||
|
||
data class RoomCall( | ||
val roomId: RoomId, | ||
) : CurrentCall | ||
|
||
data class ExternalUrl( | ||
val url: String, | ||
Check warning on line 23 in features/call/api/src/main/kotlin/io/element/android/features/call/api/CurrentCall.kt Codecov / codecov/patchfeatures/call/api/src/main/kotlin/io/element/android/features/call/api/CurrentCall.kt#L22-L23
|
||
) : CurrentCall | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/* | ||
* Copyright 2024 New Vector Ltd. | ||
* | ||
* SPDX-License-Identifier: AGPL-3.0-only | ||
* Please see LICENSE in the repository root for full details. | ||
*/ | ||
|
||
package io.element.android.features.call.api | ||
|
||
import kotlinx.coroutines.flow.StateFlow | ||
|
||
interface CurrentCallObserver { | ||
/** | ||
* The current call state flow, which will be updated when the active call changes. | ||
* This value reflect the local state of the call. It is not updated if the user answers | ||
* a call from another session. | ||
*/ | ||
val currentCall: StateFlow<CurrentCall> | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* | ||
* Copyright 2024 New Vector Ltd. | ||
* | ||
* SPDX-License-Identifier: AGPL-3.0-only | ||
* Please see LICENSE in the repository root for full details. | ||
*/ | ||
|
||
package io.element.android.features.call.impl.utils | ||
|
||
import com.squareup.anvil.annotations.ContributesBinding | ||
import io.element.android.features.call.api.CurrentCall | ||
import io.element.android.features.call.api.CurrentCallObserver | ||
import io.element.android.libraries.di.AppScope | ||
import io.element.android.libraries.di.SingleIn | ||
import kotlinx.coroutines.flow.MutableStateFlow | ||
import javax.inject.Inject | ||
|
||
@SingleIn(AppScope::class) | ||
@ContributesBinding(AppScope::class) | ||
class DefaultCurrentCallObserver @Inject constructor() : CurrentCallObserver { | ||
override val currentCall = MutableStateFlow<CurrentCall>(CurrentCall.None) | ||
|
||
fun onCallStarted(call: CurrentCall) { | ||
currentCall.value = call | ||
} | ||
|
||
fun onCallEnded() { | ||
currentCall.value = CurrentCall.None | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/* | ||
* Copyright 2024 New Vector Ltd. | ||
* | ||
* SPDX-License-Identifier: AGPL-3.0-only | ||
* Please see LICENSE in the repository root for full details. | ||
*/ | ||
|
||
package io.element.android.features.call.test | ||
|
||
import io.element.android.features.call.api.CurrentCall | ||
import io.element.android.features.call.api.CurrentCallObserver | ||
import kotlinx.coroutines.flow.MutableStateFlow | ||
|
||
class FakeCurrentCallObserver( | ||
initialValue: CurrentCall = CurrentCall.None, | ||
) : CurrentCallObserver { | ||
override val currentCall = MutableStateFlow(initialValue) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Usually when we have There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
||
fun setCurrentCall(value: CurrentCall) { | ||
currentCall.value = value | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The name is a bit weird, the observer is the one who subscribe to the flow usually, not the one providing.
I'd call this CurrentCallService or CurrentCallDataSource for exemple
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2b5acb3