hicommonwealth / commonwealth

A platform for decentralized communities
https://commonwealth.im
GNU General Public License v3.0
67 stars 44 forks source link

BUG: Discussion page crashes on some communities #9825

Open ilijabojanovic opened 2 days ago

ilijabojanovic commented 2 days ago

Describe the bug

When user navigate on community, Discussion page crashes.

Initial conditions

Environment:

QA Branch/Release version:

Master/release/v1.7.3-x Browser:

All Wallet:

All

Reproduction steps

  1. Go to: https://qa.commonwealth.im/
  2. Sing in
  3. Navigate to https://qa.commonwealth.im/october/ or https://qa.commonwealth.im/common/archived

    Actual behavior

    Page crashes

    ThreadOptions-Bt4Z72Zw.js:4 Uncaught TypeError: Cannot read properties of undefined (reading 'id')
    at Gt (ThreadOptions-Bt4Z72Zw.js:4:25012)
    at KA (index-CXALuvZi.js:142:414)
    at sI (index-CXALuvZi.js:158:10880)
    at rw (index-CXALuvZi.js:160:12831)
    at HTMLUnknownElement.Rl (index-CXALuvZi.js:77:33827)
    at HTMLUnknownElement.c (rocket-loader.min.js:1:9405)
    at Object.Qf (index-CXALuvZi.js:77:34177)
    at Vd (index-CXALuvZi.js:77:35160)
    at x8 (index-CXALuvZi.js:177:2436)

    Expected behavior

Screenshots / Video

https://app.screencast.com/dCIJHaXBUOKeN

Reporter

Additional context

timolegros commented 1 day ago

This is caused because the thread type was updated to require a topic in https://github.com/hicommonwealth/commonwealth/pull/9660 but some threads don't have associated topics hence an error is thrown from line 91 of AdminActions.tsx

timolegros commented 5 hours ago

The root of the issue is having threads that don't have an associated topic. To resolve this issue we need to make Thread.topic_id required. To do this we must introduce per-topic archival (replaces topic deletion)

Topic Archival

  1. New archived_at column in Topics table
  2. Update DeleteTopic.command to ArchiveTopic.command
    • Set archived_at for the topic and all threads associated with that topic
    • Requires client changes both for references but also in copy (e.g. updated modal + do we show archival topics in Manage Topics?)
  3. Update UpdateTopic.command to prevent updates on archived topics (except for unarchival?)
  4. Potentially update GetTopics.query
    • Archived topics should not be returned by default so that they don't show up in Group or Contest forms. We need to be mindful of caching responses that include archived topics so they don't carry over from Manage Topics to other forms (if we display archived topics in Manage Topics).
  5. Update whatever queries load all topics + threads on initial community load to exclude archived topics.

Threads with no topics

There are 413 threads without an associated topic. 287 of these are soft deleted threads which we can permanently remove. Of the remaining 126 threads, 9 are not associated with any community and can therefore also be deleted. This leaves us with 117 valid threads that must be transferred to an existing topic.

These 117 threads come from the following communities: 'borg-test', 'common', 'dhk', 'l0trial', 'sushi', and 'trepo'. All of these communities except for 'common' and 'dhk' have topics named 'General' to which we can reasonably transfer the threads. After this, we are left with 5 threads (from 'common' and 'dhk') which have no associated topic and whose associated community has no 'General' topic.

@dillchen For the 3 threads in the common community, someone from growth should assign them a topic and for the 2 in dhk we should reach out to them or assign a random topic:

TBD