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

Fixes: #859 - First time users get Welcome message and introductory v… #3676

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

isuruAb
Copy link
Member

@isuruAb isuruAb commented Oct 8, 2024

…ideo

Fixes #[Add issue number here. If you do not solve the issue entirely, please change the message e.g. "First steps for issue" #IssueNumber]

Changes: [Add here what changes were made in this pull request and if possible provide links showcasing the changes.]

Demo Link: https://pr-[ADD_PULL_REQUEST_NUMBER_HERE]-fossasia-susi-web-chat.surge.sh

Screenshots of the change: [Add screenshots depicting the changes.]

Summary by Sourcery

Add a welcome dialog with an introductory video for first-time users in the SUSI Web Chat application, utilizing cookies to track user visits and ensure the dialog is only shown to new users.

New Features:

  • Introduce a welcome dialog with an introductory video for first-time users in the SUSI Web Chat application.

Enhancements:

  • Add a mechanism to track whether a user has visited the site before using cookies, allowing the welcome dialog to be shown only to new users.

Copy link

sourcery-ai bot commented Oct 8, 2024

Reviewer's Guide by Sourcery

This pull request implements a welcome message and introductory video for first-time users of the SUSI Web Chat application. The changes primarily affect the DialogSection component, adding a new dialog for the welcome message and video, and the MessageSection component, introducing logic to show the welcome dialog for first-time visitors.

User journey diagram for first-time user welcome message

journey
    title First-time User Welcome Journey
    section Initial Visit
      User: Arrives at SUSI Web Chat: 5: User
      System: Check if user is first-time visitor: 5: System
      System: Display welcome message and video: 5: System
      User: Views welcome message and video: 5: User
    section Subsequent Visits
      User: Arrives at SUSI Web Chat: 5: User
      System: Check if user is first-time visitor: 5: System
      System: No welcome message displayed: 5: System
      User: Proceeds with normal chat usage: 5: User
Loading

Updated class diagram for DialogSection component

classDiagram
    class DialogSection {
        +bool openLogin
        +bool openSignUp
        +bool openForgotPassword
        +bool openHardwareChange
        +bool openThemeChanger
        +bool tour
        +func onLoginSignUp()
        +func handleSignUp()
        +func onRequestClose()
        +func onRequestCloseTour()
        +func onForgotPassword()
        +func onSignedUp()
    }
    class MessageSection {
        +bool showLogin
        +bool showSignUp
        +bool showThemeChanger
        +bool openForgotPassword
        +bool tour
        +func handleCloseTour()
    }
Loading

File-Level Changes

Change Details Files
Added a new welcome dialog with an introductory video
  • Implemented a new Dialog component for the welcome message
  • Embedded a YouTube video in the welcome dialog
  • Added a close button to dismiss the welcome dialog
src/components/ChatApp/MessageSection/DialogSection.js
Implemented logic to show the welcome dialog for first-time visitors
  • Added a 'tour' state to control the visibility of the welcome dialog
  • Introduced cookie-based tracking to determine if a user has visited before
  • Created a handleCloseTour method to close the welcome dialog and set the visited cookie
src/components/ChatApp/MessageSection/MessageSection.react.js
Updated component props and state management
  • Added 'tour' and 'onRequestCloseTour' props to DialogSection
  • Modified the initial state to include the 'tour' property
  • Updated PropTypes to include new props
src/components/ChatApp/MessageSection/DialogSection.js
src/components/ChatApp/MessageSection/MessageSection.react.js
Refactored code structure and formatting
  • Adjusted indentation and spacing throughout the files
  • Reorganized import statements
  • Removed unnecessary comments and whitespace
src/components/ChatApp/MessageSection/DialogSection.js
src/components/ChatApp/MessageSection/MessageSection.react.js

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time. You can also use
    this command to specify where the summary should be inserted.

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey @isuruAb - I've reviewed your changes - here's some feedback:

Overall Comments:

  • Consider standardizing indentation across the project in future updates. There's a mix of tabs and spaces which could be unified for better consistency.
Here's what I looked at during the review
  • 🟡 General issues: 2 issues found
  • 🟡 Security: 1 issue found
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment on lines +30 to +42
<Dialog
className='dialogStyle'
modal={false}
open={this.props.openLogin}
autoScrollBodyContent={true}
bodyStyle={this.props.bodyStyle}
contentStyle={{ width: '35%', minWidth: '300px' }}
onRequestClose={this.props.onRequestClose()}>
<Login {...this.props}
handleForgotPassword={this.props.onForgotPassword()}
handleSignUp={this.props.handleSignUp} />
<Close style={closingStyle} onTouchTap={this.props.onRequestClose()} />
</Dialog>
Copy link

Choose a reason for hiding this comment

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

suggestion (performance): Consider lazy-loading the tour video for better initial load performance

The new tour Dialog with an embedded YouTube video might impact the initial load time. Consider lazy-loading this component or loading the video on-demand to improve performance.

<React.Suspense fallback={<div>Loading...</div>}>
  <Dialog
    className='dialogStyle'
    modal={false}
    open={this.props.openLogin}
    autoScrollBodyContent={true}
    bodyStyle={this.props.bodyStyle}
    contentStyle={{ width: '35%', minWidth: '300px' }}
    onRequestClose={this.props.onRequestClose}>
    <LazyLogin {...this.props} handleForgotPassword={this.props.onForgotPassword} handleSignUp={this.props.handleSignUp} />
    <Close style={closingStyle} onTouchTap={this.props.onRequestClose} />
  </Dialog>
</React.Suspense>

autoScrollBodyContent={true}
bodyStyle={this.props.bodyStyle}
contentStyle={{ width: '35%', minWidth: '300px' }}
onRequestClose={this.props.onRequestClose()}>
Copy link

Choose a reason for hiding this comment

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

issue (bug_risk): Event handlers are being called immediately instead of passed as references

Throughout the component, event handlers like onRequestClose are being called immediately (e.g., this.props.onRequestClose()) instead of passed as references (this.props.onRequestClose). This can lead to unexpected behavior and performance issues. Consider changing these to pass the function references directly.

import Cookies from 'universal-cookie';


const cookies=new Cookies();
Copy link

Choose a reason for hiding this comment

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

🚨 suggestion (security): Consider implications of using cookies for user privacy and data persistence

The introduction of cookies should be carefully considered in terms of user privacy and data persistence. Ensure that you're complying with relevant data protection regulations and that users are informed about the use of cookies if necessary.

Suggested change
const cookies=new Cookies();
const cookies = new Cookies({
secure: true,
sameSite: 'strict'
});

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.

1 participant