Skip to content

Commit

Permalink
update the MessageAction fields.
Browse files Browse the repository at this point in the history
  • Loading branch information
splindsay-92 committed Oct 10, 2024
1 parent d14268c commit 1c0c2ba
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 20 deletions.
14 changes: 7 additions & 7 deletions ably.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2457,34 +2457,34 @@ export enum MessageAction {
/**
* Message action has not been set.
*/
MessageUnset = 'message_unset',
MESSAGE_UNSET = 'MESSAGE_UNSET',
/**
* Message action for a newly created message.
*/
MessageCreate = 'message_create',
MESSAGE_CREATE = 'MESSAGE_CREATE',
/**
* Message action for an updated message.
*/
MessageUpdate = 'message_update',
MESSAGE_UPDATE = 'MESSAGE_UPDATE',
/**
* Message action for a deleted message.
*/
MessageDelete = 'message_delete',
MESSAGE_DELETE = 'MESSAGE_DELETE',
/**
* Message action for a newly created annotation.
*/
MessageAnnotationCreate = 'message_annotation_create',
MESSAGE_ANNOTATION_CREATE = 'MESSAGE_ANNOTATION_CREATE',
/**
* Message action for a deleted annotation.
*/
MessageAnnotationDelete = 'message_annotation_delete',
MESSAGE_ANNOTATION_DELETE = 'MESSAGE_ANNOTATION_DELETE',
}


/**
* A message received from Ably.
*/
export type InboundMessage = Message & Required<Pick<Message, 'id' | 'timestamp' | 'serial', 'action'>>;
export type InboundMessage = Message & Required<Pick<Message, 'id' | 'timestamp' | 'serial' | 'action'>>;

/**
* Static utilities related to messages.
Expand Down
25 changes: 12 additions & 13 deletions src/common/lib/types/message.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,44 +9,43 @@ import * as API from '../../../../ably';
import { IUntypedCryptoStatic } from 'common/types/ICryptoStatic';
import { MsgPack } from 'common/types/msgpack';


/**
* Enum containing the different types of message actions.
*/
enum MessageAction {
/**
* Message action has not been set.
*/
MessageUnset = 'MESSAGE_UNSET',
MESSAGE_UNSET = 'MESSAGE_UNSET',
/**
* Message action for a newly created message.
*/
MessageCreate = 'MESSAGE_CREATE',
MESSAGE_CREATE = 'MESSAGE_CREATE',
/**
* Message action for an updated message.
*/
MessageUpdate = 'MESSAGE_UPDATE',
MESSAGE_UPDATE = 'MESSAGE_UPDATE',
/**
* Message action for a deleted message.
*/
MessageDelete = 'MESSAGE_DELETE',
MESSAGE_DELETE = 'MESSAGE_DELETE',
/**
* Message action for a newly created annotation.
*/
AnnotationCreate = 'ANNOTATION_CREATE',
MESSAGE_ANNOTATION_CREATE = 'MESSAGE_ANNOTATION_CREATE',
/**
* Message action for a deleted annotation.
*/
AnnotationDelete = 'ANNOTATION_DELETE',
MESSAGE_ANNOTATION_DELETE = 'MESSAGE_ANNOTATION_DELETE',
}

const MessageActionNumberMap: Record<number, MessageAction> = {
0: MessageAction.MessageUnset,
1: MessageAction.MessageCreate,
2: MessageAction.MessageUpdate,
3: MessageAction.MessageDelete,
4: MessageAction.AnnotationCreate,
5: MessageAction.AnnotationDelete,
0: MessageAction.MESSAGE_UNSET,
1: MessageAction.MESSAGE_CREATE,
2: MessageAction.MESSAGE_UPDATE,
3: MessageAction.MESSAGE_DELETE,
4: MessageAction.MESSAGE_ANNOTATION_CREATE,
5: MessageAction.MESSAGE_ANNOTATION_DELETE,
};

function getMessageAction(actionNumber: number): MessageAction {
Expand Down

0 comments on commit 1c0c2ba

Please sign in to comment.