aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/archive/base_archive.h8
-rw-r--r--src/archive/mastodon.cpp7
-rw-r--r--src/archive/mastodon.h3
-rw-r--r--src/list_item.cpp6
4 files changed, 17 insertions, 7 deletions
diff --git a/src/archive/base_archive.h b/src/archive/base_archive.h
index 4fdf08c..a6bf98f 100644
--- a/src/archive/base_archive.h
+++ b/src/archive/base_archive.h
@@ -3,6 +3,7 @@
#include <QString>
#include <QListWidget>
#include <variant>
+#include "src/activitypub/apactivity.h"
#include "src/types.h"
enum ArchiveType {
@@ -21,13 +22,18 @@ public:
JsonNotActivityStream // for ActivityPub archives
};
+ struct Hinting_t {
+ StatusType status_type = UNKNOWN;
+ };
+
virtual ~Archive() {};
virtual std::variant<QString, InitError> init() = 0;
static Archive* create_archive(ArchiveType archive_type, const QString& main_filename);
virtual void update_status_list(ViewStatusTypes allowed_types, QListWidget *parent) = 0;
- virtual const QString get_html_status_info(int status_index, int text_zone_width, StatusType status_type, QLocale* locale) = 0;
+ // TODO: use a index type instead of a bare int as the former can be extended
+ virtual APActivity* get_activity(int index, Hinting_t hinting) = 0;
virtual const QString get_html_status_text(int status_index) = 0;
virtual const QString get_instance_address();
diff --git a/src/archive/mastodon.cpp b/src/archive/mastodon.cpp
index 01d476d..238b861 100644
--- a/src/archive/mastodon.cpp
+++ b/src/archive/mastodon.cpp
@@ -237,13 +237,12 @@ std::vector<APAttachmentFields> MastodonArchive::get_status_attachments_list(QJs
return list;
}
-// status_index is assumed to be a valid index
-const QString MastodonArchive::get_html_status_info(int status_index, int text_zone_width, StatusType status_type, QLocale* locale) {
+APActivity* MastodonArchive::get_activity(int status_index, Hinting_t hinting) {
// the JSON AP Activity
QJsonObject activity = outbox_items->at(status_index).toObject();
APActivityFields act_fields = {
- .visibility = status_type
+ .visibility = hinting.status_type
};
QString obj_url;
@@ -331,7 +330,7 @@ const QString MastodonArchive::get_html_status_info(int status_index, int text_z
}
// TODO: it is currently a waste to create this APActivity object that will be immediately destroyed but it allows us to extend archive parsing to something that will become abstract (and an abstract base class) and separate from display (the final goal) which will allow us to add other sources that feed us with posts, reblogs and Actor information. furthermore, these objects can be cached for reuse in a session.
- return APActivity(act_fields).get_html_render({text_zone_width, locale});
+ return new APActivity(act_fields);
}
// TODO: make this use an APActivity object that will be present as an StatusListItem member.
diff --git a/src/archive/mastodon.h b/src/archive/mastodon.h
index 15a89f2..bc9da3e 100644
--- a/src/archive/mastodon.h
+++ b/src/archive/mastodon.h
@@ -2,6 +2,7 @@
#include "src/archive/base_archive.h"
#include "src/activitypub/fields.h"
+#include "src/activitypub/apactivity.h"
#include "src/types.h"
#include <QJsonDocument>
@@ -17,7 +18,7 @@ public:
std::variant<QString, InitError> init();
void update_status_list(ViewStatusTypes allowed_types, QListWidget *parent);
- const QString get_html_status_info(int status_index, int text_zone_width, StatusType status_type, QLocale* locale);
+ APActivity* get_activity(int index, Hinting_t hinting = {});
const QString get_html_status_text(int status_index);
const QString get_instance_address();
private:
diff --git a/src/list_item.cpp b/src/list_item.cpp
index b235d2b..deead65 100644
--- a/src/list_item.cpp
+++ b/src/list_item.cpp
@@ -1,4 +1,5 @@
#include "list_item.h"
+#include "src/activitypub/apactivity.h"
#include "src/types.h"
#define ICON_PATH_PREFIX "res/icons"
@@ -50,5 +51,8 @@ StatusType StatusListItem::get_status_type() {
}
const QString StatusListItem::get_info_html(int text_zone_width, QLocale* locale) {
- return data_archive->get_html_status_info(status_index, text_zone_width, status_type, locale);
+ APActivity* activity = data_archive->get_activity(status_index, {status_type});
+ QString html = activity->get_html_render({text_zone_width, locale});
+ delete activity; activity = nullptr;
+ return html;
}