Add direct timeline
authorr <r@freesoftwareextremist.com>
Tue, 28 Jan 2020 20:56:15 +0000 (20:56 +0000)
committerr <r@freesoftwareextremist.com>
Tue, 28 Jan 2020 20:56:15 +0000 (20:56 +0000)
mastodon/status.go
service/service.go
templates/navigation.tmpl

index d6a93302c1528c83019c5fd3e555d1b73579a4a9..bce283f83fe009c108358f4ba5cb0a7c0ef2570e 100644 (file)
@@ -329,3 +329,15 @@ func (c *Client) UploadMediaFromMultipartFileHeader(ctx context.Context, fh *mul
        }
        return &attachment, nil
 }
+
+// GetTimelineDirect return statuses from direct timeline.
+func (c *Client) GetTimelineDirect(ctx context.Context, pg *Pagination) ([]*Status, error) {
+       params := url.Values{}
+
+       var statuses []*Status
+       err := c.doAPI(ctx, http.MethodGet, "/api/v1/timelines/direct", params, &statuses, pg)
+       if err != nil {
+               return nil, err
+       }
+       return statuses, nil
+}
index 7ad860ffd6725067df573d35fd9387daa579af54..0ef8f094f89c269c5f24cc03fab41065c1152a2a 100644 (file)
@@ -211,6 +211,9 @@ func (svc *service) ServeTimelinePage(ctx context.Context, c *model.Client,
        case "home":
                statuses, err = c.GetTimelineHome(ctx, &pg)
                title = "Timeline"
+       case "direct":
+               statuses, err = c.GetTimelineDirect(ctx, &pg)
+               title = "Local Timeline"
        case "local":
                statuses, err = c.GetTimelinePublic(ctx, true, &pg)
                title = "Local Timeline"
index e2547ea3cc09ff3fb007d9c4e0345920a2be6599..a85f9fdbdbfb56f0b0f8a6637daa6159b8b093cd 100644 (file)
@@ -15,6 +15,7 @@
                <div>
                        <a class="nav-link" href="/timeline/home">home</a>
                        <a class="nav-link" href="/notifications">notifications{{if gt .NotificationCount 0}}({{.NotificationCount}}){{end}}</a>
+                       <a class="nav-link" href="/timeline/direct">direct</a>
                        <a class="nav-link" href="/timeline/local">local</a>
                        <a class="nav-link" href="/timeline/twkn">twkn</a>
                        <a class="nav-link" href="/search">search</a>