Skip to content

Commit

Permalink
Fix the bugs in visual UI for legacy notification (#111)
Browse files Browse the repository at this point in the history
  • Loading branch information
thalurur authored Oct 20, 2021
1 parent 6f304e3 commit c350f9c
Showing 1 changed file with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,11 @@ export default class NotificationUIAction implements UIAction<NotificationAction
action: NotificationAction;
type = ActionType.Notification;

constructor(action: NotificationAction, id: string = makeId()) {
const notificationJsonString = JSON.stringify(action.notification, null, 4);
constructor(action: NotificationAction, id: string = makeId(), useNotificationString: boolean = false) {
let notificationJsonString = JSON.stringify(action.notification, null, 4);
if (useNotificationString) {
notificationJsonString = action.notificationJsonString;
}
this.action = { ...action, notificationJsonString };
this.id = id;
}
Expand All @@ -63,6 +66,8 @@ export default class NotificationUIAction implements UIAction<NotificationAction

clone = (action: NotificationAction) => new NotificationUIAction(action, this.id);

cloneUsingString = (action: NotificationAction) => new NotificationUIAction(action, this.id, true);

isValid = () => {
try {
JSON.parse(this.action.notificationJsonString);
Expand All @@ -77,7 +82,7 @@ export default class NotificationUIAction implements UIAction<NotificationAction
return (
<ServicesConsumer>
{(services: BrowserServices | null) =>
services && <NotifUI onChangeAction={onChangeAction} action={this.action} clone={this.clone} isInvalid={!this.isValid()} />
services && <NotifUI onChangeAction={onChangeAction} action={this.action} clone={this.cloneUsingString} isInvalid={!this.isValid()} />
}
</ServicesConsumer>
);
Expand Down

0 comments on commit c350f9c

Please sign in to comment.