@shaxpir/duiduidui-models 1.24.2 → 1.24.3

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,12 +62,10 @@ 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
  }
@@ -166,7 +164,7 @@ class Chat extends SharedContent_1.SharedContent {
166
164
  toStub() {
167
165
  this.checkDisposed('Chat.toStub');
168
166
  const msgs = this.messages.values;
169
- let preview;
167
+ let preview = null;
170
168
  if (msgs.length > 0) {
171
169
  const lastMsg = msgs[msgs.length - 1];
172
170
  const textBlock = lastMsg.content.find(b => b.type === 'text');
@@ -181,7 +179,7 @@ class Chat extends SharedContent_1.SharedContent {
181
179
  }
182
180
  return {
183
181
  id: this.id,
184
- title: this.title,
182
+ title: this.title || null,
185
183
  participants: this.participants.values,
186
184
  last_message_preview: preview,
187
185
  updated_at: this.updatedAt.utc_time,
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.3",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/shaxpir/duiduidui-models"