diff --git a/demo/src/components/MessageComponent/MessageComponent.tsx b/demo/src/components/MessageComponent/MessageComponent.tsx index 55646cf1..200b2cae 100644 --- a/demo/src/components/MessageComponent/MessageComponent.tsx +++ b/demo/src/components/MessageComponent/MessageComponent.tsx @@ -24,7 +24,7 @@ interface MessageProps { const shortDateTimeFormatter = new Intl.DateTimeFormat('default', { hour: '2-digit', - minute: '2-digit' + minute: '2-digit', }); const shortDateFullFormatter = new Intl.DateTimeFormat('default', { @@ -32,7 +32,7 @@ const shortDateFullFormatter = new Intl.DateTimeFormat('default', { month: '2-digit', year: 'numeric', hour: '2-digit', - minute: '2-digit' + minute: '2-digit', }); function shortDate(date: Date): string { @@ -79,16 +79,19 @@ export const MessageComponent: React.FC = ({ {shortDate(message.createdAt)} {message.createdAt.toLocaleString()} - { (message.isUpdated && message.updatedAt) ? <> + {message.isUpdated && message.updatedAt ? ( + <> {' '} · Edited{' '} {shortDate(message.updatedAt)} {message.updatedAt.toLocaleString()} - { message.updatedBy ? by {message.updatedBy} : '' } - : '' - } + {message.updatedBy ? by {message.updatedBy} : ''} + + ) : ( + '' + )}
= ({ > {message.text}
-
+
diff --git a/demo/src/containers/Chat/Chat.tsx b/demo/src/containers/Chat/Chat.tsx index 95b5f54e..e7fec98b 100644 --- a/demo/src/containers/Chat/Chat.tsx +++ b/demo/src/containers/Chat/Chat.tsx @@ -60,7 +60,7 @@ export const Chat = () => { } // if the message is not in the list, add it - const newArray = [...prevMessages, message.message]; + const newArray = [...prevMessages, message.message]; // and put it at the right place for (let i = newArray.length - 1; i > 1; i--) { diff --git a/src/core/index.ts b/src/core/index.ts index 106f7d78..63781cd5 100644 --- a/src/core/index.ts +++ b/src/core/index.ts @@ -37,6 +37,8 @@ export type { MessageSubscriptionResponse, QueryOptions, SendMessageParams, + UpdateMessageDetails, + UpdateMessageParams, } from './messages.js'; export type { Metadata } from './metadata.js'; export type { Occupancy, OccupancyEvent, OccupancyListener, OccupancySubscriptionResponse } from './occupancy.js'; diff --git a/src/core/messages.ts b/src/core/messages.ts index 88ac1842..c5adbf9f 100644 --- a/src/core/messages.ts +++ b/src/core/messages.ts @@ -1,6 +1,5 @@ import * as Ably from 'ably'; -import { ActionMetadata } from './action-metadata.js'; import { getChannel, messagesChannelName } from './channel.js'; import { ChatApi } from './chat-api.js'; import { @@ -146,7 +145,7 @@ export interface SendMessageParams { // eslint-disable-next-line @typescript-eslint/no-empty-object-type export interface UpdateMessageParams extends SendMessageParams {} -/* +/** * Allows setting optional details about the update operation itself. */ export interface UpdateMessageDetails { diff --git a/test/core/message.test.ts b/test/core/message.test.ts index b7537479..f80dc9a1 100644 --- a/test/core/message.test.ts +++ b/test/core/message.test.ts @@ -19,7 +19,7 @@ describe('ChatMessage', () => { timeserial, ); - expect(message.createdAt).toEqual(new Date(1672531200000)) + expect(message.createdAt).toEqual(new Date(1672531200000)); }); it('is the same as another message', () => { diff --git a/test/core/messages.integration.test.ts b/test/core/messages.integration.test.ts index ee135cfa..a19de49c 100644 --- a/test/core/messages.integration.test.ts +++ b/test/core/messages.integration.test.ts @@ -171,9 +171,9 @@ describe('messages integration', () => { // send a message, and then delete it const message1 = await room.messages.send({ text: 'Hello there!' }); await new Promise((resolve) => setTimeout(resolve, 100)); - const updated1 = await room.messages.update(message1, { text: "bananas" }); + const updated1 = await room.messages.update(message1, { text: 'bananas' }); - expect(updated1.text).toBe("bananas"); + expect(updated1.text).toBe('bananas'); expect(updated1.timeserial).toBe(message1.timeserial); expect(updated1.createdAt.getTime()).toBe(message1.createdAt.getTime()); expect(updated1.updatedAt).toBeDefined(); diff --git a/test/core/messages.test.ts b/test/core/messages.test.ts index 2a648125..613c0588 100644 --- a/test/core/messages.test.ts +++ b/test/core/messages.test.ts @@ -65,7 +65,7 @@ describe('Messages', () => { it('should be able to send message and get it back from response', async (context) => { const { chatApi } = context; const timestamp = Date.now(); - const timeserial = 'abcdefghij@'+timestamp+'-123'; + const timeserial = 'abcdefghij@' + String(timestamp) + '-123'; vi.spyOn(chatApi, 'sendMessage').mockResolvedValue({ timeserial: timeserial, createdAt: timestamp, @@ -89,7 +89,7 @@ describe('Messages', () => { it('should be able to delete a message and get it back from response', async (context) => { const { chatApi } = context; const sendTimestamp = Date.now(); - const sendTimeserial = 'abcdefghij@'+sendTimestamp+'-123'; + const sendTimeserial = 'abcdefghij@' + String(sendTimestamp) + '-123'; vi.spyOn(chatApi, 'sendMessage').mockResolvedValue({ timeserial: sendTimeserial, createdAt: sendTimestamp, @@ -122,7 +122,7 @@ describe('Messages', () => { it('should be able to send message with headers and metadata and get it back from response', async (context) => { const { chatApi, realtime } = context; const timestamp = Date.now(); - const timeserial = 'abcdefghij@'+timestamp+'-123'; + const timeserial = 'abcdefghij@' + String(timestamp) + '-123'; vi.spyOn(chatApi, 'sendMessage').mockResolvedValue({ timeserial: timeserial, createdAt: timestamp,