-
Notifications
You must be signed in to change notification settings - Fork 0
feat(tabgroup): remove people from a group & handle being removed from a group #339
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
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
b54d63a
fix(tabgroup): keep former members in the money
DennisBauer 167dd47
feat(tabgroup): add removeParticipant to the data layer
DennisBauer 6259be2
feat(tabgroup): remove people from a group
DennisBauer 006d54c
feat(tabgroup): handle being removed from a group
DennisBauer 48348c2
fix(tabgroup): show when a group is no longer available
DennisBauer File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 8 additions & 1 deletion
9
...up/data/src/commonMain/kotlin/de/tabmates/features/tabgroup/data/di/TabgroupDataModule.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,10 +1,17 @@ | ||
| package de.tabmates.features.tabgroup.data.di | ||
|
|
||
| import de.tabmates.features.tabgroup.domain.group.GroupRemovalNotifier | ||
| import org.koin.core.annotation.ComponentScan | ||
| import org.koin.core.annotation.Configuration | ||
| import org.koin.core.annotation.Module | ||
| import org.koin.core.annotation.Single | ||
|
|
||
| @Module | ||
| @Configuration | ||
| @ComponentScan("de.tabmates.features.tabgroup.data") | ||
| class TabgroupDataModule | ||
| class TabgroupDataModule { | ||
| // Lives in the domain module, which carries no Koin annotations — same arrangement as | ||
| // UpgradeRequiredNotifier, which CoreDataModule provides for the same reason. | ||
| @Single | ||
| fun provideGroupRemovalNotifier(): GroupRemovalNotifier = GroupRemovalNotifier() | ||
| } |
36 changes: 36 additions & 0 deletions
36
...src/commonMain/kotlin/de/tabmates/features/tabgroup/data/dto/RemoveParticipantErrorDto.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| package de.tabmates.features.tabgroup.data.dto | ||
|
|
||
| import de.tabmates.core.domain.util.DataError | ||
| import io.ktor.client.call.body | ||
| import io.ktor.client.statement.HttpResponse | ||
| import kotlinx.coroutines.CancellationException | ||
| import kotlinx.serialization.Serializable | ||
|
|
||
| @Serializable | ||
| internal data class RemoveParticipantErrorDto(val code: String? = null) | ||
|
|
||
| /** | ||
| * Maps the two removal refusals the server states by code. | ||
| * | ||
| * Everything else — including the `403` a non-member gets and the `404` covering both an unknown | ||
| * group and an unknown target — returns `null` and falls through to the generic status handling. | ||
| * The catch tolerates non-JSON bodies; the shared `Json` already sets `ignoreUnknownKeys`. It stops | ||
| * short of cancellation, which has to reach the caller rather than be answered with a plain | ||
| * `BAD_REQUEST` from the generic handling below. | ||
| */ | ||
| internal suspend fun HttpResponse.removeParticipantErrorOrNull(): DataError.Remote? { | ||
| if (status.value != 400 && status.value != 403) return null | ||
| val code = | ||
| try { | ||
| body<RemoveParticipantErrorDto>().code | ||
| } catch (e: CancellationException) { | ||
| throw e | ||
| } catch (e: Exception) { | ||
| null | ||
| } | ||
| return when (code) { | ||
| "CANNOT_REMOVE_SELF" -> DataError.Remote.CANNOT_REMOVE_SELF | ||
| "CANNOT_REMOVE_GROUP_CREATOR" -> DataError.Remote.CANNOT_REMOVE_GROUP_CREATOR | ||
| else -> null | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.