@shaxpir/duiduidui-models 1.24.2 → 1.24.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -63,9 +63,9 @@ export interface ChatScratchpad {
63
63
  }
64
64
  export interface ChatStub {
65
65
  id: ContentId;
66
- title?: string;
66
+ title: string | null;
67
67
  participants: SocialUser[];
68
- last_message_preview?: string;
68
+ last_message_preview: string | null;
69
69
  updated_at: CompactDateTime;
70
70
  has_unread: {
71
71
  [user_id: string]: boolean;
@@ -62,17 +62,16 @@ class Chat extends SharedContent_1.SharedContent {
62
62
  for (const userId of userIds) {
63
63
  try {
64
64
  const workspaceId = shaxpir_common_1.CachingHasher.makeMd5Base62Hash(userId + "-" + ContentKind_1.ContentKind.WORKSPACE);
65
- const workspace = this.shareSync.load(ContentKind_1.ContentKind.WORKSPACE, workspaceId);
66
- if (workspace) {
67
- await workspace.acquire();
68
- if (workspace.exists()) {
69
- workspace.upsertChatStub(stub);
70
- }
65
+ const workspace = await this.shareSync.acquire(ContentKind_1.ContentKind.WORKSPACE, workspaceId);
66
+ if (workspace && workspace.exists()) {
67
+ // Cast needed to avoid circular dependency between Chat and Workspace
68
+ workspace.upsertChatStub(stub);
71
69
  workspace.release();
72
70
  }
73
71
  }
74
72
  catch {
75
- // Workspace may not exist yet for this user
73
+ // Workspace may not exist yet for this user — this is expected
74
+ // during initial account setup before the workspace is created.
76
75
  }
77
76
  }
78
77
  }
@@ -166,7 +165,7 @@ class Chat extends SharedContent_1.SharedContent {
166
165
  toStub() {
167
166
  this.checkDisposed('Chat.toStub');
168
167
  const msgs = this.messages.values;
169
- let preview;
168
+ let preview = null;
170
169
  if (msgs.length > 0) {
171
170
  const lastMsg = msgs[msgs.length - 1];
172
171
  const textBlock = lastMsg.content.find(b => b.type === 'text');
@@ -181,7 +180,7 @@ class Chat extends SharedContent_1.SharedContent {
181
180
  }
182
181
  return {
183
182
  id: this.id,
184
- title: this.title,
183
+ title: this.title || null,
185
184
  participants: this.participants.values,
186
185
  last_message_preview: preview,
187
186
  updated_at: this.updatedAt.utc_time,
@@ -31,9 +31,8 @@ class SharedContent extends Content_1.Content {
31
31
  const userIds = this.getAllSharedUserIds();
32
32
  for (const userId of userIds) {
33
33
  const manifestId = Manifest_1.Manifest.makeManifestId(userId);
34
- const manifest = this.shareSync.load(ContentKind_1.ContentKind.MANIFEST, manifestId);
35
- if (manifest) {
36
- await manifest.acquire();
34
+ const manifest = await this.shareSync.acquire(ContentKind_1.ContentKind.MANIFEST, manifestId);
35
+ if (manifest && manifest.exists()) {
37
36
  manifest.update(this);
38
37
  manifest.release();
39
38
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shaxpir/duiduidui-models",
3
- "version": "1.24.2",
3
+ "version": "1.24.4",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/shaxpir/duiduidui-models"