Skip to content

Refactor: Replace console.log/alert with toast/alert dispatcher #327

@cubap

Description

@cubap

Description

Multiple UI components currently use console.log(), console.debug(), and alert() for user notifications and debugging. This creates inconsistent UX and noisy console output.

Current State

Found 40+ instances across the codebase:

  • console.log() in various components (line-history, projects, classroom, etc.)
  • alert() calls in roles-handler, projects, legacy-annotator, etc.

Proposed Solution

  1. Route user-facing messages through the existing toast/alert dispatcher system:

    • Use eventDispatcher.dispatch('tpen-toast', { status, message }) for notifications
    • Use eventDispatcher.dispatch('tpen-alert', { message, buttonText }) for confirmations
  2. For debug logging, consider:

    • Remove debug logs entirely from production code
    • Use a debug flag/wrapper that respects environment (dev vs prod)
    • Leverage browser dev tools instead of inline logs

Files Affected

  • manage/projectsHighlight.js
  • components/roles-handler/index.js
  • components/projects/project-list-write.js
  • components/line-history/index.js
  • components/legacy-annotator/plain.js
  • components/annotorious-annotator/plain.js
  • components/classroom/ (multiple files)
  • api/Project.js

Benefits

  • Consistent user experience
  • Cleaner console output in production
  • Better error tracking and user feedback
  • Easier to test notification flows

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions