-
Notifications
You must be signed in to change notification settings - Fork 55
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
Changes to integrate rate-limit headers for Commands left
component UI
#67
Changes from 11 commits
268adb2
cae29cd
bb205a8
38582df
d146475
4463636
fdfa9ac
d5638fd
e2411a7
2764ad7
10fe0a2
811e758
6eb234d
dc2c628
75a60d1
8fce1d1
947bf44
63a58f9
dbdc650
cfb6843
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,28 @@ export const formatTime = (seconds: number): string => { | |
const remainingSeconds = seconds % 60; | ||
return `${minutes}:${remainingSeconds < 10 ? '0' : ''}${remainingSeconds}`; | ||
}; | ||
|
||
export const handleResult = ( | ||
result: any, | ||
newOutput: string, | ||
setOutput: any, | ||
onCommandExecuted: any, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can we avoid the |
||
) => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. when we have more than 3 arguments, let's convert it into an object, so that we can have named arguments. so instead of hanleResult(result, newOutput, setOutput, onComandExecuted) => hanleResult({ result, newOutput, setOutput, onComandExecuted }) |
||
if (result?.body?.data) { | ||
setOutput((prevOutput: any) => [ | ||
...prevOutput, | ||
newOutput, | ||
result?.body?.data, | ||
]); | ||
} else if (result?.body?.error) { | ||
setOutput((prevOutput: any) => [ | ||
...prevOutput, | ||
newOutput, | ||
result?.body?.error, | ||
]); | ||
} | ||
|
||
const commandsLeft = result?.headers?.['x-ratelimit-remaining']; | ||
const cleanupTimeLeft = 10; | ||
onCommandExecuted(commandsLeft, cleanupTimeLeft); | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we have a type defined here? preferrably using zod schema. Idea is to ensure and catch early if there is an issue with the response.
right now, we just have a lot of
any
which should be avoided