Skip to content

Commit ecbbd6d

Browse files
committed
api: Drop legacy support for prev_subject and topic from edit history, 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 1ad07dd commit ecbbd6d

File tree

2 files changed

+6
-19
lines changed

2 files changed

+6
-19
lines changed

lib/api/model/model.dart

+6-9
Original file line numberDiff line numberDiff line change
@@ -826,16 +826,13 @@ enum MessageEditState {
826826
continue;
827827
}
828828

829-
// TODO(server-5) prev_subject was the old name of prev_topic on pre-5.0 servers
830-
final prevTopic = (entry['prev_topic'] ?? entry['prev_subject']) as String?;
829+
final prevTopic = entry['prev_topic'] as String?;
831830
final topic = entry['topic'] as String?;
832-
if (prevTopic != null) {
833-
// TODO(server-5) pre-5.0 servers do not have the 'topic' field
834-
if (topic == null) {
835-
hasMoved = true;
836-
} else {
837-
hasMoved |= !topicMoveWasResolveOrUnresolve(topic, prevTopic);
838-
}
831+
if (topic != null || prevTopic != null) {
832+
// Crunchy-shell validation: Both are present if the topic was edited
833+
topic as String;
834+
prevTopic as String;
835+
hasMoved |= !topicMoveWasResolveOrUnresolve(topic, prevTopic);
839836
}
840837
}
841838

test/api/model/model_test.dart

-10
Original file line numberDiff line numberDiff line change
@@ -284,16 +284,6 @@ void main() {
284284
checkEditState(MessageEditState.edited,
285285
[{'prev_content': 'old_content'}]);
286286
});
287-
288-
test("'prev_topic' present without the 'topic' field -> moved", () {
289-
checkEditState(MessageEditState.moved,
290-
[{'prev_topic': 'old_topic'}]);
291-
});
292-
293-
test("'prev_subject' present from a pre-5.0 server -> moved", () {
294-
checkEditState(MessageEditState.moved,
295-
[{'prev_subject': 'old_topic'}]);
296-
});
297287
});
298288

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

0 commit comments

Comments
 (0)