θΏ™ζ˜―indexlocζδΎ›ηš„ζœεŠ‘οΌŒδΈθ¦θΎ“ε…₯任何密码
Skip to content

Conversation

@shatfield4
Copy link
Collaborator

Pull Request Type

  • ✨ feat
  • πŸ› fix
  • ♻️ refactor
  • πŸ’„ style
  • πŸ”¨ chore
  • πŸ“ docs

Relevant Issues

resolves #586

What is in this change?

Describe the changes in this PR that are impactful to the repo.

  • Add a check to skip empty messages when setting custom messages in appearance settings

Additional Information

Add any other context about the Pull Request here that was not captured above.

Developer Validations

  • I ran yarn lint from the root of the repo & committed changes
  • Relevant documentation has been updated
  • I have tested my code functionality
  • Docker build succeeds locally

@review-agent-prime
Copy link

server/models/welcomeMessages.js

Instead of creating each message individually, you can use Prisma's bulk create method to create all messages at once. This will reduce the number of database calls and improve the performance of the function.
Create Issue
See the diff
Checkout the fix

    const data = messages
      .filter(message => message.response)
      .map((message, index) => ({
        user: message.user,
        response: message.response,
        orderIndex: index,
      }));

    await prisma.welcome_messages.createMany({ data });
git fetch origin && git checkout -b ReviewBot/Impro-xz3s7ws origin/ReviewBot/Impro-xz3s7ws

Instead of just logging the error, it would be better to throw the error to the caller function. This way, the caller function can decide how to handle the error (e.g., by sending an error response to the client).
Create Issue
See the diff
Checkout the fix

    } catch (error) {
      console.error("Failed to save all messages", error.message);
      throw error;
    }
git fetch origin && git checkout -b ReviewBot/Impro-bsbpe17 origin/ReviewBot/Impro-bsbpe17

@timothycarambat timothycarambat merged commit bf503ee into master Jan 17, 2024
@timothycarambat timothycarambat deleted the 586-bug-not-able-to-delete-empty-custom-messages-in-the-apperance-pane branch January 17, 2024 02:23
cabwds pushed a commit to cabwds/anything-llm that referenced this pull request Jul 3, 2025
* add check to skip empty messages

* add comment explaining prisma + sqlite not supporting createMany()
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.

[BUG]: Not able to delete empty custom messages in the Apperance pane.

3 participants