Skip to content

Commit e5df278

Browse files
committed
api: Drop legacy support for prev_subject and topic, relying on server 5+, FL 118+
"topic" is no longer optional when the topic was edited, we also don't need to expect "prev_subject" as opposed to "prev_topic". See "Feature level 118" from Zulip API changelog: https://zulip.com/api/changelog See also: https://zulip.com/api/get-messages#response Signed-off-by: Zixuan James Li <[email protected]>
1 parent 1e7ae48 commit e5df278

File tree

2 files changed

+5
-19
lines changed

2 files changed

+5
-19
lines changed

lib/api/model/model.dart

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -824,16 +824,12 @@ enum MessageEditState {
824824
continue;
825825
}
826826

827-
// TODO(server-5) prev_subject was the old name of prev_topic on pre-5.0 servers
828-
final prevTopic = (entry['prev_topic'] ?? entry['prev_subject']) as String?;
827+
final prevTopic = entry['prev_topic'] as String?;
829828
final topic = entry['topic'] as String?;
830-
if (prevTopic != null) {
831-
// TODO(server-5) pre-5.0 servers do not have the 'topic' field
832-
if (topic == null) {
833-
hasMoved = true;
834-
} else {
835-
hasMoved |= !topicMoveWasResolveOrUnresolve(topic, prevTopic);
836-
}
829+
if (topic != null || prevTopic != null) {
830+
// Both are present if the topic was edited
831+
assert(topic != null && prevTopic != null);
832+
hasMoved |= !topicMoveWasResolveOrUnresolve(topic!, prevTopic!);
837833
}
838834
}
839835

test/api/model/model_test.dart

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -279,16 +279,6 @@ void main() {
279279
checkEditState(MessageEditState.edited,
280280
[{'prev_content': 'old_content'}]);
281281
});
282-
283-
test("'prev_topic' present without the 'topic' field -> moved", () {
284-
checkEditState(MessageEditState.moved,
285-
[{'prev_topic': 'old_topic'}]);
286-
});
287-
288-
test("'prev_subject' present from a pre-5.0 server -> moved", () {
289-
checkEditState(MessageEditState.moved,
290-
[{'prev_subject': 'old_topic'}]);
291-
});
292282
});
293283

294284
group('topic resolved in edit history', () {

0 commit comments

Comments
 (0)