From fe6f884d946f1e7810f865088d3b5e1493222982 Mon Sep 17 00:00:00 2001 From: Alex Ling Date: Sat, 20 Nov 2021 11:08:36 +0000 Subject: [PATCH] Store manga ID with subscriptions --- public/js/plugin-download.js | 3 +++ src/plugin/subscriptions.cr | 3 ++- src/routes/api.cr | 3 ++- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/public/js/plugin-download.js b/public/js/plugin-download.js index 422f613..fd10e58 100644 --- a/public/js/plugin-download.js +++ b/public/js/plugin-download.js @@ -5,6 +5,7 @@ const component = () => { pid: undefined, chapters: undefined, // undefined: not searched yet, []: empty manga: undefined, // undefined: not searched yet, []: empty + mid: undefined, // id of the selected manga allChapters: [], query: "", mangaTitle: "", @@ -374,6 +375,7 @@ const component = () => { }, mangaSelected(event) { const mid = event.currentTarget.getAttribute("data-id"); + this.mid = mid; this.searchChapters(mid); }, subscribe(modal) { @@ -384,6 +386,7 @@ const component = () => { filters: this.filterSettings, plugin: this.pid, name: this.subscriptionName.trim(), + manga: this.mid, }), headers: { "Content-Type": "application/json", diff --git a/src/plugin/subscriptions.cr b/src/plugin/subscriptions.cr index 3c23848..2593970 100644 --- a/src/plugin/subscriptions.cr +++ b/src/plugin/subscriptions.cr @@ -54,12 +54,13 @@ struct Subscription property id : String property plugin_id : String + property manga_id : String property name : String property created_at : Int64 property last_checked : Int64 property filters = [] of Filter - def initialize(@plugin_id, @name) + def initialize(@plugin_id, @manga_id, @name) @id = UUID.random.to_s @created_at = Time.utc.to_unix @last_checked = Time.utc.to_unix diff --git a/src/routes/api.cr b/src/routes/api.cr index 8ef0229..caedc30 100644 --- a/src/routes/api.cr +++ b/src/routes/api.cr @@ -629,12 +629,13 @@ struct APIRouter post "/api/admin/plugin/subscriptions" do |env| begin plugin_id = env.params.json["plugin"].as String + manga_id = env.params.json["manga"].as String filters = env.params.json["filters"].as(Array(JSON::Any)).map do |f| Filter.from_json f.to_json end name = env.params.json["name"].as String - sub = Subscription.new plugin_id, name + sub = Subscription.new plugin_id, manga_id, name sub.filters = filters plugin = Plugin.new plugin_id