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

Refactor to use localized state management for conversation ID #124

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

Conversation

Asin-Junior-Honore
Copy link

Description

This PR fixes the usage of a global variable GlobalConversationID in Copilot.tsx. The global variable has been refactored to use localized state management with React's useState hook.
issue #115

Changes include:

  • Refactored createNewConversation function to accept a state setter for conversation ID.
  • Updated CopilotChat component to manage the conversation ID using the useState hook.
  • Adjusted relevant function calls and state management logic to accommodate these changes.

@Asin-Junior-Honore
Copy link
Author

hey
@Arindam200 , @mason-at-pieces , @shivay-at-pieces
please could someone review my PR please , thank you

Copy link
Contributor

@Arindam200 Arindam200 left a comment

Choose a reason for hiding this comment

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

Can You please remove the extra spaces and unwanted changes?

Rest looks Good to me.

src/app/components/Copilot/Copilot.tsx Outdated Show resolved Hide resolved
Comment on lines 35 to 62
new Pieces.ConversationsApi()
.conversationsCreateSpecificConversationRaw({
transferables: true,
seededConversation,
})
.then((_c) => {
console.log("Conversation created! : Here is the response:");
console.log(_c);

// check and ensure the response back is clean.
if (_c.raw.ok == true && _c.raw.status == 200) {
console.log("CLEAN RESPONSE BACK.");
_c.value().then((_conversation) => {
console.log("Returning new conversation values.");
// console.log('ID | ' + _conversation.id);
// console.log('NAME | ' + _conversation.name);
// console.log('CREATED | ' + _conversation.created.readable);
// console.log('ID: ' + _conversation.);

// Set the conversation variable here for the local file:
setConversationID(_conversation.id);
});
}
});
} catch (error) {
console.error('An error occurred while creating a conversation:', error);
console.error("An error occurred while creating a conversation:", error);
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Same Here

Copy link
Author

Choose a reason for hiding this comment

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

All done sir

@Asin-Junior-Honore
Copy link
Author

Hey
@Arindam200 ,

Please review the changes I made based on your request a few hours ago. Thanks!

Copy link
Contributor

@shivay-at-pieces shivay-at-pieces left a comment

Choose a reason for hiding this comment

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

Looks good.

Copy link
Contributor

@Arindam200 Arindam200 left a comment

Choose a reason for hiding this comment

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

Looks Good to me!

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.

3 participants