Skip to content

Commit

Permalink
Merge pull request #1956 from daostack/feature/CW-1954-new-stream-sys…
Browse files Browse the repository at this point in the history
…tem-message

Add FE system message for new stream created - Use BE text #1954
  • Loading branch information
andreymikhadyuk authored Aug 11, 2023
2 parents e254fa4 + c7a90c9 commit e5ab376
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ const getCommonMemberAddedSystemMessageText = async (

export const getTextFromSystemMessage = async (
data: TextData,
): Promise<Text[]> => {
): Promise<Text[] | null> => {
const { systemMessage } = data;
let text: Text[] = [];

Expand Down Expand Up @@ -147,8 +147,7 @@ export const getTextFromSystemMessage = async (
);
break;
default:
text = [];
break;
return null;
}

return text.map((item, index) => (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,11 @@ export const getTextFromTextEditorString = async (
} = data;

if (systemMessage) {
return await getTextFromSystemMessage(data);
const systemMessageText = await getTextFromSystemMessage(data);

if (systemMessageText) {
return systemMessageText;
}
}

const textEditorValue = parseStringToTextEditorValue(textEditorString);
Expand Down
1 change: 1 addition & 0 deletions src/shared/constants/systemDiscussionMessage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ export enum SystemDiscussionMessageType {
CommonMemberAdded = "common-member-added",
CommonEdited = "common-edited",
CommonCreated = "common-created",
FeedItemCreated = "feed-item-created",
}
13 changes: 12 additions & 1 deletion src/shared/models/DiscussionMessage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,21 @@ export interface CommonEditedSystemMessage extends BaseSystemDiscussionMessage {
};
}

export interface CommonFeedItemCreatedSystemMessage
extends BaseSystemDiscussionMessage {
systemMessageType: SystemDiscussionMessageType.FeedItemCreated;
systemMessageData: {
commonType: SystemMessageCommonType;
commonId: string;
userId: string;
};
}

export type SystemDiscussionMessage =
| CommonCreatedSystemMessage
| CommonMemberAddedSystemMessage
| CommonEditedSystemMessage;
| CommonEditedSystemMessage
| CommonFeedItemCreatedSystemMessage;

export type DiscussionMessage = UserDiscussionMessage | SystemDiscussionMessage;

Expand Down

0 comments on commit e5ab376

Please sign in to comment.