@@ -23,20 +23,18 @@ import androidx.compose.ui.draw.clip
23
23
import androidx.compose.ui.graphics.Color
24
24
import androidx.compose.ui.unit.dp
25
25
import database.entity.BonusRecord
26
- import database.entity.BonusRecordWeapons.weapon
26
+ import database.entity.BonusRecordView
27
27
import database.entity.BonusRecords
28
- import database.entity.Weapon
28
+ import database.entity.toView
29
29
import kotlinx.coroutines.CoroutineScope
30
30
import kotlinx.coroutines.launch
31
31
import org.jetbrains.exposed.dao.with
32
32
import org.jetbrains.exposed.sql.SortOrder
33
33
import org.jetbrains.exposed.sql.SqlExpressionBuilder.eq
34
34
import org.jetbrains.exposed.sql.deleteWhere
35
- import org.jetbrains.exposed.sql.mapLazy
36
35
import view.account.AccountViewPage
37
36
import view.account.PageViewState
38
37
import java.time.Duration
39
- import java.time.Instant
40
38
import java.time.ZoneId
41
39
42
40
@@ -75,37 +73,28 @@ var account by Account referencedOn BonusRecords.account
75
73
var weapons by Weapon via BonusRecordWeapons
76
74
*/
77
75
78
- private data class RecordData (
79
- val id : Int ,
80
- val startTime : Instant ,
81
- val endTime : Instant ,
82
- val duration : Duration ,
83
- val score : UInt ,
84
- val weapons : List <Weapon >
85
- )
76
+ // private data class RecordData(
77
+ // val id: Int,
78
+ // val startTime: Instant,
79
+ // val endTime: Instant,
80
+ // val duration: Duration,
81
+ // val score: UInt,
82
+ // val weapons: List<WeaponView >
83
+ // )
86
84
87
85
@Composable
88
86
private fun ShowBonusRecordList (state : PageViewState ) {
89
87
val scope = rememberCoroutineScope()
90
- val recordList = remember { mutableStateListOf<RecordData >() }
88
+ val recordList = remember { mutableStateListOf<BonusRecordView >() }
91
89
val listState = rememberLazyListState()
92
90
93
91
LaunchedEffect (Unit ) {
94
92
state.accountState.inAccountTransaction { account ->
95
- val all = account.records
93
+ val all = BonusRecord .find { BonusRecords . account eq account.id }
96
94
.orderBy(BonusRecords .createTime to SortOrder .DESC )
97
95
.with (BonusRecord ::weapons)
98
96
.notForUpdate()
99
- .mapLazy {
100
- RecordData (
101
- id = it.id.value,
102
- startTime = it.startTime,
103
- endTime = it.endTime,
104
- duration = it.duration,
105
- score = it.score,
106
- weapons = it.weapons.toList(),
107
- )
108
- }
97
+ .map { it.toView() }
109
98
110
99
recordList.addAll(all)
111
100
}
@@ -125,8 +114,8 @@ private fun ShowBonusRecordList(state: PageViewState) {
125
114
private fun ListItemRecord (
126
115
state : PageViewState ,
127
116
scope : CoroutineScope ,
128
- record : RecordData ,
129
- onDelete : (RecordData ) -> Unit ,
117
+ record : BonusRecordView ,
118
+ onDelete : (BonusRecordView ) -> Unit ,
130
119
) {
131
120
val interactionSource = remember { MutableInteractionSource () }
132
121
val isHovered by interactionSource.collectIsHoveredAsState()
0 commit comments