Skip to content

Commit 88a0440

Browse files
committed
api: Add savedSnippets to initial snapshot
Signed-off-by: Zixuan James Li <[email protected]>
1 parent 0767d0f commit 88a0440

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;
@@ -129,6 +131,7 @@ class InitialSnapshot {
129131
required this.serverTypingStartedWaitPeriodMilliseconds,
130132
required this.realmEmoji,
131133
required this.recentPrivateConversations,
134+
required this.savedSnippets,
132135
required this.subscriptions,
133136
required this.unreadMsgs,
134137
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
@@ -310,6 +310,30 @@ enum UserRole{
310310
}
311311
}
312312

313+
/// An item in `saved_snippets` from the initial snapshot.
314+
///
315+
/// For docs, search for "saved_snippets:"
316+
/// in <https://zulip.com/api/register-queue>.
317+
@JsonSerializable(fieldRename: FieldRename.snake)
318+
class SavedSnippet {
319+
SavedSnippet({
320+
required this.id,
321+
required this.title,
322+
required this.content,
323+
required this.dateCreated,
324+
});
325+
326+
final int id;
327+
final String title;
328+
final String content;
329+
final int dateCreated;
330+
331+
factory SavedSnippet.fromJson(Map<String, Object?> json) =>
332+
_$SavedSnippetFromJson(json);
333+
334+
Map<String, dynamic> toJson() => _$SavedSnippetToJson(this);
335+
}
336+
313337
/// As in `streams` in the initial snapshot.
314338
///
315339
/// 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
@@ -910,6 +910,7 @@ InitialSnapshot initialSnapshot({
910910
int? serverTypingStartedWaitPeriodMilliseconds,
911911
Map<String, RealmEmojiItem>? realmEmoji,
912912
List<RecentDmConversation>? recentPrivateConversations,
913+
List<SavedSnippet>? savedSnippets,
913914
List<Subscription>? subscriptions,
914915
UnreadMessagesSnapshot? unreadMsgs,
915916
List<ZulipStream>? streams,
@@ -943,6 +944,7 @@ InitialSnapshot initialSnapshot({
943944
serverTypingStartedWaitPeriodMilliseconds ?? 10000,
944945
realmEmoji: realmEmoji ?? {},
945946
recentPrivateConversations: recentPrivateConversations ?? [],
947+
savedSnippets: savedSnippets ?? [],
946948
subscriptions: subscriptions ?? [], // TODO add subscriptions to default
947949
unreadMsgs: unreadMsgs ?? _unreadMsgs(),
948950
streams: streams ?? [], // TODO add streams to default

0 commit comments

Comments
 (0)