Skip to content

Commit b2d935e

Browse files
committed
api: Add savedSnippets to initial snapshot
1 parent 9689dce commit b2d935e

File tree

5 files changed

+49
-0
lines changed

5 files changed

+49
-0
lines changed

lib/api/model/initial_snapshot.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ class InitialSnapshot {
4848

4949
final List<RecentDmConversation> recentPrivateConversations;
5050

51+
final List<SavedSnippet>? savedSnippets; // TODO(server-10)
52+
5153
final List<Subscription> subscriptions;
5254

5355
final UnreadMessagesSnapshot unreadMsgs;
@@ -132,6 +134,7 @@ class InitialSnapshot {
132134
required this.serverTypingStartedWaitPeriodMilliseconds,
133135
required this.realmEmoji,
134136
required this.recentPrivateConversations,
137+
required this.savedSnippets,
135138
required this.subscriptions,
136139
required this.unreadMsgs,
137140
required this.streams,

lib/api/model/initial_snapshot.g.dart

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/api/model/model.dart

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,30 @@ enum UserRole{
311311
}
312312
}
313313

314+
/// An item in `saved_snippets` from the initial snapshot.
315+
///
316+
/// For docs, search for "saved_snippets:"
317+
/// in <https://zulip.com/api/register-queue>.
318+
@JsonSerializable(fieldRename: FieldRename.snake)
319+
class SavedSnippet {
320+
SavedSnippet({
321+
required this.id,
322+
required this.title,
323+
required this.content,
324+
required this.dateCreated,
325+
});
326+
327+
final int id;
328+
final String title;
329+
final String content;
330+
final int dateCreated;
331+
332+
factory SavedSnippet.fromJson(Map<String, Object?> json) =>
333+
_$SavedSnippetFromJson(json);
334+
335+
Map<String, dynamic> toJson() => _$SavedSnippetToJson(this);
336+
}
337+
314338
/// As in `streams` in the initial snapshot.
315339
///
316340
/// Not called `Stream` because dart:async uses that name.

lib/api/model/model.g.dart

Lines changed: 15 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/example_data.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -923,6 +923,7 @@ InitialSnapshot initialSnapshot({
923923
int? serverTypingStartedWaitPeriodMilliseconds,
924924
Map<String, RealmEmojiItem>? realmEmoji,
925925
List<RecentDmConversation>? recentPrivateConversations,
926+
List<SavedSnippet>? savedSnippets,
926927
List<Subscription>? subscriptions,
927928
UnreadMessagesSnapshot? unreadMsgs,
928929
List<ZulipStream>? streams,
@@ -958,6 +959,7 @@ InitialSnapshot initialSnapshot({
958959
serverTypingStartedWaitPeriodMilliseconds ?? 10000,
959960
realmEmoji: realmEmoji ?? {},
960961
recentPrivateConversations: recentPrivateConversations ?? [],
962+
savedSnippets: savedSnippets ?? [],
961963
subscriptions: subscriptions ?? [], // TODO add subscriptions to default
962964
unreadMsgs: unreadMsgs ?? _unreadMsgs(),
963965
streams: streams ?? [], // TODO add streams to default

0 commit comments

Comments
 (0)