Add support for local lists
This commit is contained in:
parent
7861b5b5b1
commit
4fec086508
4 changed files with 36 additions and 2 deletions
|
@ -4,6 +4,7 @@
|
|||
#include <vector>
|
||||
#include <optional>
|
||||
#include "app-window.h"
|
||||
#include "rei-json/Array.h"
|
||||
#include "rei-json/json.h"
|
||||
#include "slint_string.h"
|
||||
#include "slint.h"
|
||||
|
@ -131,6 +132,10 @@ public:
|
|||
ui->global<ui::State>().on_add_anilist_list([&](ui::AddAnilistListParams params) {
|
||||
addAnilistList(std::string(params.name), std::string(params.anilist_user_name), std::string(params.anilist_list_name));
|
||||
});
|
||||
|
||||
ui->global<ui::State>().on_add_local_list([&](ui::AddLocalListParams params) {
|
||||
addLocalList(std::string(params.name));
|
||||
});
|
||||
|
||||
ui->global<ui::State>().on_sync_list([&](slint::SharedString name) {
|
||||
//std::println("{}",res->body);
|
||||
|
@ -221,6 +226,7 @@ public:
|
|||
}
|
||||
listJson.set("name", listName);
|
||||
listJson.set("source", "anilist");
|
||||
listJson.set("type", "animes");
|
||||
listJson.set("anilistUserName", anilistUserName);
|
||||
listJson.set("anilistListName", anilistListName);
|
||||
|
||||
|
@ -240,6 +246,25 @@ public:
|
|||
save();
|
||||
}
|
||||
|
||||
void addLocalList(const std::string& listName) {
|
||||
|
||||
rei::json::JsonObject saveJson{};
|
||||
saveJson.set("version", 1);
|
||||
|
||||
rei::json::JsonObject listJson{};
|
||||
listJson.set("name", listName);
|
||||
listJson.set("source", "local");
|
||||
listJson.set("type", "animes");
|
||||
listJson.addArray("animes", rei::json::JsonArray{});
|
||||
|
||||
json.getArray("lists").pushObject(listJson);
|
||||
listsSlint->push_back(ui::List{
|
||||
.name = slint::SharedString(listName),
|
||||
.selected = false
|
||||
});
|
||||
save();
|
||||
}
|
||||
|
||||
slint::Image getAnimeImage(int animeId, std::string imageUrl) {
|
||||
//std::println("Get image for anime {}", animeId);
|
||||
std::string imagePath = "./imgs/" + std::to_string(animeId);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue