Skip to content

Commit d877730

Browse files
committed
api [nfc]: Rename DmRecipient to DmDisplayRecipient
We will use this name for a different purpose later.
1 parent 8a7b259 commit d877730

File tree

3 files changed

+26
-25
lines changed

3 files changed

+26
-25
lines changed

lib/api/model/model.dart

+15-15
Original file line numberDiff line numberDiff line change
@@ -766,46 +766,46 @@ class StreamMessage extends Message {
766766
}
767767

768768
@JsonSerializable(fieldRename: FieldRename.snake)
769-
class DmRecipient {
769+
class DmDisplayRecipient {
770770
final int id;
771771
final String email;
772772
final String fullName;
773773

774774
// final String? shortName; // obsolete, ignore
775775
// final bool? isMirrorDummy; // obsolete, ignore
776776

777-
DmRecipient({required this.id, required this.email, required this.fullName});
777+
const DmDisplayRecipient({required this.id, required this.email, required this.fullName});
778778

779-
factory DmRecipient.fromJson(Map<String, dynamic> json) =>
780-
_$DmRecipientFromJson(json);
779+
factory DmDisplayRecipient.fromJson(Map<String, dynamic> json) =>
780+
_$DmDisplayRecipientFromJson(json);
781781

782-
Map<String, dynamic> toJson() => _$DmRecipientToJson(this);
782+
Map<String, dynamic> toJson() => _$DmDisplayRecipientToJson(this);
783783

784784
@override
785-
String toString() => 'DmRecipient(id: $id, email: $email, fullName: $fullName)';
785+
String toString() => 'DmDisplayRecipient(id: $id, email: $email, fullName: $fullName)';
786786

787787
@override
788788
bool operator ==(Object other) {
789-
if (other is! DmRecipient) return false;
789+
if (other is! DmDisplayRecipient) return false;
790790
return other.id == id && other.email == email && other.fullName == fullName;
791791
}
792792

793793
@override
794-
int get hashCode => Object.hash('DmRecipient', id, email, fullName);
794+
int get hashCode => Object.hash('DmDisplayRecipient', id, email, fullName);
795795
}
796796

797-
class DmRecipientListConverter extends JsonConverter<List<DmRecipient>, List<dynamic>> {
798-
const DmRecipientListConverter();
797+
class DmDisplayRecipientListConverter extends JsonConverter<List<DmDisplayRecipient>, List<dynamic>> {
798+
const DmDisplayRecipientListConverter();
799799

800800
@override
801-
List<DmRecipient> fromJson(List<dynamic> json) {
802-
return json.map((e) => DmRecipient.fromJson(e as Map<String, dynamic>))
801+
List<DmDisplayRecipient> fromJson(List<dynamic> json) {
802+
return json.map((e) => DmDisplayRecipient.fromJson(e as Map<String, dynamic>))
803803
.toList(growable: false)
804804
..sort((a, b) => a.id.compareTo(b.id));
805805
}
806806

807807
@override
808-
List<dynamic> toJson(List<DmRecipient> object) => object;
808+
List<dynamic> toJson(List<DmDisplayRecipient> object) => object;
809809
}
810810

811811
@JsonSerializable(fieldRename: FieldRename.snake)
@@ -826,8 +826,8 @@ class DmMessage extends Message {
826826
/// from the store.
827827
// TODO(server): Document that it's all users. That statement is based on
828828
// reverse-engineering notes in zulip-mobile:src/api/modelTypes.js at PmMessage.
829-
@DmRecipientListConverter()
830-
final List<DmRecipient> displayRecipient;
829+
@DmDisplayRecipientListConverter()
830+
final List<DmDisplayRecipient> displayRecipient;
831831

832832
/// The user IDs of all users in the thread, sorted numerically.
833833
///

lib/api/model/model.g.dart

+9-8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/api/model/model_test.dart

+2-2
Original file line numberDiff line numberDiff line change
@@ -172,9 +172,9 @@ void main() {
172172
return DmMessage.fromJson({ ...baseJson, ...specialJson });
173173
}
174174

175-
Iterable<DmRecipient> asRecipients(Iterable<User> users) {
175+
Iterable<DmDisplayRecipient> asRecipients(Iterable<User> users) {
176176
return users.map((u) =>
177-
DmRecipient(id: u.userId, email: u.email, fullName: u.fullName));
177+
DmDisplayRecipient(id: u.userId, email: u.email, fullName: u.fullName));
178178
}
179179

180180
Map<String, dynamic> withRecipients(Iterable<User> recipients) {

0 commit comments

Comments
 (0)