Skip to content

Commit 99c4b0b

Browse files
gnpricechrisbobbe
authored andcommitted
api [nfc]: Use TopicName type across request parameters
This completes the conversion to use the TopicName type in the places where it belongs. Next, we'll start making use of this new type distinction: instead of using a TopicName implicitly as a String, we'll introduce members corresponding to the different ways a topic name is used which are going to start having different behavior in the future. After that's complete, we can start enforcing the distinction in order to catch accidental future implicit uses as a String.
1 parent 54d5e1c commit 99c4b0b

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

lib/api/route/channels.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class GetStreamTopicsEntry {
4646
// TODO(server-7): remove this and just use updateUserTopic
4747
Future<void> updateUserTopicCompat(ApiConnection connection, {
4848
required int streamId,
49-
required String topic,
49+
required TopicName topic,
5050
required UserTopicVisibilityPolicy visibilityPolicy,
5151
}) {
5252
final useLegacyApi = connection.zulipFeatureLevel! < 170;
@@ -76,7 +76,7 @@ Future<void> updateUserTopicCompat(ApiConnection connection, {
7676
// TODO(server-7) remove FL 170+ mention in doc, and the related `assert`
7777
Future<void> updateUserTopic(ApiConnection connection, {
7878
required int streamId,
79-
required String topic,
79+
required TopicName topic,
8080
required UserTopicVisibilityPolicy visibilityPolicy,
8181
}) {
8282
assert(visibilityPolicy != UserTopicVisibilityPolicy.unknown);

lib/api/route/messages.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ class StreamDestination extends MessageDestination {
231231
const StreamDestination(this.streamId, this.topic);
232232

233233
final int streamId;
234-
final String topic;
234+
final TopicName topic;
235235
}
236236

237237
/// A DM conversation, for specifying to [sendMessage].
@@ -449,7 +449,7 @@ Future<void> markStreamAsRead(ApiConnection connection, {
449449
// TODO(server-6): Remove as deprecated by updateMessageFlagsForNarrow
450450
Future<void> markTopicAsRead(ApiConnection connection, {
451451
required int streamId,
452-
required String topicName,
452+
required TopicName topicName,
453453
}) {
454454
return connection.post('markTopicAsRead', (_) {}, 'mark_topic_as_read', {
455455
'stream_id': streamId,

0 commit comments

Comments
 (0)