Skip to content

Commit

Permalink
[IMPROVE] Uses view id to handle modal submit
Browse files Browse the repository at this point in the history
  • Loading branch information
RonLek committed Jul 21, 2021
1 parent ed03a0e commit fce018f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 9 deletions.
11 changes: 4 additions & 7 deletions PollApp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ export class PollApp extends App implements IUIKitInteractionHandler {
public async executeViewSubmitHandler(context: UIKitViewSubmitInteractionContext, read: IRead, http: IHttp, persistence: IPersistence, modify: IModify) {
const data = context.getInteractionData();

const title = data.view.title.text;
const id = data.view.id;

if (/create-poll-modal/i.test(id)) {

switch (title) {
case 'Create a poll': {
const { state }: {
state: {
poll: {
Expand Down Expand Up @@ -87,9 +87,8 @@ export class PollApp extends App implements IUIKitInteractionHandler {
return {
success: true,
};
}
} else if (/create-mixed-visibility-modal/.test(id)) {

case 'Select anonymous options': {
const { state }: {
state: {
mixedVisibility: {
Expand Down Expand Up @@ -121,8 +120,6 @@ export class PollApp extends App implements IUIKitInteractionHandler {
};
}

}

return {
success: true,
};
Expand Down
2 changes: 1 addition & 1 deletion src/lib/createMixedVisibilityModal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export async function createMixedVisibilityModal({
data: IUIKitViewSubmitIncomingInteraction;
modify: IModify;
}): Promise<IUIKitModalViewParam> {
const viewId = id || uuid();
const viewId = id || `create-mixed-visibility-modal-${uuid()}`;

const association = new RocketChatAssociationRecord(
RocketChatAssociationModel.MISC,
Expand Down
2 changes: 1 addition & 1 deletion src/lib/createPollModal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export async function createPollModal({ id = '', question, persistence, data, mo
modify: IModify,
options?: number,
}): Promise<IUIKitModalViewParam> {
const viewId = id || uuid();
const viewId = id || `create-poll-modal-${uuid()}`;

const association = new RocketChatAssociationRecord(RocketChatAssociationModel.MISC, viewId);
await persistence.createWithAssociation(data, association);
Expand Down

0 comments on commit fce018f

Please sign in to comment.