Skip to content

Commit

Permalink
streamline message related types
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexNi245 committed Nov 21, 2024
1 parent 6076931 commit 17dd080
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 11 deletions.
6 changes: 1 addition & 5 deletions packages/js-sdk/src/conversation/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,7 @@ import {
DeliveryServiceProfile,
getAccountDisplayName,
} from '@dm3-org/dm3-lib-profile';

class Messages {
public readonly list: string[];
public addMessage(message: string) {}
}
import { Messages } from '../message/Messages';

export interface Contact {
name: string;
Expand Down
6 changes: 1 addition & 5 deletions packages/js-sdk/src/message/Messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { encryptAsymmetric } from '@dm3-org/dm3-lib-crypto';
import {
buildEnvelop,
EncryptionEnvelop,
Envelop,
getEnvelopSize,
Message,
MessageState,
Expand All @@ -13,10 +12,7 @@ import {
ProfileKeys,
} from '@dm3-org/dm3-lib-profile';
import { sha256, stringify } from '@dm3-org/dm3-lib-shared';
import {
StorageAPI,
StorageEnvelopContainer as StorageEnvelopContainerNew,
} from '@dm3-org/dm3-lib-storage';
import { StorageAPI } from '@dm3-org/dm3-lib-storage';
import { submitEnvelopsToReceiversDs } from '../api/ds/submitEnvelopsToReceiversDs';
import { Conversations } from '../conversation/Conversations';
import { Contact } from '../conversation/types';
Expand Down
2 changes: 1 addition & 1 deletion packages/js-sdk/src/message/renderer/renderMessage.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { MessageModel } from '../Messages';
import { MessageModel } from '../types';
import { renderDelete } from './messageTypes/renderDelete';
import { renderDuplicates } from './messageTypes/renderDuplicates';
import { renderEdit } from './messageTypes/renderEdit';
Expand Down
37 changes: 37 additions & 0 deletions packages/js-sdk/src/message/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import { Envelop } from '@dm3-org/dm3-lib-messaging';
import {
StorageAPI,
StorageEnvelopContainer as StorageEnvelopContainerNew,
} from '@dm3-org/dm3-lib-storage';
export enum MessageActionType {
NEW = 'NEW',
EDIT = 'EDIT',
DELETE = 'DELETE_REQUEST',
REPLY = 'REPLY',
REACT = 'REACTION',
NONE = 'NONE',
}

export enum MessageIndicator {
SENT = 'SENT',
RECEIVED = 'RECEIVED',
READED = 'READED',
}
//Message source to identify where a message comes from. This is important to handle pagination of storage messages properly
export enum MessageSource {
//Messages added by the client via addMessage
Client,
//Messages fetched from the storage
Storage,
//Messages fetched from the deliveryService
DeliveryService,
//Messages received from the Websocket
WebSocket,
}

export type MessageModel = StorageEnvelopContainerNew & {
reactions: Envelop[];
replyToMessageEnvelop?: Envelop;
source: MessageSource;
indicator?: MessageIndicator;
};

0 comments on commit 17dd080

Please sign in to comment.