From 78bb644821927ea2bc66533c6ef439a0b61448c4 Mon Sep 17 00:00:00 2001 From: Greg Price Date: Wed, 5 Apr 2023 14:57:03 -0700 Subject: [PATCH 1/3] api [nfc]: Use FieldRename.snake on JsonSerializable This will allow us to switch to the Dart standard convention of camel case within our source code, while still interoperating smoothly with the snake case in the Zulip API. --- lib/api/model/events.dart | 4 ++-- lib/api/model/initial_snapshot.dart | 2 +- lib/api/model/model.dart | 10 +++++----- lib/api/route/account.dart | 2 +- lib/api/route/events.dart | 2 +- lib/api/route/messages.dart | 4 ++-- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/lib/api/model/events.dart b/lib/api/model/events.dart index 1b46132770..8038c9e2c6 100644 --- a/lib/api/model/events.dart +++ b/lib/api/model/events.dart @@ -46,7 +46,7 @@ class UnexpectedEvent extends Event { } /// A Zulip event of type `alert_words`. -@JsonSerializable() +@JsonSerializable(fieldRename: FieldRename.snake) class AlertWordsEvent extends Event { @override @JsonKey(includeToJson: true) @@ -100,7 +100,7 @@ class MessageEvent extends Event { } } -@JsonSerializable() +@JsonSerializable(fieldRename: FieldRename.snake) class HeartbeatEvent extends Event { @override @JsonKey(includeToJson: true) diff --git a/lib/api/model/initial_snapshot.dart b/lib/api/model/initial_snapshot.dart index 312c637824..591a2517f2 100644 --- a/lib/api/model/initial_snapshot.dart +++ b/lib/api/model/initial_snapshot.dart @@ -7,7 +7,7 @@ import 'model.dart'; part 'initial_snapshot.g.dart'; // https://zulip.com/api/register-queue#response -@JsonSerializable() +@JsonSerializable(fieldRename: FieldRename.snake) class InitialSnapshot { final String? queue_id; final int last_event_id; diff --git a/lib/api/model/model.dart b/lib/api/model/model.dart index c8e0539ab1..bbe3e4da76 100644 --- a/lib/api/model/model.dart +++ b/lib/api/model/model.dart @@ -7,7 +7,7 @@ part 'model.g.dart'; /// As in `custom_profile_fields` in the initial snapshot. /// /// https://zulip.com/api/register-queue#response -@JsonSerializable() +@JsonSerializable(fieldRename: FieldRename.snake) class CustomProfileField { final int id; final int type; // TODO enum; also TODO(server-6) a value added @@ -34,7 +34,7 @@ class CustomProfileField { } /// As in `subscriptions` in the initial snapshot. -@JsonSerializable() +@JsonSerializable(fieldRename: FieldRename.snake) class Subscription { final int stream_id; final String name; @@ -165,7 +165,7 @@ abstract class Message { Map toJson(); } -@JsonSerializable() +@JsonSerializable(fieldRename: FieldRename.snake) class StreamMessage extends Message { @override @JsonKey(includeToJson: true) @@ -203,7 +203,7 @@ class StreamMessage extends Message { Map toJson() => _$StreamMessageToJson(this); } -@JsonSerializable() +@JsonSerializable(fieldRename: FieldRename.snake) class PmRecipient { final int id; final String email; @@ -220,7 +220,7 @@ class PmRecipient { Map toJson() => _$PmRecipientToJson(this); } -@JsonSerializable() +@JsonSerializable(fieldRename: FieldRename.snake) class PmMessage extends Message { @override @JsonKey(includeToJson: true) diff --git a/lib/api/route/account.dart b/lib/api/route/account.dart index 193d1b4d93..cec8244ef4 100644 --- a/lib/api/route/account.dart +++ b/lib/api/route/account.dart @@ -31,7 +31,7 @@ Future fetchApiKey({ return FetchApiKeyResult.fromJson(json); } -@JsonSerializable() +@JsonSerializable(fieldRename: FieldRename.snake) class FetchApiKeyResult { final String api_key; final String email; diff --git a/lib/api/route/events.dart b/lib/api/route/events.dart index 13b3690a6a..462d762ec8 100644 --- a/lib/api/route/events.dart +++ b/lib/api/route/events.dart @@ -39,7 +39,7 @@ Future getEvents(ApiConnection connection, { return GetEventsResult.fromJson(jsonDecode(data)); } -@JsonSerializable() +@JsonSerializable(fieldRename: FieldRename.snake) class GetEventsResult { final List events; // TODO(server): Docs say queue_id required; empirically sometimes missing. diff --git a/lib/api/route/messages.dart b/lib/api/route/messages.dart index f2a9dec6a9..8afa3bd622 100644 --- a/lib/api/route/messages.dart +++ b/lib/api/route/messages.dart @@ -23,7 +23,7 @@ Future getMessages(ApiConnection connection, { return GetMessagesResult.fromJson(jsonDecode(data)); } -@JsonSerializable() +@JsonSerializable(fieldRename: FieldRename.snake) class GetMessagesResult { final int anchor; final bool found_newest; @@ -84,7 +84,7 @@ Future sendMessage( return SendMessageResult.fromJson(jsonDecode(data)); } -@JsonSerializable() +@JsonSerializable(fieldRename: FieldRename.snake) class SendMessageResult { final int id; final String? deliver_at; From f7ce1ef33de8e5b2ce0e4ac623de591b5359b0a8 Mon Sep 17 00:00:00 2001 From: Greg Price Date: Wed, 5 Apr 2023 15:05:53 -0700 Subject: [PATCH 2/3] api [nfc]: Use Dart-standard camel case throughout our source code If the field names and parameter names used in the API bindings match the snake case of the Zulip API, then that will unavoidably propagate to some names found throughout the rest of our code -- as indeed it already has, as seen in this diff. There's no clean line that can be drawn within our source code so that snake-case names go on one side, and camel-case names on the other. So we'd inevitably have an unpredictable mix of both kinds of names, and often of the same name appearing in two different forms in the same code. That's what we see in the zulip-mobile RN app. Instead, draw that line at the very boundary of our code, where the data comes and goes via JSON. Happily the json_serializable code generator allows us to largely just write camel case and let the conversion to and from snake case be done automatically. Written by removing those ignore_for_file lines, and then using Android Studio's "rename" feature many times. Then grepped for `\w+(_\w+)+` to find stragglers in comments, and fixed those by hand. There's a couple of remaining stragglers in credential_fixture.dart, which I'll handle as a followup commit. --- lib/api/model/events.dart | 12 +- lib/api/model/events.g.dart | 4 +- lib/api/model/initial_snapshot.dart | 30 ++-- lib/api/model/initial_snapshot.g.dart | 28 ++-- lib/api/model/model.dart | 206 +++++++++++++------------- lib/api/model/model.g.dart | 190 ++++++++++++------------ lib/api/route/account.dart | 6 +- lib/api/route/account.g.dart | 4 +- lib/api/route/events.dart | 16 +- lib/api/route/events.g.dart | 4 +- lib/api/route/messages.dart | 30 ++-- lib/api/route/messages.g.dart | 20 +-- lib/model/message_list.dart | 2 +- lib/model/store.dart | 24 ++- lib/widgets/app.dart | 2 +- lib/widgets/lightbox.dart | 2 +- lib/widgets/login.dart | 2 +- lib/widgets/message_list.dart | 10 +- test/api/model/events_checks.dart | 4 +- test/api/route/route_checks.dart | 4 +- test/example_data.dart | 14 +- 21 files changed, 297 insertions(+), 317 deletions(-) diff --git a/lib/api/model/events.dart b/lib/api/model/events.dart index 8038c9e2c6..a8c191e317 100644 --- a/lib/api/model/events.dart +++ b/lib/api/model/events.dart @@ -1,5 +1,3 @@ -// ignore_for_file: non_constant_identifier_names - import 'package:json_annotation/json_annotation.dart'; import 'model.dart'; @@ -52,9 +50,9 @@ class AlertWordsEvent extends Event { @JsonKey(includeToJson: true) String get type => 'alert_words'; - final List alert_words; + final List alertWords; - AlertWordsEvent({required super.id, required this.alert_words}); + AlertWordsEvent({required super.id, required this.alertWords}); factory AlertWordsEvent.fromJson(Map json) => _$AlertWordsEventFromJson(json); @@ -75,9 +73,9 @@ class MessageEvent extends Event { // normalize that away in deserialization. // // The other difference in the server API between message objects in these - // events and in the get-messages results is that `match_content` and - // `match_subject` are absent here. Already [Message.match_content] and - // [Message.match_subject] are optional, so no action is needed on that. + // events and in the get-messages results is that `matchContent` and + // `matchSubject` are absent here. Already [Message.matchContent] and + // [Message.matchSubject] are optional, so no action is needed on that. final Message message; MessageEvent({required super.id, required this.message}); diff --git a/lib/api/model/events.g.dart b/lib/api/model/events.g.dart index 20bc9c502a..d08834382b 100644 --- a/lib/api/model/events.g.dart +++ b/lib/api/model/events.g.dart @@ -9,7 +9,7 @@ part of 'events.dart'; AlertWordsEvent _$AlertWordsEventFromJson(Map json) => AlertWordsEvent( id: json['id'] as int, - alert_words: (json['alert_words'] as List) + alertWords: (json['alert_words'] as List) .map((e) => e as String) .toList(), ); @@ -18,7 +18,7 @@ Map _$AlertWordsEventToJson(AlertWordsEvent instance) => { 'id': instance.id, 'type': instance.type, - 'alert_words': instance.alert_words, + 'alert_words': instance.alertWords, }; HeartbeatEvent _$HeartbeatEventFromJson(Map json) => diff --git a/lib/api/model/initial_snapshot.dart b/lib/api/model/initial_snapshot.dart index 591a2517f2..9a92038200 100644 --- a/lib/api/model/initial_snapshot.dart +++ b/lib/api/model/initial_snapshot.dart @@ -1,5 +1,3 @@ -// ignore_for_file: non_constant_identifier_names - import 'package:json_annotation/json_annotation.dart'; import 'model.dart'; @@ -9,15 +7,15 @@ part 'initial_snapshot.g.dart'; // https://zulip.com/api/register-queue#response @JsonSerializable(fieldRename: FieldRename.snake) class InitialSnapshot { - final String? queue_id; - final int last_event_id; - final int zulip_feature_level; - final String zulip_version; - final String? zulip_merge_base; // TODO(server-5) + final String? queueId; + final int lastEventId; + final int zulipFeatureLevel; + final String zulipVersion; + final String? zulipMergeBase; // TODO(server-5) - final List alert_words; + final List alertWords; - final List custom_profile_fields; + final List customProfileFields; // TODO etc., etc. @@ -26,13 +24,13 @@ class InitialSnapshot { // TODO etc., etc. InitialSnapshot({ - this.queue_id, - required this.last_event_id, - required this.zulip_feature_level, - required this.zulip_version, - this.zulip_merge_base, - required this.alert_words, - required this.custom_profile_fields, + this.queueId, + required this.lastEventId, + required this.zulipFeatureLevel, + required this.zulipVersion, + this.zulipMergeBase, + required this.alertWords, + required this.customProfileFields, required this.subscriptions, }); diff --git a/lib/api/model/initial_snapshot.g.dart b/lib/api/model/initial_snapshot.g.dart index 42bbb4bf86..d70fbdb3b1 100644 --- a/lib/api/model/initial_snapshot.g.dart +++ b/lib/api/model/initial_snapshot.g.dart @@ -8,15 +8,15 @@ part of 'initial_snapshot.dart'; InitialSnapshot _$InitialSnapshotFromJson(Map json) => InitialSnapshot( - queue_id: json['queue_id'] as String?, - last_event_id: json['last_event_id'] as int, - zulip_feature_level: json['zulip_feature_level'] as int, - zulip_version: json['zulip_version'] as String, - zulip_merge_base: json['zulip_merge_base'] as String?, - alert_words: (json['alert_words'] as List) + queueId: json['queue_id'] as String?, + lastEventId: json['last_event_id'] as int, + zulipFeatureLevel: json['zulip_feature_level'] as int, + zulipVersion: json['zulip_version'] as String, + zulipMergeBase: json['zulip_merge_base'] as String?, + alertWords: (json['alert_words'] as List) .map((e) => e as String) .toList(), - custom_profile_fields: (json['custom_profile_fields'] as List) + customProfileFields: (json['custom_profile_fields'] as List) .map((e) => CustomProfileField.fromJson(e as Map)) .toList(), subscriptions: (json['subscriptions'] as List) @@ -26,12 +26,12 @@ InitialSnapshot _$InitialSnapshotFromJson(Map json) => Map _$InitialSnapshotToJson(InitialSnapshot instance) => { - 'queue_id': instance.queue_id, - 'last_event_id': instance.last_event_id, - 'zulip_feature_level': instance.zulip_feature_level, - 'zulip_version': instance.zulip_version, - 'zulip_merge_base': instance.zulip_merge_base, - 'alert_words': instance.alert_words, - 'custom_profile_fields': instance.custom_profile_fields, + 'queue_id': instance.queueId, + 'last_event_id': instance.lastEventId, + 'zulip_feature_level': instance.zulipFeatureLevel, + 'zulip_version': instance.zulipVersion, + 'zulip_merge_base': instance.zulipMergeBase, + 'alert_words': instance.alertWords, + 'custom_profile_fields': instance.customProfileFields, 'subscriptions': instance.subscriptions, }; diff --git a/lib/api/model/model.dart b/lib/api/model/model.dart index bbe3e4da76..49e0274946 100644 --- a/lib/api/model/model.dart +++ b/lib/api/model/model.dart @@ -1,10 +1,8 @@ -// ignore_for_file: non_constant_identifier_names - import 'package:json_annotation/json_annotation.dart'; part 'model.g.dart'; -/// As in `custom_profile_fields` in the initial snapshot. +/// As in [InitialSnapshot.customProfileFields]. /// /// https://zulip.com/api/register-queue#response @JsonSerializable(fieldRename: FieldRename.snake) @@ -14,8 +12,8 @@ class CustomProfileField { final int order; final String name; final String hint; - final String field_data; - final bool? display_in_profile_summary; // TODO(server-6) + final String fieldData; + final bool? displayInProfileSummary; // TODO(server-6) CustomProfileField({ required this.id, @@ -23,8 +21,8 @@ class CustomProfileField { required this.order, required this.name, required this.hint, - required this.field_data, - required this.display_in_profile_summary, + required this.fieldData, + required this.displayInProfileSummary, }); factory CustomProfileField.fromJson(Map json) => @@ -36,66 +34,66 @@ class CustomProfileField { /// As in `subscriptions` in the initial snapshot. @JsonSerializable(fieldRename: FieldRename.snake) class Subscription { - final int stream_id; + final int streamId; final String name; final String description; - final String rendered_description; - final int date_created; - final bool invite_only; + final String renderedDescription; + final int dateCreated; + final bool inviteOnly; - // final List subscribers; // we register with include_subscribers false + // final List subscribers; // we register with includeSubscribers false - final bool? desktop_notifications; - final bool? email_notifications; - final bool? wildcard_mentions_notify; - final bool? push_notifications; - final bool? audible_notifications; + final bool? desktopNotifications; + final bool? emailNotifications; + final bool? wildcardMentionsNotify; + final bool? pushNotifications; + final bool? audibleNotifications; - final bool pin_to_top; + final bool pinToTop; - final String email_address; + final String emailAddress; - final bool is_muted; + final bool isMuted; - // final bool? in_home_view; // deprecated; ignore + // final bool? inHomeView; // deprecated; ignore - // final bool? is_announcement_only; // deprecated; ignore - final bool? is_web_public; // TODO(server-??): doc doesn't say when added + // final bool? isAnnouncementOnly; // deprecated; ignore + final bool? isWebPublic; // TODO(server-??): doc doesn't say when added final String color; - final int stream_post_policy; // TODO enum - final int? message_retention_days; - final bool history_public_to_subscribers; + final int streamPostPolicy; // TODO enum + final int? messageRetentionDays; + final bool historyPublicToSubscribers; - final int? first_message_id; - final int? stream_weekly_traffic; + final int? firstMessageId; + final int? streamWeeklyTraffic; - final int? can_remove_subscribers_group_id; // TODO(server-6) + final int? canRemoveSubscribersGroupId; // TODO(server-6) Subscription({ - required this.stream_id, + required this.streamId, required this.name, required this.description, - required this.rendered_description, - required this.date_created, - required this.invite_only, - this.desktop_notifications, - this.email_notifications, - this.wildcard_mentions_notify, - this.push_notifications, - this.audible_notifications, - required this.pin_to_top, - required this.email_address, - required this.is_muted, - this.is_web_public, + required this.renderedDescription, + required this.dateCreated, + required this.inviteOnly, + this.desktopNotifications, + this.emailNotifications, + this.wildcardMentionsNotify, + this.pushNotifications, + this.audibleNotifications, + required this.pinToTop, + required this.emailAddress, + required this.isMuted, + this.isWebPublic, required this.color, - required this.stream_post_policy, - this.message_retention_days, - required this.history_public_to_subscribers, - this.first_message_id, - this.stream_weekly_traffic, - this.can_remove_subscribers_group_id, + required this.streamPostPolicy, + this.messageRetentionDays, + required this.historyPublicToSubscribers, + this.firstMessageId, + this.streamWeeklyTraffic, + this.canRemoveSubscribersGroupId, }); factory Subscription.fromJson(Map json) => @@ -108,51 +106,51 @@ class Subscription { /// /// https://zulip.com/api/get-messages#response abstract class Message { - final String? avatar_url; + final String? avatarUrl; final String client; final String content; - final String content_type; + final String contentType; - // final List edit_history; // TODO handle + // final List editHistory; // TODO handle final int id; - final bool is_me_message; - final int? last_edit_timestamp; + final bool isMeMessage; + final int? lastEditTimestamp; // final List reactions; // TODO handle - final int recipient_id; - final String sender_email; - final String sender_full_name; - final int sender_id; - final String sender_realm_str; + final int recipientId; + final String senderEmail; + final String senderFullName; + final int senderId; + final String senderRealmStr; final String subject; // TODO call it "topic" internally; also similar others // final List submessages; // TODO handle final int timestamp; String get type; - // final List topic_links; // TODO handle + // final List topicLinks; // TODO handle // final string type; // handled by runtime type of object final List flags; // TODO enum - final String? match_content; - final String? match_subject; + final String? matchContent; + final String? matchSubject; Message({ - this.avatar_url, + this.avatarUrl, required this.client, required this.content, - required this.content_type, + required this.contentType, required this.id, - required this.is_me_message, - this.last_edit_timestamp, - required this.recipient_id, - required this.sender_email, - required this.sender_full_name, - required this.sender_id, - required this.sender_realm_str, + required this.isMeMessage, + this.lastEditTimestamp, + required this.recipientId, + required this.senderEmail, + required this.senderFullName, + required this.senderId, + required this.senderRealmStr, required this.subject, required this.timestamp, required this.flags, - this.match_content, - this.match_subject, + this.matchContent, + this.matchSubject, }); factory Message.fromJson(Map json) { @@ -171,29 +169,29 @@ class StreamMessage extends Message { @JsonKey(includeToJson: true) String get type => 'stream'; - final String display_recipient; - final int stream_id; + final String displayRecipient; + final int streamId; StreamMessage({ - super.avatar_url, + super.avatarUrl, required super.client, required super.content, - required super.content_type, + required super.contentType, required super.id, - required super.is_me_message, - super.last_edit_timestamp, - required super.recipient_id, - required super.sender_email, - required super.sender_full_name, - required super.sender_id, - required super.sender_realm_str, + required super.isMeMessage, + super.lastEditTimestamp, + required super.recipientId, + required super.senderEmail, + required super.senderFullName, + required super.senderId, + required super.senderRealmStr, required super.subject, required super.timestamp, required super.flags, - super.match_content, - super.match_subject, - required this.display_recipient, - required this.stream_id, + super.matchContent, + super.matchSubject, + required this.displayRecipient, + required this.streamId, }); factory StreamMessage.fromJson(Map json) => @@ -207,12 +205,12 @@ class StreamMessage extends Message { class PmRecipient { final int id; final String email; - final String full_name; + final String fullName; - // final String? short_name; // obsolete, ignore - // final bool? is_mirror_dummy; // obsolete, ignore + // final String? shortName; // obsolete, ignore + // final bool? isMirrorDummy; // obsolete, ignore - PmRecipient({required this.id, required this.email, required this.full_name}); + PmRecipient({required this.id, required this.email, required this.fullName}); factory PmRecipient.fromJson(Map json) => _$PmRecipientFromJson(json); @@ -226,27 +224,27 @@ class PmMessage extends Message { @JsonKey(includeToJson: true) String get type => 'private'; - final List display_recipient; + final List displayRecipient; PmMessage({ - super.avatar_url, + super.avatarUrl, required super.client, required super.content, - required super.content_type, + required super.contentType, required super.id, - required super.is_me_message, - super.last_edit_timestamp, - required super.recipient_id, - required super.sender_email, - required super.sender_full_name, - required super.sender_id, - required super.sender_realm_str, + required super.isMeMessage, + super.lastEditTimestamp, + required super.recipientId, + required super.senderEmail, + required super.senderFullName, + required super.senderId, + required super.senderRealmStr, required super.subject, required super.timestamp, required super.flags, - super.match_content, - super.match_subject, - required this.display_recipient, + super.matchContent, + super.matchSubject, + required this.displayRecipient, }); factory PmMessage.fromJson(Map json) => diff --git a/lib/api/model/model.g.dart b/lib/api/model/model.g.dart index 1ff85b05d8..9a959eeb0e 100644 --- a/lib/api/model/model.g.dart +++ b/lib/api/model/model.g.dart @@ -13,8 +13,8 @@ CustomProfileField _$CustomProfileFieldFromJson(Map json) => order: json['order'] as int, name: json['name'] as String, hint: json['hint'] as String, - field_data: json['field_data'] as String, - display_in_profile_summary: json['display_in_profile_summary'] as bool?, + fieldData: json['field_data'] as String, + displayInProfileSummary: json['display_in_profile_summary'] as bool?, ); Map _$CustomProfileFieldToJson(CustomProfileField instance) => @@ -24,165 +24,163 @@ Map _$CustomProfileFieldToJson(CustomProfileField instance) => 'order': instance.order, 'name': instance.name, 'hint': instance.hint, - 'field_data': instance.field_data, - 'display_in_profile_summary': instance.display_in_profile_summary, + 'field_data': instance.fieldData, + 'display_in_profile_summary': instance.displayInProfileSummary, }; Subscription _$SubscriptionFromJson(Map json) => Subscription( - stream_id: json['stream_id'] as int, + streamId: json['stream_id'] as int, name: json['name'] as String, description: json['description'] as String, - rendered_description: json['rendered_description'] as String, - date_created: json['date_created'] as int, - invite_only: json['invite_only'] as bool, - desktop_notifications: json['desktop_notifications'] as bool?, - email_notifications: json['email_notifications'] as bool?, - wildcard_mentions_notify: json['wildcard_mentions_notify'] as bool?, - push_notifications: json['push_notifications'] as bool?, - audible_notifications: json['audible_notifications'] as bool?, - pin_to_top: json['pin_to_top'] as bool, - email_address: json['email_address'] as String, - is_muted: json['is_muted'] as bool, - is_web_public: json['is_web_public'] as bool?, + renderedDescription: json['rendered_description'] as String, + dateCreated: json['date_created'] as int, + inviteOnly: json['invite_only'] as bool, + desktopNotifications: json['desktop_notifications'] as bool?, + emailNotifications: json['email_notifications'] as bool?, + wildcardMentionsNotify: json['wildcard_mentions_notify'] as bool?, + pushNotifications: json['push_notifications'] as bool?, + audibleNotifications: json['audible_notifications'] as bool?, + pinToTop: json['pin_to_top'] as bool, + emailAddress: json['email_address'] as String, + isMuted: json['is_muted'] as bool, + isWebPublic: json['is_web_public'] as bool?, color: json['color'] as String, - stream_post_policy: json['stream_post_policy'] as int, - message_retention_days: json['message_retention_days'] as int?, - history_public_to_subscribers: - json['history_public_to_subscribers'] as bool, - first_message_id: json['first_message_id'] as int?, - stream_weekly_traffic: json['stream_weekly_traffic'] as int?, - can_remove_subscribers_group_id: + streamPostPolicy: json['stream_post_policy'] as int, + messageRetentionDays: json['message_retention_days'] as int?, + historyPublicToSubscribers: json['history_public_to_subscribers'] as bool, + firstMessageId: json['first_message_id'] as int?, + streamWeeklyTraffic: json['stream_weekly_traffic'] as int?, + canRemoveSubscribersGroupId: json['can_remove_subscribers_group_id'] as int?, ); Map _$SubscriptionToJson(Subscription instance) => { - 'stream_id': instance.stream_id, + 'stream_id': instance.streamId, 'name': instance.name, 'description': instance.description, - 'rendered_description': instance.rendered_description, - 'date_created': instance.date_created, - 'invite_only': instance.invite_only, - 'desktop_notifications': instance.desktop_notifications, - 'email_notifications': instance.email_notifications, - 'wildcard_mentions_notify': instance.wildcard_mentions_notify, - 'push_notifications': instance.push_notifications, - 'audible_notifications': instance.audible_notifications, - 'pin_to_top': instance.pin_to_top, - 'email_address': instance.email_address, - 'is_muted': instance.is_muted, - 'is_web_public': instance.is_web_public, + 'rendered_description': instance.renderedDescription, + 'date_created': instance.dateCreated, + 'invite_only': instance.inviteOnly, + 'desktop_notifications': instance.desktopNotifications, + 'email_notifications': instance.emailNotifications, + 'wildcard_mentions_notify': instance.wildcardMentionsNotify, + 'push_notifications': instance.pushNotifications, + 'audible_notifications': instance.audibleNotifications, + 'pin_to_top': instance.pinToTop, + 'email_address': instance.emailAddress, + 'is_muted': instance.isMuted, + 'is_web_public': instance.isWebPublic, 'color': instance.color, - 'stream_post_policy': instance.stream_post_policy, - 'message_retention_days': instance.message_retention_days, - 'history_public_to_subscribers': instance.history_public_to_subscribers, - 'first_message_id': instance.first_message_id, - 'stream_weekly_traffic': instance.stream_weekly_traffic, - 'can_remove_subscribers_group_id': - instance.can_remove_subscribers_group_id, + 'stream_post_policy': instance.streamPostPolicy, + 'message_retention_days': instance.messageRetentionDays, + 'history_public_to_subscribers': instance.historyPublicToSubscribers, + 'first_message_id': instance.firstMessageId, + 'stream_weekly_traffic': instance.streamWeeklyTraffic, + 'can_remove_subscribers_group_id': instance.canRemoveSubscribersGroupId, }; StreamMessage _$StreamMessageFromJson(Map json) => StreamMessage( - avatar_url: json['avatar_url'] as String?, + avatarUrl: json['avatar_url'] as String?, client: json['client'] as String, content: json['content'] as String, - content_type: json['content_type'] as String, + contentType: json['content_type'] as String, id: json['id'] as int, - is_me_message: json['is_me_message'] as bool, - last_edit_timestamp: json['last_edit_timestamp'] as int?, - recipient_id: json['recipient_id'] as int, - sender_email: json['sender_email'] as String, - sender_full_name: json['sender_full_name'] as String, - sender_id: json['sender_id'] as int, - sender_realm_str: json['sender_realm_str'] as String, + isMeMessage: json['is_me_message'] as bool, + lastEditTimestamp: json['last_edit_timestamp'] as int?, + recipientId: json['recipient_id'] as int, + senderEmail: json['sender_email'] as String, + senderFullName: json['sender_full_name'] as String, + senderId: json['sender_id'] as int, + senderRealmStr: json['sender_realm_str'] as String, subject: json['subject'] as String, timestamp: json['timestamp'] as int, flags: (json['flags'] as List).map((e) => e as String).toList(), - match_content: json['match_content'] as String?, - match_subject: json['match_subject'] as String?, - display_recipient: json['display_recipient'] as String, - stream_id: json['stream_id'] as int, + matchContent: json['match_content'] as String?, + matchSubject: json['match_subject'] as String?, + displayRecipient: json['display_recipient'] as String, + streamId: json['stream_id'] as int, ); Map _$StreamMessageToJson(StreamMessage instance) => { - 'avatar_url': instance.avatar_url, + 'avatar_url': instance.avatarUrl, 'client': instance.client, 'content': instance.content, - 'content_type': instance.content_type, + 'content_type': instance.contentType, 'id': instance.id, - 'is_me_message': instance.is_me_message, - 'last_edit_timestamp': instance.last_edit_timestamp, - 'recipient_id': instance.recipient_id, - 'sender_email': instance.sender_email, - 'sender_full_name': instance.sender_full_name, - 'sender_id': instance.sender_id, - 'sender_realm_str': instance.sender_realm_str, + 'is_me_message': instance.isMeMessage, + 'last_edit_timestamp': instance.lastEditTimestamp, + 'recipient_id': instance.recipientId, + 'sender_email': instance.senderEmail, + 'sender_full_name': instance.senderFullName, + 'sender_id': instance.senderId, + 'sender_realm_str': instance.senderRealmStr, 'subject': instance.subject, 'timestamp': instance.timestamp, 'flags': instance.flags, - 'match_content': instance.match_content, - 'match_subject': instance.match_subject, + 'match_content': instance.matchContent, + 'match_subject': instance.matchSubject, 'type': instance.type, - 'display_recipient': instance.display_recipient, - 'stream_id': instance.stream_id, + 'display_recipient': instance.displayRecipient, + 'stream_id': instance.streamId, }; PmRecipient _$PmRecipientFromJson(Map json) => PmRecipient( id: json['id'] as int, email: json['email'] as String, - full_name: json['full_name'] as String, + fullName: json['full_name'] as String, ); Map _$PmRecipientToJson(PmRecipient instance) => { 'id': instance.id, 'email': instance.email, - 'full_name': instance.full_name, + 'full_name': instance.fullName, }; PmMessage _$PmMessageFromJson(Map json) => PmMessage( - avatar_url: json['avatar_url'] as String?, + avatarUrl: json['avatar_url'] as String?, client: json['client'] as String, content: json['content'] as String, - content_type: json['content_type'] as String, + contentType: json['content_type'] as String, id: json['id'] as int, - is_me_message: json['is_me_message'] as bool, - last_edit_timestamp: json['last_edit_timestamp'] as int?, - recipient_id: json['recipient_id'] as int, - sender_email: json['sender_email'] as String, - sender_full_name: json['sender_full_name'] as String, - sender_id: json['sender_id'] as int, - sender_realm_str: json['sender_realm_str'] as String, + isMeMessage: json['is_me_message'] as bool, + lastEditTimestamp: json['last_edit_timestamp'] as int?, + recipientId: json['recipient_id'] as int, + senderEmail: json['sender_email'] as String, + senderFullName: json['sender_full_name'] as String, + senderId: json['sender_id'] as int, + senderRealmStr: json['sender_realm_str'] as String, subject: json['subject'] as String, timestamp: json['timestamp'] as int, flags: (json['flags'] as List).map((e) => e as String).toList(), - match_content: json['match_content'] as String?, - match_subject: json['match_subject'] as String?, - display_recipient: (json['display_recipient'] as List) + matchContent: json['match_content'] as String?, + matchSubject: json['match_subject'] as String?, + displayRecipient: (json['display_recipient'] as List) .map((e) => PmRecipient.fromJson(e as Map)) .toList(), ); Map _$PmMessageToJson(PmMessage instance) => { - 'avatar_url': instance.avatar_url, + 'avatar_url': instance.avatarUrl, 'client': instance.client, 'content': instance.content, - 'content_type': instance.content_type, + 'content_type': instance.contentType, 'id': instance.id, - 'is_me_message': instance.is_me_message, - 'last_edit_timestamp': instance.last_edit_timestamp, - 'recipient_id': instance.recipient_id, - 'sender_email': instance.sender_email, - 'sender_full_name': instance.sender_full_name, - 'sender_id': instance.sender_id, - 'sender_realm_str': instance.sender_realm_str, + 'is_me_message': instance.isMeMessage, + 'last_edit_timestamp': instance.lastEditTimestamp, + 'recipient_id': instance.recipientId, + 'sender_email': instance.senderEmail, + 'sender_full_name': instance.senderFullName, + 'sender_id': instance.senderId, + 'sender_realm_str': instance.senderRealmStr, 'subject': instance.subject, 'timestamp': instance.timestamp, 'flags': instance.flags, - 'match_content': instance.match_content, - 'match_subject': instance.match_subject, + 'match_content': instance.matchContent, + 'match_subject': instance.matchSubject, 'type': instance.type, - 'display_recipient': instance.display_recipient, + 'display_recipient': instance.displayRecipient, }; diff --git a/lib/api/route/account.dart b/lib/api/route/account.dart index cec8244ef4..a5f552d6bd 100644 --- a/lib/api/route/account.dart +++ b/lib/api/route/account.dart @@ -1,5 +1,3 @@ -// ignore_for_file: non_constant_identifier_names - import 'dart:convert'; import 'package:json_annotation/json_annotation.dart'; @@ -33,10 +31,10 @@ Future fetchApiKey({ @JsonSerializable(fieldRename: FieldRename.snake) class FetchApiKeyResult { - final String api_key; + final String apiKey; final String email; - FetchApiKeyResult({required this.api_key, required this.email}); + FetchApiKeyResult({required this.apiKey, required this.email}); factory FetchApiKeyResult.fromJson(Map json) => _$FetchApiKeyResultFromJson(json); diff --git a/lib/api/route/account.g.dart b/lib/api/route/account.g.dart index 1a93f01d4b..7673770bbe 100644 --- a/lib/api/route/account.g.dart +++ b/lib/api/route/account.g.dart @@ -8,12 +8,12 @@ part of 'account.dart'; FetchApiKeyResult _$FetchApiKeyResultFromJson(Map json) => FetchApiKeyResult( - api_key: json['api_key'] as String, + apiKey: json['api_key'] as String, email: json['email'] as String, ); Map _$FetchApiKeyResultToJson(FetchApiKeyResult instance) => { - 'api_key': instance.api_key, + 'api_key': instance.apiKey, 'email': instance.email, }; diff --git a/lib/api/route/events.dart b/lib/api/route/events.dart index 462d762ec8..af961d92ac 100644 --- a/lib/api/route/events.dart +++ b/lib/api/route/events.dart @@ -1,5 +1,3 @@ -// ignore_for_file: non_constant_identifier_names - import 'dart:convert'; import 'package:json_annotation/json_annotation.dart'; @@ -29,12 +27,12 @@ Future registerQueue(ApiConnection connection) async { /// https://zulip.com/api/get-events Future getEvents(ApiConnection connection, { - required String queue_id, int? last_event_id, bool? dont_block, + required String queueId, int? lastEventId, bool? dontBlock, }) async { final data = await connection.get('events', { - 'queue_id': RawParameter(queue_id), - if (last_event_id != null) 'last_event_id': last_event_id, - if (dont_block != null) 'dont_block': dont_block, + 'queue_id': RawParameter(queueId), + if (lastEventId != null) 'last_event_id': lastEventId, + if (dontBlock != null) 'dont_block': dontBlock, }); return GetEventsResult.fromJson(jsonDecode(data)); } @@ -42,12 +40,12 @@ Future getEvents(ApiConnection connection, { @JsonSerializable(fieldRename: FieldRename.snake) class GetEventsResult { final List events; - // TODO(server): Docs say queue_id required; empirically sometimes missing. - final String? queue_id; + // TODO(server): Docs say queueId required; empirically sometimes missing. + final String? queueId; GetEventsResult({ required this.events, - this.queue_id, + this.queueId, }); factory GetEventsResult.fromJson(Map json) => diff --git a/lib/api/route/events.g.dart b/lib/api/route/events.g.dart index 38183ebde5..2a10afbb0f 100644 --- a/lib/api/route/events.g.dart +++ b/lib/api/route/events.g.dart @@ -11,11 +11,11 @@ GetEventsResult _$GetEventsResultFromJson(Map json) => events: (json['events'] as List) .map((e) => Event.fromJson(e as Map)) .toList(), - queue_id: json['queue_id'] as String?, + queueId: json['queue_id'] as String?, ); Map _$GetEventsResultToJson(GetEventsResult instance) => { 'events': instance.events, - 'queue_id': instance.queue_id, + 'queue_id': instance.queueId, }; diff --git a/lib/api/route/messages.dart b/lib/api/route/messages.dart index 8afa3bd622..62f4d0b711 100644 --- a/lib/api/route/messages.dart +++ b/lib/api/route/messages.dart @@ -1,5 +1,3 @@ -// ignore_for_file: non_constant_identifier_names - import 'dart:convert'; import 'package:json_annotation/json_annotation.dart'; @@ -11,14 +9,14 @@ part 'messages.g.dart'; /// https://zulip.com/api/get-messages Future getMessages(ApiConnection connection, { - required int num_before, - required int num_after, + required int numBefore, + required int numAfter, }) async { final data = await connection.get('messages', { // 'narrow': [], // TODO parametrize 'anchor': 999999999, // TODO parametrize; use RawParameter for strings - 'num_before': num_before, - 'num_after': num_after, + 'num_before': numBefore, + 'num_after': numAfter, }); return GetMessagesResult.fromJson(jsonDecode(data)); } @@ -26,18 +24,18 @@ Future getMessages(ApiConnection connection, { @JsonSerializable(fieldRename: FieldRename.snake) class GetMessagesResult { final int anchor; - final bool found_newest; - final bool found_oldest; - final bool found_anchor; - final bool history_limited; + final bool foundNewest; + final bool foundOldest; + final bool foundAnchor; + final bool historyLimited; final List messages; GetMessagesResult({ required this.anchor, - required this.found_newest, - required this.found_oldest, - required this.found_anchor, - required this.history_limited, + required this.foundNewest, + required this.foundOldest, + required this.foundAnchor, + required this.historyLimited, required this.messages, }); @@ -87,11 +85,11 @@ Future sendMessage( @JsonSerializable(fieldRename: FieldRename.snake) class SendMessageResult { final int id; - final String? deliver_at; + final String? deliverAt; SendMessageResult({ required this.id, - this.deliver_at, + this.deliverAt, }); factory SendMessageResult.fromJson(Map json) => diff --git a/lib/api/route/messages.g.dart b/lib/api/route/messages.g.dart index 79b94f74f7..fe929c9278 100644 --- a/lib/api/route/messages.g.dart +++ b/lib/api/route/messages.g.dart @@ -9,10 +9,10 @@ part of 'messages.dart'; GetMessagesResult _$GetMessagesResultFromJson(Map json) => GetMessagesResult( anchor: json['anchor'] as int, - found_newest: json['found_newest'] as bool, - found_oldest: json['found_oldest'] as bool, - found_anchor: json['found_anchor'] as bool, - history_limited: json['history_limited'] as bool, + foundNewest: json['found_newest'] as bool, + foundOldest: json['found_oldest'] as bool, + foundAnchor: json['found_anchor'] as bool, + historyLimited: json['history_limited'] as bool, messages: (json['messages'] as List) .map((e) => Message.fromJson(e as Map)) .toList(), @@ -21,21 +21,21 @@ GetMessagesResult _$GetMessagesResultFromJson(Map json) => Map _$GetMessagesResultToJson(GetMessagesResult instance) => { 'anchor': instance.anchor, - 'found_newest': instance.found_newest, - 'found_oldest': instance.found_oldest, - 'found_anchor': instance.found_anchor, - 'history_limited': instance.history_limited, + 'found_newest': instance.foundNewest, + 'found_oldest': instance.foundOldest, + 'found_anchor': instance.foundAnchor, + 'history_limited': instance.historyLimited, 'messages': instance.messages, }; SendMessageResult _$SendMessageResultFromJson(Map json) => SendMessageResult( id: json['id'] as int, - deliver_at: json['deliver_at'] as String?, + deliverAt: json['deliver_at'] as String?, ); Map _$SendMessageResultToJson(SendMessageResult instance) => { 'id': instance.id, - 'deliver_at': instance.deliver_at, + 'deliver_at': instance.deliverAt, }; diff --git a/lib/model/message_list.dart b/lib/model/message_list.dart index 4a8941d14b..b2c9109d4a 100644 --- a/lib/model/message_list.dart +++ b/lib/model/message_list.dart @@ -58,7 +58,7 @@ class MessageListView extends ChangeNotifier { assert(contents.isEmpty); // TODO schedule all this in another isolate final result = - await getMessages(store.connection, num_before: 100, num_after: 10); + await getMessages(store.connection, numBefore: 100, numAfter: 10); messages.addAll(result.messages); contents.addAll(_contentsOfMessages(result.messages)); _fetched = true; diff --git a/lib/model/store.dart b/lib/model/store.dart index 1e66875cfd..1aa599a4cc 100644 --- a/lib/model/store.dart +++ b/lib/model/store.dart @@ -1,5 +1,3 @@ -// ignore_for_file: non_constant_identifier_names - import 'dart:convert'; import 'package:flutter/foundation.dart'; @@ -142,14 +140,14 @@ class PerAccountStore extends ChangeNotifier { required this.account, required this.connection, required InitialSnapshot initialSnapshot, - }) : zulip_version = initialSnapshot.zulip_version, + }) : zulipVersion = initialSnapshot.zulipVersion, subscriptions = Map.fromEntries(initialSnapshot.subscriptions.map( - (subscription) => MapEntry(subscription.stream_id, subscription))); + (subscription) => MapEntry(subscription.streamId, subscription))); final Account account; final ApiConnection connection; - final String zulip_version; + final String zulipVersion; final Map subscriptions; // TODO lots more data. When adding, be sure to update handleEvent too. @@ -250,12 +248,12 @@ class LivePerAccountStore extends PerAccountStore { required super.account, required super.connection, required super.initialSnapshot, - }) : queue_id = initialSnapshot.queue_id ?? (() { - // The queue_id is optional in the type, but should only be missing in the + }) : queueId = initialSnapshot.queueId ?? (() { + // The queueId is optional in the type, but should only be missing in the // case of unauthenticated access to a web-public realm. We authenticated. - throw Exception("bad initial snapshot: missing queue_id"); + throw Exception("bad initial snapshot: missing queueId"); })(), - last_event_id = initialSnapshot.last_event_id, + lastEventId = initialSnapshot.lastEventId, super.fromInitialSnapshot(); /// Load the user's data from the server, and start an event queue going. @@ -279,13 +277,13 @@ class LivePerAccountStore extends PerAccountStore { return store; } - final String queue_id; - int last_event_id; + final String queueId; + int lastEventId; void poll() async { while (true) { final result = await getEvents(connection, - queue_id: queue_id, last_event_id: last_event_id); + queueId: queueId, lastEventId: lastEventId); // TODO handle errors on get-events; retry with backoff // TODO abort long-poll on [dispose] final events = result.events; @@ -293,7 +291,7 @@ class LivePerAccountStore extends PerAccountStore { handleEvent(event); } if (events.isNotEmpty) { - last_event_id = events.last.id; + lastEventId = events.last.id; } } } diff --git a/lib/widgets/app.dart b/lib/widgets/app.dart index 9fc1e708dc..782854c704 100644 --- a/lib/widgets/app.dart +++ b/lib/widgets/app.dart @@ -106,7 +106,7 @@ class HomePage extends StatelessWidget { children: [bold(store.account.realmUrl)])), Text.rich(TextSpan( text: 'Zulip server version: ', - children: [bold(store.zulip_version)])), + children: [bold(store.zulipVersion)])), Text.rich(TextSpan(text: 'Subscribed to ', children: [ bold(store.subscriptions.length.toString()), const TextSpan(text: ' streams'), diff --git a/lib/widgets/lightbox.dart b/lib/widgets/lightbox.dart index 175a7bcb66..cf9eadbba3 100644 --- a/lib/widgets/lightbox.dart +++ b/lib/widgets/lightbox.dart @@ -151,7 +151,7 @@ class _LightboxPageState extends State<_LightboxPage> { text: TextSpan( children: [ TextSpan( - text: '${widget.message.sender_full_name}\n', + text: '${widget.message.senderFullName}\n', // Restate default style: themeData.textTheme.titleLarge!.copyWith(color: appBarForegroundColor)), diff --git a/lib/widgets/login.dart b/lib/widgets/login.dart index ba0c9ebe9b..ff29b98baa 100644 --- a/lib/widgets/login.dart +++ b/lib/widgets/login.dart @@ -112,7 +112,7 @@ class _EmailPasswordLoginPageState extends State { } final account = Account( - realmUrl: realmUrl.toString(), email: result.email, apiKey: result.api_key); + realmUrl: realmUrl.toString(), email: result.email, apiKey: result.apiKey); final globalStore = GlobalStoreWidget.of(context); final accountId = await globalStore.insertAccount(account); if (context.mounted) {} // https://github.com/dart-lang/linter/issues/4007 diff --git a/lib/widgets/message_list.dart b/lib/widgets/message_list.dart index 087527890a..a164459f90 100644 --- a/lib/widgets/message_list.dart +++ b/lib/widgets/message_list.dart @@ -131,7 +131,7 @@ class MessageItem extends StatelessWidget { Widget recipientHeader; if (message is StreamMessage) { final msg = (message as StreamMessage); - final subscription = store.subscriptions[msg.stream_id]; + final subscription = store.subscriptions[msg.streamId]; highlightBorderColor = colorForStream(subscription); restBorderColor = _kStreamMessageBorderColor; recipientHeader = StreamTopicRecipientHeader( @@ -200,7 +200,7 @@ class StreamTopicRecipientHeader extends StatelessWidget { @override Widget build(BuildContext context) { - final streamName = message.display_recipient; // TODO get from stream data + final streamName = message.displayRecipient; // TODO get from stream data final topic = message.subject; final contrastingColor = ThemeData.estimateBrightnessForColor(streamColor) == Brightness.dark @@ -288,9 +288,9 @@ class MessageWithSender extends StatelessWidget { Widget build(BuildContext context) { final store = PerAccountStoreWidget.of(context); - final avatarUrl = message.avatar_url == null // TODO get from user data + final avatarUrl = message.avatarUrl == null // TODO get from user data ? null // TODO handle computing gravatars - : resolveUrl(message.avatar_url!, store.account); + : resolveUrl(message.avatarUrl!, store.account); final avatar = (avatarUrl == null) ? const SizedBox.shrink() : RealmContentNetworkImage( @@ -322,7 +322,7 @@ class MessageWithSender extends StatelessWidget { crossAxisAlignment: CrossAxisAlignment.stretch, children: [ const SizedBox(height: 3), - Text(message.sender_full_name, // TODO get from user data + Text(message.senderFullName, // TODO get from user data style: const TextStyle(fontWeight: FontWeight.bold)), const SizedBox(height: 4), MessageContent(message: message, content: content), diff --git a/test/api/model/events_checks.dart b/test/api/model/events_checks.dart index 82e0256f0a..a7e9440916 100644 --- a/test/api/model/events_checks.dart +++ b/test/api/model/events_checks.dart @@ -1,5 +1,3 @@ -// ignore_for_file: non_constant_identifier_names - import 'package:checks/checks.dart'; import 'package:zulip/api/model/events.dart'; import 'package:zulip/api/model/model.dart'; @@ -14,7 +12,7 @@ extension UnexpectedEventChecks on Subject { } extension AlertWordsEventChecks on Subject { - Subject> get alert_words => has((e) => e.alert_words, 'alert_words'); + Subject> get alertWords => has((e) => e.alertWords, 'alertWords'); } extension MessageEventChecks on Subject { diff --git a/test/api/route/route_checks.dart b/test/api/route/route_checks.dart index ee3dc67580..8fe2b7fa6f 100644 --- a/test/api/route/route_checks.dart +++ b/test/api/route/route_checks.dart @@ -1,11 +1,9 @@ -// ignore_for_file: non_constant_identifier_names - import 'package:checks/checks.dart'; import 'package:zulip/api/route/messages.dart'; extension SendMessageResultChecks on Subject { Subject get id => has((e) => e.id, 'id'); - Subject get deliver_at => has((e) => e.deliver_at, 'deliver_at'); + Subject get deliverAt => has((e) => e.deliverAt, 'deliverAt'); } // TODO add similar extensions for other classes in api/route/*.dart diff --git a/test/example_data.dart b/test/example_data.dart index 125d391240..1ed93f9fde 100644 --- a/test/example_data.dart +++ b/test/example_data.dart @@ -57,12 +57,12 @@ StreamMessage streamMessage( // TODO example data for many more types final InitialSnapshot initialSnapshot = InitialSnapshot( - queue_id: '1:2345', - last_event_id: 1, - zulip_feature_level: recentZulipFeatureLevel, - zulip_version: recentZulipVersion, - zulip_merge_base: recentZulipVersion, - alert_words: ['klaxon'], - custom_profile_fields: [], + queueId: '1:2345', + lastEventId: 1, + zulipFeatureLevel: recentZulipFeatureLevel, + zulipVersion: recentZulipVersion, + zulipMergeBase: recentZulipVersion, + alertWords: ['klaxon'], + customProfileFields: [], subscriptions: [], // TODO add subscriptions to example initial snapshot ); From bd8e59d14234e4d647150e8f5ff6f7ea517a4dd2 Mon Sep 17 00:00:00 2001 From: Greg Price Date: Wed, 5 Apr 2023 15:13:21 -0700 Subject: [PATCH 3/3] store: Use camel case for fixture credentials, too This is non-NFC because one needs to update `credential_fixture.dart`. (That's something I don't expect to happen more than once or twice more before we're able to do away with that mechanism entirely.) --- README.md | 5 ++--- lib/model/store.dart | 4 ++-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index aba7cecf4f..5cd788da4e 100644 --- a/README.md +++ b/README.md @@ -49,10 +49,9 @@ to use, and [download a `.zuliprc` file][download-zuliprc]. Then create a file `lib/credential_fixture.dart` in this worktree with the following form: ```dart -// ignore_for_file: constant_identifier_names -const String realm_url = '…'; +const String realmUrl = '…'; const String email = '…'; -const String api_key = '…'; +const String apiKey = '…'; ``` Now build and run the app (see "Flutter help" above), and things diff --git a/lib/model/store.dart b/lib/model/store.dart index 1aa599a4cc..9766ddddc2 100644 --- a/lib/model/store.dart +++ b/lib/model/store.dart @@ -237,9 +237,9 @@ class LiveGlobalStore extends GlobalStore { /// See "Server credentials" in the project README for how to fill in the /// `credential_fixture.dart` file this requires. const Account _fixtureAccount = Account( - realmUrl: credentials.realm_url, + realmUrl: credentials.realmUrl, email: credentials.email, - apiKey: credentials.api_key, + apiKey: credentials.apiKey, ); /// A [PerAccountStore] which polls an event queue to stay up to date.