Skip to content

Commit a7955ca

Browse files
committed
api [nfc]: Move resolved-topic-prefix constant onto TopicName
1 parent a252427 commit a7955ca

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

lib/api/model/model.dart

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -664,6 +664,11 @@ enum MessageFlag {
664664
// Using as a Map key is almost certainly a bug because it won't case-fold;
665665
// see for example #739, #980, #1205.
666666
extension type const TopicName(String _value) {
667+
/// The canonical form of the resolved-topic prefix.
668+
// This is RESOLVED_TOPIC_PREFIX in web:
669+
// https://github.com/zulip/zulip/blob/1fac99733/web/shared/src/resolved_topic.ts
670+
static const resolvedTopicPrefix = '✔ ';
671+
667672
/// The string this topic is identified by in the Zulip API.
668673
///
669674
/// This should be used in constructing HTTP requests to the server,
@@ -844,25 +849,20 @@ enum MessageEditState {
844849
edited,
845850
moved;
846851

847-
// Adapted from the shared code:
848-
// https://github.com/zulip/zulip/blob/1fac99733/web/shared/src/resolved_topic.ts
849-
// The canonical resolved-topic prefix.
850-
static const String _resolvedTopicPrefix = '✔ ';
851-
852852
/// Whether the given topic move reflected either a "resolve topic"
853853
/// or "unresolve topic" operation.
854854
///
855855
/// The Zulip "resolved topics" feature is implemented by renaming the topic;
856856
/// but for purposes of [Message.editState], we want to ignore such renames.
857857
/// This method identifies topic moves that should be ignored in that context.
858858
static bool topicMoveWasResolveOrUnresolve(TopicName topic, TopicName prevTopic) {
859-
if (topic.apiName.startsWith(_resolvedTopicPrefix)
860-
&& topic.apiName.substring(_resolvedTopicPrefix.length) == prevTopic.apiName) {
859+
if (topic.apiName.startsWith(TopicName.resolvedTopicPrefix)
860+
&& topic.apiName.substring(TopicName.resolvedTopicPrefix.length) == prevTopic.apiName) {
861861
return true;
862862
}
863863

864-
if (prevTopic.apiName.startsWith(_resolvedTopicPrefix)
865-
&& prevTopic.apiName.substring(_resolvedTopicPrefix.length) == topic.apiName) {
864+
if (prevTopic.apiName.startsWith(TopicName.resolvedTopicPrefix)
865+
&& prevTopic.apiName.substring(TopicName.resolvedTopicPrefix.length) == topic.apiName) {
866866
return true;
867867
}
868868

0 commit comments

Comments
 (0)