Skip to content

Commit 55c6975

Browse files
Updated chat sdk version. FIxed an issue where image attachments weren't displayed in the messages (#266)
1 parent ab2d201 commit 55c6975

File tree

7 files changed

+41
-34
lines changed

7 files changed

+41
-34
lines changed

join-chat-to-teams-meeting/Chat Experience with File Sharing/client.js

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,14 @@ async function init() {
3131

3232
let identityResponse = await identityClient.createUser();
3333
userId = identityResponse.communicationUserId;
34-
console.log(`\nCreated an identity with ID: ${identityResponse.communicationUserId}`);
34+
console.log(
35+
`\nCreated an identity with ID: ${identityResponse.communicationUserId}`
36+
);
3537

36-
let tokenResponse = await identityClient.getToken(identityResponse, ["voip", "chat"]);
38+
let tokenResponse = await identityClient.getToken(identityResponse, [
39+
"voip",
40+
"chat",
41+
]);
3742

3843
const { token, expiresOn } = tokenResponse;
3944
tokenString = token;
@@ -45,7 +50,10 @@ async function init() {
4550
callAgent = await callClient.createCallAgent(tokenCredential);
4651
callButton.disabled = false;
4752

48-
chatClient = new ChatClient(endpointUrl, new AzureCommunicationTokenCredential(token));
53+
chatClient = new ChatClient(
54+
endpointUrl,
55+
new AzureCommunicationTokenCredential(token)
56+
);
4957

5058
console.log("Azure Communication Chat client created!");
5159
}
@@ -71,7 +79,9 @@ callButton.addEventListener("click", async () => {
7179
try {
7280
call = joinCall(meetingLinkInput.value, callAgent);
7381
} catch {
74-
throw new Error("Could not join meeting - have you set your connection string?");
82+
throw new Error(
83+
"Could not join meeting - have you set your connection string?"
84+
);
7585
}
7686

7787
// Chat thread ID is provided from the call info, after connection.
@@ -117,12 +127,14 @@ async function renderReceivedMessage(event) {
117127
messages += `<div class="container lighter"> ${event.message} </div>`;
118128
messagesContainer.innerHTML = messages;
119129
console.log(event);
130+
// filter out inline images from attachments
131+
const imageAttachments = event.attachments?.filter(
132+
(attachment) =>
133+
attachment.attachmentType === "image" && !messages.includes(attachment.id)
134+
);
120135
// Inject image tag for all image attachments
121136
var imageAttachmentHtml =
122-
event.attachments
123-
?.filter(
124-
(attachment) => attachment.attachmentType === "image" && !messages.includes(attachment.id)
125-
)
137+
imageAttachments
126138
.map((attachment) => renderImageAttachments(attachment))
127139
.join("") ?? "";
128140
messagesContainer.innerHTML += imageAttachmentHtml;
@@ -135,11 +147,6 @@ async function renderReceivedMessage(event) {
135147
.join("") ?? "";
136148
messagesContainer.innerHTML += attachmentHtml;
137149

138-
// filter out inline images from attachments
139-
const imageAttachments = event.attachments?.filter(
140-
(attachment) => attachment.attachmentType === "image" && messages.includes(attachment.id)
141-
);
142-
143150
// fetch and render preview images
144151
fetchPreviewImages(imageAttachments);
145152
}

join-chat-to-teams-meeting/Chat Experience with File Sharing/package-lock.json

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

join-chat-to-teams-meeting/Chat Experience with File Sharing/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"license": "ISC",
1313
"dependencies": {
1414
"@azure/communication-calling": "1.26.1-beta.1",
15-
"@azure/communication-chat": "1.6.0-beta.2",
15+
"@azure/communication-chat": "1.6.0-beta.3",
1616
"@azure/communication-common": "^2.3.0",
1717
"@azure/communication-identity": "^1.3.0"
1818
},

join-chat-to-teams-meeting/Chat Experience with Inline Image/package-lock.json

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

join-chat-to-teams-meeting/Chat Experience with Inline Image/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"license": "ISC",
1313
"dependencies": {
1414
"@azure/communication-calling": "1.26.1-beta.1",
15-
"@azure/communication-chat": "1.6.0-beta.2",
15+
"@azure/communication-chat": "1.6.0-beta.3",
1616
"@azure/communication-common": "^2.3.1",
1717
"@azure/communication-identity": "^1.3.0"
1818
},

join-chat-to-teams-meeting/Chat Experience/package-lock.json

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

join-chat-to-teams-meeting/Chat Experience/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"license": "ISC",
1313
"dependencies": {
1414
"@azure/communication-calling": "1.26.1-beta.1",
15-
"@azure/communication-chat": "1.6.0-beta.2",
15+
"@azure/communication-chat": "1.6.0-beta.3",
1616
"@azure/communication-common": "^2.3.1",
1717
"@azure/communication-identity": "^1.3.0"
1818
},

0 commit comments

Comments
 (0)