From b95edec462e5d3a1a21f467d3e0cc0a1746100a6 Mon Sep 17 00:00:00 2001 From: Nicolas Werner Date: Mon, 17 Apr 2023 16:54:43 +0200 Subject: [PATCH] fix: Update the generated enum files --- CHANGELOG.md | 7 ++ lib/src/generated/model.g.dart | 137 +++++++++++++++++++++++---------- pubspec.yaml | 2 +- 3 files changed, 104 insertions(+), 42 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 576d2f59..a40bf5ff 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +## [1.6.1] - 17th Apr 2023 + +Fixes a small issue in the last release, where some enhanced enums were not +updated and as such missing a few members. + +- fix: Update the generated enum files + ## [1.6.0] - 17th Apr 2023 This release updates to version 1.6 of the Matrix specification. Users might diff --git a/lib/src/generated/model.g.dart b/lib/src/generated/model.g.dart index b5f907e3..08265a66 100644 --- a/lib/src/generated/model.g.dart +++ b/lib/src/generated/model.g.dart @@ -6,6 +6,88 @@ part of 'model.dart'; // EnhancedEnumGenerator // ************************************************************************** +extension DirectionFromStringExtension on Iterable { + Direction? fromString(String val) { + final override = { + 'b': Direction.b, + 'f': Direction.f, + }[val]; +// ignore: unnecessary_this + return this.contains(override) ? override : null; + } +} + +extension DirectionEnhancedEnum on Direction { + @override +// ignore: override_on_non_overriding_member + String get name => { + Direction.b: 'b', + Direction.f: 'f', + }[this]!; + bool get isB => this == Direction.b; + bool get isF => this == Direction.f; + T when({ + required T Function() b, + required T Function() f, + }) => + { + Direction.b: b, + Direction.f: f, + }[this]!(); + T maybeWhen({ + T? Function()? b, + T? Function()? f, + required T Function() orElse, + }) => + { + Direction.b: b, + Direction.f: f, + }[this] + ?.call() ?? + orElse(); +} + +extension IncludeFromStringExtension on Iterable { + Include? fromString(String val) { + final override = { + 'all': Include.all, + 'participated': Include.participated, + }[val]; +// ignore: unnecessary_this + return this.contains(override) ? override : null; + } +} + +extension IncludeEnhancedEnum on Include { + @override +// ignore: override_on_non_overriding_member + String get name => { + Include.all: 'all', + Include.participated: 'participated', + }[this]!; + bool get isAll => this == Include.all; + bool get isParticipated => this == Include.participated; + T when({ + required T Function() all, + required T Function() participated, + }) => + { + Include.all: all, + Include.participated: participated, + }[this]!(); + T maybeWhen({ + T? Function()? all, + T? Function()? participated, + required T Function() orElse, + }) => + { + Include.all: all, + Include.participated: participated, + }[this] + ?.call() ?? + orElse(); +} + extension ThirdPartyIdentifierMediumFromStringExtension on Iterable { ThirdPartyIdentifierMedium? fromString(String val) { @@ -514,51 +596,12 @@ extension MembershipEnhancedEnum on Membership { orElse(); } -extension DirectionFromStringExtension on Iterable { - Direction? fromString(String val) { - final override = { - 'b': Direction.b, - 'f': Direction.f, - }[val]; -// ignore: unnecessary_this - return this.contains(override) ? override : null; - } -} - -extension DirectionEnhancedEnum on Direction { - @override -// ignore: override_on_non_overriding_member - String get name => { - Direction.b: 'b', - Direction.f: 'f', - }[this]!; - bool get isB => this == Direction.b; - bool get isF => this == Direction.f; - T when({ - required T Function() b, - required T Function() f, - }) => - { - Direction.b: b, - Direction.f: f, - }[this]!(); - T maybeWhen({ - T? Function()? b, - T? Function()? f, - required T Function() orElse, - }) => - { - Direction.b: b, - Direction.f: f, - }[this] - ?.call() ?? - orElse(); -} - extension ReceiptTypeFromStringExtension on Iterable { ReceiptType? fromString(String val) { final override = { + 'm.fully_read': ReceiptType.mFullyRead, 'm.read': ReceiptType.mRead, + 'm.read.private': ReceiptType.mReadPrivate, }[val]; // ignore: unnecessary_this return this.contains(override) ? override : null; @@ -569,21 +612,33 @@ extension ReceiptTypeEnhancedEnum on ReceiptType { @override // ignore: override_on_non_overriding_member String get name => { + ReceiptType.mFullyRead: 'm.fully_read', ReceiptType.mRead: 'm.read', + ReceiptType.mReadPrivate: 'm.read.private', }[this]!; + bool get isMFullyRead => this == ReceiptType.mFullyRead; bool get isMRead => this == ReceiptType.mRead; + bool get isMReadPrivate => this == ReceiptType.mReadPrivate; T when({ + required T Function() mFullyRead, required T Function() mRead, + required T Function() mReadPrivate, }) => { + ReceiptType.mFullyRead: mFullyRead, ReceiptType.mRead: mRead, + ReceiptType.mReadPrivate: mReadPrivate, }[this]!(); T maybeWhen({ + T? Function()? mFullyRead, T? Function()? mRead, + T? Function()? mReadPrivate, required T Function() orElse, }) => { + ReceiptType.mFullyRead: mFullyRead, ReceiptType.mRead: mRead, + ReceiptType.mReadPrivate: mReadPrivate, }[this] ?.call() ?? orElse(); diff --git a/pubspec.yaml b/pubspec.yaml index 95328d0c..ab670998 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: matrix_api_lite description: Dead simple data model for the matrix.org client-server API. -version: 1.6.0 +version: 1.6.1 homepage: https://famedly.com repository: https://gitlab.com/famedly/company/frontend/libraries/matrix_api_lite/ issues: https://gitlab.com/famedly/company/frontend/libraries/matrix_api_lite/-/issues