Some checks are pending
Backend CI / test (push) Waiting to run
Backend CI / build (push) Blocked by required conditions
Mobile App CI / test (push) Waiting to run
Mobile App CI / build-android (push) Blocked by required conditions
Mobile App CI / build-ios (push) Blocked by required conditions
Web App CI / test (push) Waiting to run
Web App CI / build (push) Blocked by required conditions
Deploy Mnemo Cards / Deploy Backend (push) Waiting to run
Deploy Mnemo Cards / Deploy Web App (push) Blocked by required conditions
Deploy Mnemo Cards / Final Verification (push) Blocked by required conditions
Deploy Telegram Bot / Deploy Telegram Bot (push) Waiting to run
32 lines
965 B
Dart
32 lines
965 B
Dart
import 'package:mnemo_cards_common_backend/mnemo_cards_common_backend.dart';
|
|
import 'package:mnemo_cards_common/mnemo_cards_common.dart';
|
|
|
|
extension converterExtenxion on GameCardModel {
|
|
GameCardDto toDto() {
|
|
return GameCardDto(
|
|
id: id,
|
|
image: image,
|
|
mnemo: mnemo,
|
|
original: original,
|
|
translation: translation,
|
|
transcription: transcription,
|
|
transcriptionMnemo: transcriptionMnemo,
|
|
imageBack: imageBack,
|
|
back: back,
|
|
);
|
|
}
|
|
}
|
|
|
|
extension listConverterExtenxion on Iterable<GameCardModel> {
|
|
List<GameCardDto> toDtosList(List<String> cardsOrder) =>
|
|
map((e) => e.toDto()).toList()..sort((p, n) {
|
|
final pIndex = cardsOrder.indexOf(p.id);
|
|
final nIndex = cardsOrder.indexOf(n.id);
|
|
if (pIndex == -1) {
|
|
return nIndex == -1 ? p.id.compareTo(n.id) : 1;
|
|
} else if (nIndex == -1) {
|
|
return -1;
|
|
}
|
|
return pIndex.compareTo(nIndex);
|
|
});
|
|
}
|