Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added a feature of quick create from the input box itself.. #23

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

not-meet
Copy link

@not-meet not-meet commented Nov 22, 2024

Issue(s)

Closes #22

##This PR introduces a new feature that allows users to create quick replies directly from the message input box using the /quick create command, eliminating the need for an input modal.

Acceptance Criteria fulfillment

  • Introduce support for the /quick create command format.
  • Validate inputs directly within the command execution handler.
  • Notify users about the success or failure of reply creation via in-app notifications.

Proposed changes (including videos or screenshots)

  • Users can now create quick replies with the following format:
    /quick create
  • Ensures the command includes at least a name (replyName) and a body (replyBody).
  • Displays an error message if the inputs are invalid or missing.
  • New File for Quick Reply Logic: Contains the logic for handling /quick create.
  • Updates to CommandUtility.ts: Added logic to check the input arguments. Redirects the call to the appropriate handler based on the input.

Demo

Screencast from 2024-11-22 10-32-50.webm
Screenshot from 2024-11-22 10-38-23

up for any changes and learning :)

@CLAassistant
Copy link

CLAassistant commented Nov 22, 2024

CLA assistant check
All committers have signed the CLA.

Copy link
Collaborator

@VipinDevelops VipinDevelops left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is alot of thing's that make no sense, try to make a PR that is clear and not bloated it, Ideally a PR should not have move then 200-300 line of code.

IModify,
IPersistence,
IRead,
IHttp,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove these spaces

public persis: IPersistence;
public triggerId?: string;
public threadId?: string;
public app: QuickRepliesApp;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove

const subCommand = this.params[0].toLowerCase();

if (
subCommand === CommandParam.CREATE ||
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why are we creating team in all the command ? explain me this

await this.handleSingleParam(handler);
break;
}
default: {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should not be in default

}
}
}
private async handleQuickCreate(handler: Handler, args: string[]): Promise<void> {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we already handled default cases

);

if (args.length < 3) {
await sendUsageMessage(modify, room, sender);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is this ?

return;
}
}
public app: QuickRepliesApp;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

too much bloated code remove all these spaces

room: IRoom,
user: IUser,
): Promise<void> {
const text = '/quick-create <replyName> "<replyBody>"';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why we have this code ?

Copy link
Collaborator

@VipinDevelops VipinDevelops left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make requested changes

@not-meet
Copy link
Author

not-meet commented Nov 22, 2024

Hi @VipinDevelops so i reflected the changes you asked for and made them as per the requirements

Note
the reason of adding the handlequickcreate function in the default is because of the number of arguments and the authentication of the keyword used as the switch case works on the parameters of length so as there can be a high chances of having uncertainty of inputs ive added quick create function in the default as it gets only called when there is a create keyword in the first index! :)

Copy link
Collaborator

@VipinDevelops VipinDevelops left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is still a lot of room for improvement basically you are repeating a lot of code and not following best practice.

@@ -77,7 +77,13 @@ export class CommandUtility implements ICommandUtility {
break;
}
default: {
await handler.sendDefault();
const subCommand = this.params[0].toLowerCase();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you don't have to put this in switch case you can handle this in global

@@ -107,4 +113,23 @@ export class CommandUtility implements ICommandUtility {
}
}
}

private async handleQuickCreate(handler: Handler, args: string[]): Promise<void> {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why dont use the function we already have for creating new replies ?

return;
}

switch (args[0].toLowerCase()) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why switch case in a function that is made to create a reply ?

await handler.CreateQuickReply(args);
break;
}
default: {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is the third place where you please .sendDefault() is there any other way to achieve check without repeating this

@@ -206,4 +207,20 @@ export class Handler implements IHandler {
return;
}
}
public async CreateQuickReply(args: string[]): Promise<void> {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we do have a method already for this

@VipinDevelops
Copy link
Collaborator

Also, update the documentation accordingly.

@not-meet
Copy link
Author

hey @VipinDevelops made changes as you asked..! now i believe the code looks much cleaner to be merged...
up if there are any other changes to be made : )

@VipinDevelops
Copy link
Collaborator

VipinDevelops commented Dec 16, 2024

Hey @not-meet Can you explain a little about changes you have made and use the code we have already for creating replies I have seen you writing some code again that already exist Either reuse the function we have or make something new that can be use in both old and new code.

@not-meet
Copy link
Author

not-meet commented Dec 17, 2024

hey!! @VipinDevelops
so I've added conditional logic in the CreateModal to take the reply name and body from CLI arguments as the original modal uses the input from the input boxes in the modal.

I wrote new logic instead of modifying the existing modal to avoid conflicts. While I understand the concern about calling the handler in the default switch case instead of passing it globally, doing so avoids issues where the global call still triggers the switch case unintentionally.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feat] Enhancement: Enable Quick Reply Creation via Message Input in Quick Replies
3 participants