-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement share content feature (#303)
* Implement share content feature * fix text field max width size constraint * Remove name field from SharedMonsterLore * Improve contentToImportShort * Fix jvm migration and sync monster after imported creatures * Fix jvm database migration when has no database
- Loading branch information
1 parent
a790975
commit f305339
Showing
89 changed files
with
1,476 additions
and
204 deletions.
There are no files selected for viewing
This file contains 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 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 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
33 changes: 33 additions & 0 deletions
33
app/src/commonMain/kotlin/br/alexandregpereira/hunter/app/event/AppEventDispatcher.kt
This file contains 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,33 @@ | ||
package br.alexandregpereira.hunter.app.event | ||
|
||
import br.alexadregpereira.hunter.shareContent.event.ShareContentEvent | ||
import br.alexadregpereira.hunter.shareContent.event.ShareContentEventDispatcher | ||
import br.alexandregpereira.hunter.monster.event.MonsterEvent | ||
import br.alexandregpereira.hunter.monster.event.MonsterEventDispatcher | ||
import kotlinx.coroutines.MainScope | ||
import kotlinx.coroutines.flow.filterIsInstance | ||
import kotlinx.coroutines.flow.launchIn | ||
import kotlinx.coroutines.flow.onEach | ||
|
||
interface AppEventDispatcher { | ||
fun observeEvents() | ||
} | ||
|
||
internal class AppEventDispatcherImpl( | ||
private val shareContentEventDispatcher: ShareContentEventDispatcher, | ||
private val monsterEventDispatcher: MonsterEventDispatcher, | ||
) : AppEventDispatcher { | ||
|
||
private val scope = MainScope() | ||
|
||
override fun observeEvents() { | ||
observeShareContentEvents() | ||
} | ||
|
||
private fun observeShareContentEvents() { | ||
shareContentEventDispatcher.events.filterIsInstance<ShareContentEvent.Import.OnFinish>() | ||
.onEach { | ||
monsterEventDispatcher.dispatchEvent(MonsterEvent.OnCompendiumChanges) | ||
}.launchIn(scope) | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
app/src/commonMain/kotlin/br/alexandregpereira/hunter/app/event/di.kt
This file contains 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,7 @@ | ||
package br.alexandregpereira.hunter.app.event | ||
|
||
import org.koin.dsl.module | ||
|
||
val appEventModule = module { | ||
single<AppEventDispatcher> { AppEventDispatcherImpl(get(), get()) } | ||
} |
This file contains 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
30 changes: 30 additions & 0 deletions
30
core/event/src/commonMain/kotlin/br/alexandregpereira/hunter/event/v2/Event.kt
This file contains 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,30 @@ | ||
package br.alexandregpereira.hunter.event.v2 | ||
|
||
import kotlinx.coroutines.channels.BufferOverflow | ||
import kotlinx.coroutines.flow.Flow | ||
import kotlinx.coroutines.flow.MutableSharedFlow | ||
|
||
interface EventDispatcher<Event> : EventListener<Event> { | ||
|
||
fun dispatchEvent(event: Event) | ||
} | ||
|
||
interface EventListener<Event> { | ||
|
||
val events: Flow<Event> | ||
} | ||
|
||
fun <Event> EventDispatcher(): EventDispatcher<Event> = DefaultEventManager() | ||
|
||
private class DefaultEventManager<Event> : EventDispatcher<Event> { | ||
|
||
private val _events: MutableSharedFlow<Event> = MutableSharedFlow( | ||
extraBufferCapacity = 10, | ||
onBufferOverflow = BufferOverflow.DROP_OLDEST | ||
) | ||
override val events: Flow<Event> = _events | ||
|
||
override fun dispatchEvent(event: Event) { | ||
_events.tryEmit(event) | ||
} | ||
} |
This file contains 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 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 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
4 changes: 2 additions & 2 deletions
4
domain/app/data/src/commonMain/sqldelight/br/alexandregpereira/hunter/database/Spell.sq
This file contains 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
Binary file not shown.
This file contains 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 @@ | ||
ALTER TABLE SpellEntity ADD COLUMN status INTEGER NOT NULL DEFAULT 0; |
This file contains 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 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 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 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 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 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 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 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 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 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.