Store manga ID with subscriptions

This commit is contained in:
Alex Ling 2021-11-20 11:08:36 +00:00
parent 5442d124af
commit fe6f884d94
3 changed files with 7 additions and 2 deletions

View File

@ -5,6 +5,7 @@ const component = () => {
pid: undefined, pid: undefined,
chapters: undefined, // undefined: not searched yet, []: empty chapters: undefined, // undefined: not searched yet, []: empty
manga: undefined, // undefined: not searched yet, []: empty manga: undefined, // undefined: not searched yet, []: empty
mid: undefined, // id of the selected manga
allChapters: [], allChapters: [],
query: "", query: "",
mangaTitle: "", mangaTitle: "",
@ -374,6 +375,7 @@ const component = () => {
}, },
mangaSelected(event) { mangaSelected(event) {
const mid = event.currentTarget.getAttribute("data-id"); const mid = event.currentTarget.getAttribute("data-id");
this.mid = mid;
this.searchChapters(mid); this.searchChapters(mid);
}, },
subscribe(modal) { subscribe(modal) {
@ -384,6 +386,7 @@ const component = () => {
filters: this.filterSettings, filters: this.filterSettings,
plugin: this.pid, plugin: this.pid,
name: this.subscriptionName.trim(), name: this.subscriptionName.trim(),
manga: this.mid,
}), }),
headers: { headers: {
"Content-Type": "application/json", "Content-Type": "application/json",

View File

@ -54,12 +54,13 @@ struct Subscription
property id : String property id : String
property plugin_id : String property plugin_id : String
property manga_id : String
property name : String property name : String
property created_at : Int64 property created_at : Int64
property last_checked : Int64 property last_checked : Int64
property filters = [] of Filter property filters = [] of Filter
def initialize(@plugin_id, @name) def initialize(@plugin_id, @manga_id, @name)
@id = UUID.random.to_s @id = UUID.random.to_s
@created_at = Time.utc.to_unix @created_at = Time.utc.to_unix
@last_checked = Time.utc.to_unix @last_checked = Time.utc.to_unix

View File

@ -629,12 +629,13 @@ struct APIRouter
post "/api/admin/plugin/subscriptions" do |env| post "/api/admin/plugin/subscriptions" do |env|
begin begin
plugin_id = env.params.json["plugin"].as String 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| filters = env.params.json["filters"].as(Array(JSON::Any)).map do |f|
Filter.from_json f.to_json Filter.from_json f.to_json
end end
name = env.params.json["name"].as String name = env.params.json["name"].as String
sub = Subscription.new plugin_id, name sub = Subscription.new plugin_id, manga_id, name
sub.filters = filters sub.filters = filters
plugin = Plugin.new plugin_id plugin = Plugin.new plugin_id