From f12a602e4d7a57a1c34587c8e34e8ad866072c0f Mon Sep 17 00:00:00 2001 From: Morgan McMillian Date: Sat, 14 Apr 2018 13:01:58 -0700 Subject: [PATCH] add long post data to postitem in stream and thread views. --- assets/PostItem.qml | 13 +++++++++++++ src/Pnut.cpp | 7 ++++++- translations/Goober.ts | 20 ++++++++++---------- 3 files changed, 29 insertions(+), 11 deletions(-) diff --git a/assets/PostItem.qml b/assets/PostItem.qml index 3c2cda4..0269eed 100644 --- a/assets/PostItem.qml +++ b/assets/PostItem.qml @@ -155,6 +155,19 @@ Container { navigation.focusPolicy: NavigationFocusPolicy.NotFocusable } } + Container { // long post body + topMargin: ui.sdu(2.0) + bottomMargin: ui.sdu(2.0) + visible: (typeof ListItemData.longpost_body !== "undefined") + Divider { + } + Label { + text: (typeof ListItemData.longpost_body !== "undefined") ? ListItemData.longpost_body : "" + multiline: true + textFormat: TextFormat.Html + navigation.focusPolicy: NavigationFocusPolicy.NotFocusable + } + } Container { // post embeds // TODO: add tab to open full image in a page horizontalAlignment: HorizontalAlignment.Center diff --git a/src/Pnut.cpp b/src/Pnut.cpp index 6d19522..cf7bcc0 100644 --- a/src/Pnut.cpp +++ b/src/Pnut.cpp @@ -226,7 +226,8 @@ void Pnut::onAuthorizedRequestReady(QByteArray data, int id) } else if (endpoint == ":thread") { - emit threadReceived(variant.toMap()["data"].toList()); + QVariantList streamlist = variant.toMap()["data"].toList(); + emit threadReceived(parseStream(streamlist)); req_map.remove(id); } else if (endpoint == ":userstream") @@ -576,6 +577,10 @@ QVariantList Pnut::parseStream(QVariantList stream) } } } + if (raw["type"] == "nl.chimpnut.blog.post") { + QVariantMap value = raw["value"].toMap(); + item.insert("longpost_body", value["body"]); + } } } pstream.append(item); diff --git a/translations/Goober.ts b/translations/Goober.ts index d19322b..37e0890 100644 --- a/translations/Goober.ts +++ b/translations/Goober.ts @@ -43,52 +43,52 @@ PostItem - + Reply - + Reply All - + Delete Bookmark - + Add Bookmark - + Delete Repost - + Repost - + Quote - + View Profile - + Copy text - + Delete