fetch user-submitted published notes
This commit is contained in:
parent
8ebd35c3b6
commit
aa893b9f4d
|
@ -29,8 +29,9 @@
|
|||
// Get feed tree.
|
||||
#define TTRSS_GFT_TYPE_CATEGORY "category"
|
||||
|
||||
// Special feeds.
|
||||
#define TTRSS_FEED_PUBLISHED_ID -2
|
||||
// "Published" feed/label.
|
||||
#define TTRSS_PUBLISHED_LABEL_ID -2
|
||||
#define TTRSS_PUBLISHED_FEED_ID 0
|
||||
|
||||
// Subscribe to feed.
|
||||
#define STF_UNKNOWN -1
|
||||
|
|
|
@ -770,10 +770,23 @@ RootItem* TtRssGetFeedsCategoriesResponse::feedsCategories(TtRssNetworkFactory*
|
|||
|
||||
feed->setTitle(item[QSL("name")].toString());
|
||||
feed->setCustomId(QString::number(item_id));
|
||||
|
||||
act_parent->appendChild(feed);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Append special "published" feed to hold "notes" created by user
|
||||
// via "shareToPublished" method. These "notes" are not normal articles
|
||||
// because they do not belong to any feed.
|
||||
// We have feed.
|
||||
auto* published_feed = new TtRssFeed();
|
||||
|
||||
published_feed->setTitle(QSL("[SYSTEM] ") + QObject::tr("User-published articles"));
|
||||
published_feed->setCustomId(QString::number(0));
|
||||
published_feed->setKeepOnTop(true);
|
||||
|
||||
parent->appendChild(published_feed);
|
||||
}
|
||||
|
||||
return parent;
|
||||
|
@ -788,7 +801,7 @@ QList<Message> TtRssGetHeadlinesResponse::messages(ServiceRoot* root) const {
|
|||
auto active_labels = root->labelsNode() != nullptr ? root->labelsNode()->labels() : QList<Label*>();
|
||||
auto json_msgs = m_rawContent[QSL("content")].toArray();
|
||||
auto* published_lbl = boolinq::from(active_labels).firstOrDefault([](const Label* lbl) {
|
||||
return lbl->customNumericId() == TTRSS_FEED_PUBLISHED_ID;
|
||||
return lbl->customNumericId() == TTRSS_PUBLISHED_LABEL_ID;
|
||||
});
|
||||
|
||||
for (const QJsonValue& item : qAsConst(json_msgs)) {
|
||||
|
@ -921,11 +934,11 @@ QList<RootItem*> TtRssGetLabelsResponse::labels() const {
|
|||
// note, which is then assigned to "Published feed" but can be also assigned label from 1).
|
||||
//
|
||||
// This label solves situation 1). 2) is solved in other way (creating static system feed).
|
||||
QString published_caption = QObject::tr("[SYSTEM] Published articles");
|
||||
QString published_caption = QSL("[SYSTEM] ") + QObject::tr("Published articles");
|
||||
auto* published_lbl = new Label(published_caption, TextFactory::generateColorFromText(published_caption));
|
||||
|
||||
published_lbl->setKeepOnTop(true);
|
||||
published_lbl->setCustomId(QString::number(TTRSS_FEED_PUBLISHED_ID));
|
||||
published_lbl->setCustomId(QString::number(TTRSS_PUBLISHED_LABEL_ID));
|
||||
labels.append(published_lbl);
|
||||
|
||||
for (const QJsonValue& lbl_val : qAsConst(json_labels)) {
|
||||
|
|
|
@ -46,10 +46,16 @@ void TtRssServiceRoot::start(bool freshly_activated) {
|
|||
auto lbls = m_labelsNode->labels();
|
||||
|
||||
boolinq::from(lbls).for_each([](Label* lbl) {
|
||||
if (lbl->customNumericId() == TTRSS_FEED_PUBLISHED_ID) {
|
||||
if (lbl->customNumericId() == TTRSS_PUBLISHED_LABEL_ID) {
|
||||
lbl->setKeepOnTop(true);
|
||||
}
|
||||
});
|
||||
|
||||
boolinq::from(childItems()).for_each([](RootItem* child) {
|
||||
if (child->kind() == RootItem::Kind::Feed && child->customNumericId() == TTRSS_PUBLISHED_FEED_ID) {
|
||||
child->setKeepOnTop(true);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
updateTitle();
|
||||
|
@ -170,7 +176,7 @@ void TtRssServiceRoot::saveAllCachedData(bool ignore_errors) {
|
|||
if (!messages.isEmpty()) {
|
||||
TtRssResponse res;
|
||||
|
||||
if (label_custom_id.toInt() == TTRSS_FEED_PUBLISHED_ID) {
|
||||
if (label_custom_id.toInt() == TTRSS_PUBLISHED_LABEL_ID) {
|
||||
// "published" label must be added in other method.
|
||||
res = network()->updateArticles(messages,
|
||||
UpdateArticle::OperatingField::Published,
|
||||
|
@ -198,7 +204,7 @@ void TtRssServiceRoot::saveAllCachedData(bool ignore_errors) {
|
|||
if (!messages.isEmpty()) {
|
||||
TtRssResponse res;
|
||||
|
||||
if (label_custom_id.toInt() == TTRSS_FEED_PUBLISHED_ID) {
|
||||
if (label_custom_id.toInt() == TTRSS_PUBLISHED_LABEL_ID) {
|
||||
// "published" label must be removed in other method.
|
||||
res = network()->updateArticles(messages,
|
||||
UpdateArticle::OperatingField::Published,
|
||||
|
|
Loading…
Reference in New Issue