-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
converting the coupling query element
- Loading branch information
1 parent
778205e
commit 70a5b51
Showing
17 changed files
with
141 additions
and
139 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
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
42 changes: 22 additions & 20 deletions
42
client/src/jsMain/kotlin/com/zegreatrob/coupling/client/party/PartyConfigPage.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 |
---|---|---|
@@ -1,31 +1,33 @@ | ||
package com.zegreatrob.coupling.client.party | ||
|
||
import com.zegreatrob.coupling.client.components.party.PartyConfig | ||
import com.zegreatrob.coupling.client.components.party.create | ||
import com.zegreatrob.coupling.client.routing.CouplingQuery | ||
import com.zegreatrob.coupling.client.routing.PageProps | ||
import com.zegreatrob.coupling.client.routing.partyId | ||
import com.zegreatrob.coupling.model.party.PartyId | ||
import com.zegreatrob.coupling.sdk.gql.graphQuery | ||
import com.zegreatrob.minreact.add | ||
import com.zegreatrob.minreact.nfc | ||
|
||
val PartyConfigPage by nfc<PageProps> { props -> | ||
add((props.partyId?.partyQueryProps(props) ?: newPartyProps(props)), key = props.partyId?.value) | ||
} | ||
|
||
private fun PartyId.partyQueryProps(pageProps: PageProps) = CouplingQuery( | ||
commander = pageProps.commander, | ||
query = graphQuery { party(this@partyQueryProps) { party() } }, | ||
build = { _, commandFunc, result -> | ||
PartyConfig( | ||
party = result.party?.details?.data ?: return@CouplingQuery, | ||
dispatchFunc = commandFunc, | ||
val partyId = props.partyId | ||
if (partyId != null) { | ||
CouplingQuery( | ||
commander = props.commander, | ||
query = graphQuery { party(partyId) { party() } }, | ||
toNode = { _, commandFunc, result -> | ||
PartyConfig.create( | ||
party = result.party?.details?.data ?: return@CouplingQuery null, | ||
dispatchFunc = commandFunc, | ||
) | ||
}, | ||
key = props.partyId?.value, | ||
) | ||
}, | ||
) | ||
|
||
private fun newPartyProps(pageProps: PageProps) = CouplingQuery( | ||
commander = pageProps.commander, | ||
query = NewPartyCommand(), | ||
build = { _, commandFunc, data -> PartyConfig(data, commandFunc) }, | ||
) | ||
} else { | ||
CouplingQuery( | ||
commander = props.commander, | ||
query = NewPartyCommand(), | ||
toNode = { _, commandFunc, data -> PartyConfig.create(data, commandFunc) }, | ||
key = props.partyId?.value, | ||
) | ||
} | ||
} |
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
15 changes: 8 additions & 7 deletions
15
client/src/jsMain/kotlin/com/zegreatrob/coupling/client/pin/PinPage.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 |
---|---|---|
@@ -1,33 +1,34 @@ | ||
package com.zegreatrob.coupling.client.pin | ||
|
||
import com.zegreatrob.coupling.client.components.pin.PinConfig | ||
import com.zegreatrob.coupling.client.components.pin.create | ||
import com.zegreatrob.coupling.client.partyPageFunction | ||
import com.zegreatrob.coupling.client.routing.CouplingQuery | ||
import com.zegreatrob.coupling.client.routing.pinId | ||
import com.zegreatrob.coupling.model.elements | ||
import com.zegreatrob.coupling.model.pin.Pin | ||
import com.zegreatrob.coupling.sdk.gql.graphQuery | ||
import com.zegreatrob.minreact.create | ||
|
||
val PinPage = partyPageFunction { props, partyId -> | ||
val pinId = props.pinId | ||
+CouplingQuery( | ||
CouplingQuery( | ||
commander = props.commander, | ||
query = graphQuery { | ||
party(partyId) { | ||
party() | ||
pinList() | ||
} | ||
}, | ||
build = { reload, commandFunc, result -> | ||
val pinList = result.party?.pinList?.elements ?: return@CouplingQuery | ||
PinConfig( | ||
party = result.party?.details?.data ?: return@CouplingQuery, | ||
toNode = { reload, commandFunc, result -> | ||
val pinList = result.party?.pinList?.elements ?: return@CouplingQuery null | ||
PinConfig.create( | ||
party = result.party?.details?.data ?: return@CouplingQuery null, | ||
pinList = pinList, | ||
pin = pinList.firstOrNull { it.id == pinId } ?: Pin(), | ||
reload = reload, | ||
dispatchFunc = commandFunc, | ||
) | ||
}, | ||
).create(key = pinId) | ||
key = pinId, | ||
) | ||
} |
11 changes: 6 additions & 5 deletions
11
client/src/jsMain/kotlin/com/zegreatrob/coupling/client/player/PlayerPage.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 |
---|---|---|
@@ -1,20 +1,21 @@ | ||
package com.zegreatrob.coupling.client.player | ||
|
||
import com.zegreatrob.coupling.client.components.player.PlayerConfig | ||
import com.zegreatrob.coupling.client.components.player.create | ||
import com.zegreatrob.coupling.client.partyPageFunction | ||
import com.zegreatrob.coupling.client.routing.CouplingQuery | ||
import com.zegreatrob.coupling.client.routing.PageProps | ||
import com.zegreatrob.coupling.client.routing.playerId | ||
import com.zegreatrob.coupling.model.party.PartyId | ||
import com.zegreatrob.coupling.sdk.PartyPlayerQuery | ||
import com.zegreatrob.minreact.create | ||
|
||
val PlayerPage = partyPageFunction { props: PageProps, partyId: PartyId -> | ||
+CouplingQuery( | ||
CouplingQuery( | ||
commander = props.commander, | ||
query = PartyPlayerQuery(partyId, props.playerId), | ||
build = { reload, commandFunc, (party, players, player) -> | ||
PlayerConfig(party, player, players, reload, commandFunc) | ||
toNode = { reload, commandFunc, (party, players, player) -> | ||
PlayerConfig.create(party, player, players, reload, commandFunc) | ||
}, | ||
).create(key = "${partyId.value}-${props.playerId}") | ||
key = "${partyId.value}-${props.playerId}", | ||
) | ||
} |
Oops, something went wrong.