Skip to content

Plan for Clearing Welcome Queue #333

@kyle-apex

Description

@kyle-apex

Plan for Clearing Welcome Queue

This document outlines the plan to modify the handleUserClick function in pages/e/[path]/welcome.tsx to clear the welcome queue when a user avatar is clicked.

Goal

The goal is to ensure that clicking a user's avatar clears the existing welcome queue and displays a welcome message for the clicked user. Any currently displayed welcome message should also be immediately stopped.

Current Behavior

Currently, handleUserClick adds the clicked user to the welcomeQueueRef without clearing the existing queue.

Proposed Changes

  1. Modify handleUserClick:

    • Before adding the clicked user to the queue, clear the existing queue by setting welcomeQueueRef.current = [].
    • Clear any existing timeout using clearTimeout(timeoutRef.current).
    • Set isShowingWelcome to false.
    • Set welcomeMessage to an empty string.
    • Then, proceed with the existing logic of adding the clicked user to the now-empty queue and calling showNextWelcome.

Code Modifications (Conceptual)

// Inside handleUserClick function:

// Clear existing queue and timeout
welcomeQueueRef.current = [];
if (timeoutRef.current) {
  clearTimeout(timeoutRef.current);
}
setIsShowingWelcome(false);
setWelcomeMessage('');

// ... (rest of the existing handleUserClick logic) ...

Mermaid Sequence Diagram

sequenceDiagram
    participant User
    participant Component
    participant welcomeQueueRef
    participant timeoutRef

    User->>Component: Click User Avatar
    activate Component
    Component->>welcomeQueueRef: welcomeQueueRef.current = []
    Component->>timeoutRef: clearTimeout(timeoutRef.current)
    Component->>Component: setIsShowingWelcome(false)
    Component->>Component: setWelcomeMessage('')
    Component->>welcomeQueueRef: push(clickedUserCheckin)
    Component->>Component: showNextWelcome()
    deactivate Component
Loading

Justification

This approach ensures that only the clicked user's welcome message is displayed, and any previous messages in the queue are cleared, preventing unexpected behavior. Clearing the timeout ensures that any ongoing welcome message is immediately stopped.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions