@shaxpir/duiduidui-models 1.23.0 → 1.24.0
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.
- package/dist/models/Chat.d.ts +13 -0
- package/dist/models/Chat.js +29 -0
- package/package.json +1 -1
package/dist/models/Chat.d.ts
CHANGED
|
@@ -70,6 +70,12 @@ export interface ChatStub {
|
|
|
70
70
|
[user_id: string]: boolean;
|
|
71
71
|
};
|
|
72
72
|
}
|
|
73
|
+
export type ChatStatus = 'idle' | 'pending' | 'error';
|
|
74
|
+
export interface ChatError {
|
|
75
|
+
message: string;
|
|
76
|
+
code?: string;
|
|
77
|
+
retryable: boolean;
|
|
78
|
+
}
|
|
73
79
|
export interface ChatPayload {
|
|
74
80
|
title?: string;
|
|
75
81
|
participants: SocialUser[];
|
|
@@ -77,6 +83,8 @@ export interface ChatPayload {
|
|
|
77
83
|
last_read: {
|
|
78
84
|
[user_id: string]: CompactDateTime;
|
|
79
85
|
};
|
|
86
|
+
status: ChatStatus;
|
|
87
|
+
error?: ChatError;
|
|
80
88
|
}
|
|
81
89
|
export interface ChatBody extends ContentBody {
|
|
82
90
|
meta: ContentMeta;
|
|
@@ -101,7 +109,12 @@ export declare class Chat extends SharedContent {
|
|
|
101
109
|
get lastRead(): {
|
|
102
110
|
[user_id: string]: CompactDateTime;
|
|
103
111
|
};
|
|
112
|
+
get status(): ChatStatus;
|
|
113
|
+
get error(): ChatError | undefined;
|
|
104
114
|
setTitle(title: string): void;
|
|
115
|
+
setStatus(status: ChatStatus): void;
|
|
116
|
+
setError(error: ChatError): void;
|
|
117
|
+
clearError(): void;
|
|
105
118
|
addParticipant(user: SocialUser): void;
|
|
106
119
|
removeParticipant(userId: ContentId): void;
|
|
107
120
|
markRead(userId: ContentId): void;
|
package/dist/models/Chat.js
CHANGED
|
@@ -36,6 +36,7 @@ class Chat extends SharedContent_1.SharedContent {
|
|
|
36
36
|
participants,
|
|
37
37
|
messages: [],
|
|
38
38
|
last_read: {},
|
|
39
|
+
status: 'idle',
|
|
39
40
|
}
|
|
40
41
|
});
|
|
41
42
|
}
|
|
@@ -91,6 +92,14 @@ class Chat extends SharedContent_1.SharedContent {
|
|
|
91
92
|
this.checkDisposed('Chat.lastRead');
|
|
92
93
|
return this.payload.last_read;
|
|
93
94
|
}
|
|
95
|
+
get status() {
|
|
96
|
+
this.checkDisposed('Chat.status');
|
|
97
|
+
return this.payload.status;
|
|
98
|
+
}
|
|
99
|
+
get error() {
|
|
100
|
+
this.checkDisposed('Chat.error');
|
|
101
|
+
return this.payload.error;
|
|
102
|
+
}
|
|
94
103
|
// ---- Setters ----
|
|
95
104
|
setTitle(title) {
|
|
96
105
|
this.checkDisposed('Chat.setTitle');
|
|
@@ -98,6 +107,26 @@ class Chat extends SharedContent_1.SharedContent {
|
|
|
98
107
|
batch.setPathValue(['payload', 'title'], title);
|
|
99
108
|
batch.commit();
|
|
100
109
|
}
|
|
110
|
+
setStatus(status) {
|
|
111
|
+
this.checkDisposed('Chat.setStatus');
|
|
112
|
+
const batch = new Operation_1.BatchOperation(this);
|
|
113
|
+
batch.setPathValue(['payload', 'status'], status);
|
|
114
|
+
batch.commit();
|
|
115
|
+
}
|
|
116
|
+
setError(error) {
|
|
117
|
+
this.checkDisposed('Chat.setError');
|
|
118
|
+
const batch = new Operation_1.BatchOperation(this);
|
|
119
|
+
batch.setPathValue(['payload', 'status'], 'error');
|
|
120
|
+
batch.setPathValue(['payload', 'error'], error);
|
|
121
|
+
batch.commit();
|
|
122
|
+
}
|
|
123
|
+
clearError() {
|
|
124
|
+
this.checkDisposed('Chat.clearError');
|
|
125
|
+
const batch = new Operation_1.BatchOperation(this);
|
|
126
|
+
batch.setPathValue(['payload', 'status'], 'idle');
|
|
127
|
+
batch.removeValueAtPath(['payload', 'error']);
|
|
128
|
+
batch.commit();
|
|
129
|
+
}
|
|
101
130
|
// ---- Participant operations ----
|
|
102
131
|
addParticipant(user) {
|
|
103
132
|
this.checkDisposed('Chat.addParticipant');
|