Skip to content

Commit e192f80

Browse files
committed
Redirect the modal_close event to the App
1 parent 6e92a4f commit e192f80

File tree

2 files changed

+34
-6
lines changed

2 files changed

+34
-6
lines changed

app/apps/server/communication/uikit.js

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,37 @@ export class AppUIKitInteractionApi {
9191
break;
9292
}
9393

94-
case UIKitIncomingInteractionType.VIEW_CLOSED:
95-
res.sendStatus(200);
94+
case UIKitIncomingInteractionType.VIEW_CLOSED: {
95+
const {
96+
type,
97+
actionId,
98+
view,
99+
isCleared,
100+
} = req.body;
101+
102+
const user = this.orch.getConverters().get('users').convertToApp(req.user);
103+
104+
const action = {
105+
type,
106+
appId,
107+
actionId,
108+
user,
109+
payload: {
110+
view,
111+
isCleared,
112+
},
113+
};
114+
115+
try {
116+
Promise.await(this.orch.getBridges().getListenerBridge().uiKitInteractionEvent('IUIKitInteractionHandler', action));
117+
118+
res.send(200);
119+
} catch (e) {
120+
console.log(e);
121+
res.status(500).send(e.message);
122+
}
96123
break;
124+
}
97125

98126
case UIKitIncomingInteractionType.VIEW_SUBMIT: {
99127
const {

app/ui-message/client/ActionManager.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,14 +133,14 @@ export const triggerSubmitView = async ({ viewId, ...options }) => {
133133
close();
134134
}
135135
};
136-
export const triggerCancel = async ({ viewId, ...options }) => {
137-
const instance = instances.get(viewId);
136+
export const triggerCancel = async ({ view, ...options }) => {
137+
const instance = instances.get(view.id);
138138
try {
139-
await triggerAction({ type: UIKitIncomingInteractionType.VIEW_CLOSED, viewId, ...options });
139+
await triggerAction({ type: UIKitIncomingInteractionType.VIEW_CLOSED, view, ...options });
140140
} finally {
141141
if (instance) {
142142
instance.close();
143-
instances.delete(viewId);
143+
instances.delete(view.id);
144144
}
145145
}
146146
};

0 commit comments

Comments
 (0)