Skip to content

Commit 6fb301a

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 2d475c6 commit 6fb301a

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
@@ -855,16 +855,13 @@ enum MessageEditState {
855855
continue;
856856
}
857857

858-
// TODO(server-5) prev_subject was the old name of prev_topic on pre-5.0 servers
859-
final prevTopic = (entry['prev_topic'] ?? entry['prev_subject']) as String?;
858+
final prevTopic = entry['prev_topic'] as String?;
860859
final topic = entry['topic'] as String?;
861-
if (prevTopic != null) {
862-
// TODO(server-5) pre-5.0 servers do not have the 'topic' field
863-
if (topic == null) {
864-
hasMoved = true;
865-
} else {
866-
hasMoved |= !topicMoveWasResolveOrUnresolve(topic, prevTopic);
867-
}
860+
if (topic != null || prevTopic != null) {
861+
// Crunchy-shell validation: Both are present if the topic was edited
862+
topic as String;
863+
prevTopic as String;
864+
hasMoved |= !topicMoveWasResolveOrUnresolve(topic, prevTopic);
868865
}
869866
}
870867

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)