[feature/frontend] Better visual separation between "main" thread and "replies" (#3093)

* [feature/frontend] Better web threading model

* fix test

* bwap

* tweaks

* more tweaks to wording

* typo

* indenting

* adjust wording

* aaa
This commit is contained in:
tobi
2024-07-12 20:36:03 +02:00
committed by GitHub
parent cde2fb6244
commit aeb65bceae
16 changed files with 895 additions and 385 deletions

View File

@@ -20,7 +20,6 @@ package web
import (
"context"
"encoding/json"
"errors"
"fmt"
"net/http"
"strings"
@@ -101,34 +100,20 @@ func (m *Module) threadGETHandler(c *gin.Context) {
return
}
// Get the status itself from the processor using provided ID and authorization (if any).
status, errWithCode := m.processor.Status().WebGet(ctx, targetStatusID)
// Get the thread context. This will fetch the target status as well.
context, errWithCode := m.processor.Status().WebContextGet(ctx, targetStatusID)
if errWithCode != nil {
apiutil.WebErrorHandler(c, errWithCode, instanceGet)
return
}
// Ensure status actually belongs to target account.
if status.GetAccountID() != targetAccount.ID {
if context.Status.GetAccountID() != targetAccount.ID {
err := fmt.Errorf("target account %s does not own status %s", targetUsername, targetStatusID)
apiutil.WebErrorHandler(c, gtserror.NewErrorNotFound(err), instanceGet)
return
}
// Don't render boosts/reblogs as top-level statuses.
if status.Reblog != nil {
err := errors.New("status is a boost wrapper / reblog")
apiutil.WebErrorHandler(c, gtserror.NewErrorNotFound(err), instanceGet)
return
}
// Fill in the rest of the thread context.
context, errWithCode := m.processor.Status().WebContextGet(ctx, targetStatusID)
if errWithCode != nil {
apiutil.WebErrorHandler(c, errWithCode, instanceGet)
return
}
// Prepare stylesheets for thread.
stylesheets := make([]string, 0, 5)
@@ -159,11 +144,10 @@ func (m *Module) threadGETHandler(c *gin.Context) {
page := apiutil.WebPage{
Template: "thread.tmpl",
Instance: instance,
OGMeta: apiutil.OGBase(instance).WithStatus(status),
OGMeta: apiutil.OGBase(instance).WithStatus(context.Status),
Stylesheets: stylesheets,
Javascript: []string{jsFrontend},
Extra: map[string]any{
"status": status,
"context": context,
},
}