[go: nahoru, domu]

Skip to content

Commit

Permalink
Bug fixes with state management
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinlu1248 committed Jun 23, 2024
1 parent 3f1da81 commit 891a16b
Showing 1 changed file with 5 additions and 13 deletions.
18 changes: 5 additions & 13 deletions sweep_chat/components/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -239,11 +239,7 @@ function App({ defaultMessageId = '' }: { defaultMessageId?: string }) {
commit_to_pr,
} = data.data
console.log(
"loaded",
repo_name,
messages,
snippets,
user_mentioned_pull_requests
`Loaded ${messages.length} messages from ${messagesId}`
)
setRepoName(repo_name)
setRepoNameValid(true)
Expand Down Expand Up @@ -359,7 +355,7 @@ function App({ defaultMessageId = '' }: { defaultMessageId?: string }) {
repoName: string,
messages: Message[],
snippets: Snippet[],
currentMessagesId: string,
messagesId: string,
userMentionedPullRequest: PullRequest | null = null,
userMentionedPullRequests: PullRequest[] | null = null,
commitToPR: boolean = false,
Expand All @@ -374,7 +370,7 @@ function App({ defaultMessageId = '' }: { defaultMessageId?: string }) {
repoName,
messages,
snippets,
messagesId: currentMessagesId,
messageId: messagesId,
originalCodeSuggestions: originalSuggestedChanges,
codeSuggestions: suggestedChanges,
pullRequest,
Expand All @@ -385,13 +381,12 @@ function App({ defaultMessageId = '' }: { defaultMessageId?: string }) {
commitToPRString,
}))
const saveData = await saveResponse.json()
console.log("saving", messages)
console.log(`Saving ${messages.length} messages to ${messagesId}`)
if (saveData.status == 'success') {
const { message_id } = saveData
if (!currentMessagesId && message_id) {
if (!messagesId && message_id) {
setMessagesId(message_id)
const updatedUrl = `/c/${message_id}`
window.history.pushState({}, '', updatedUrl)
}
} else {
console.warn('Failed to save message', saveData)
Expand All @@ -400,7 +395,6 @@ function App({ defaultMessageId = '' }: { defaultMessageId?: string }) {

const debouncedSave = useCallback(
debounce((...args: Parameters<typeof save>) => {
console.log('saving...')
save(
...args
)
Expand Down Expand Up @@ -858,7 +852,6 @@ function App({ defaultMessageId = '' }: { defaultMessageId?: string }) {
}

const reset = () => {
window.history.pushState({}, '', '/')
setMessages([])
setCurrentMessage('')
setIsLoading(false)
Expand Down Expand Up @@ -1225,7 +1218,6 @@ function App({ defaultMessageId = '' }: { defaultMessageId?: string }) {
setMessages(newMessages)
setIsCreatingPullRequest(false)
if (index == 0) {
window.history.pushState({}, '', '/')
setMessagesId('')
setOriginalSuggestedChanges([])
setSuggestedChanges([])
Expand Down

0 comments on commit 891a16b

Please sign in to comment.