Fix hiding anime on completion

This commit is contained in:
Timothy Warren 2020-10-05 12:32:12 -04:00
parent 913f9082ef
commit ecce90abd5
6 changed files with 195 additions and 79 deletions

View File

@ -6,7 +6,7 @@ const search = (query) => {
_.show('.cssload-loader');
// Do the api search
return _.get(_.url('/anime-collection/search'), { query }, (searchResults, status) => {
_.get(_.url('/anime-collection/search'), { query }, (searchResults, status) => {
searchResults = JSON.parse(searchResults);
// Hide the loader
@ -18,19 +18,13 @@ const search = (query) => {
};
if (_.hasElement('.anime #search')) {
let prevRequest = null;
_.on('#search', 'input', _.throttle(250, (e) => {
const query = encodeURIComponent(e.target.value);
if (query === '') {
return;
}
if (prevRequest !== null) {
prevRequest.abort();
}
prevRequest = search(query);
search(query);
}));
}
@ -53,12 +47,12 @@ _.on('body.anime.list', 'click', '.plus-one', (e) => {
// If the episode count is 0, and incremented,
// change status to currently watching
if (isNaN(watchedCount) || watchedCount === 0) {
data.data.status = 'CURRENT';
data.data.status = 'current';
}
// If you increment at the last episode, mark as completed
if ((!isNaN(watchedCount)) && (watchedCount + 1) === totalCount) {
data.data.status = 'COMPLETED';
data.data.status = 'completed';
}
_.show('#loading-shadow');
@ -78,7 +72,7 @@ _.on('body.anime.list', 'click', '.plus-one', (e) => {
return;
}
if (String(resData.data.status).toUpperCase() === 'COMPLETED') {
if (resData.data.libraryEntry.update.libraryEntry.status === 'COMPLETED') {
_.hide(parentSel);
}

View File

@ -590,7 +590,7 @@ const search = (query) => {
AnimeClient.show('.cssload-loader');
// Do the api search
return AnimeClient.get(AnimeClient.url('/anime-collection/search'), { query }, (searchResults, status) => {
AnimeClient.get(AnimeClient.url('/anime-collection/search'), { query }, (searchResults, status) => {
searchResults = JSON.parse(searchResults);
// Hide the loader
@ -602,19 +602,13 @@ const search = (query) => {
};
if (AnimeClient.hasElement('.anime #search')) {
let prevRequest = null;
AnimeClient.on('#search', 'input', AnimeClient.throttle(250, (e) => {
const query = encodeURIComponent(e.target.value);
if (query === '') {
return;
}
if (prevRequest !== null) {
prevRequest.abort();
}
prevRequest = search(query);
search(query);
}));
}
@ -637,12 +631,12 @@ AnimeClient.on('body.anime.list', 'click', '.plus-one', (e) => {
// If the episode count is 0, and incremented,
// change status to currently watching
if (isNaN(watchedCount) || watchedCount === 0) {
data.data.status = 'CURRENT';
data.data.status = 'current';
}
// If you increment at the last episode, mark as completed
if ((!isNaN(watchedCount)) && (watchedCount + 1) === totalCount) {
data.data.status = 'COMPLETED';
data.data.status = 'completed';
}
AnimeClient.show('#loading-shadow');
@ -662,7 +656,7 @@ AnimeClient.on('body.anime.list', 'click', '.plus-one', (e) => {
return;
}
if (String(resData.data.status).toUpperCase() === 'COMPLETED') {
if (resData.data.libraryEntry.update.libraryEntry.status === 'COMPLETED') {
AnimeClient.hide(parentSel);
}

View File

@ -16,13 +16,13 @@ function(beat){var status=JSON.parse(beat);if(status.hasAuth!==true){document.re
x.id+'.webp" type="image/webp" />\n\t\t\t\t\t\t\t<source srcset="/public/images/anime/'+x.id+'.jpg" type="image/jpeg" />\n\t\t\t\t\t\t\t<img src="/public/images/anime/'+x.id+'.jpg" alt="" width="220" />\n\t\t\t\t\t\t</picture>\n\t\t\t\t\t\t<span class="name">\n\t\t\t\t\t\t\t'+item.canonicalTitle+"<br />\n\t\t\t\t\t\t\t<small>"+titles+'</small>\n\t\t\t\t\t\t</span>\n\t\t\t\t\t</label>\n\t\t\t\t</div>\n\t\t\t\t<div class="table">\n\t\t\t\t\t<div class="row">\n\t\t\t\t\t\t<span class="edit">\n\t\t\t\t\t\t\t<a class="bracketed" href="/anime/details/'+
item.slug+'">Info Page</a>\n\t\t\t\t\t\t</span>\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t</article>\n\t\t')});return results.join("")}function renderMangaSearchResults(data){var results=[];data.forEach(function(x){var item=x.attributes;var titles=item.titles.join("<br />");results.push('\n\t\t\t<article class="media search">\n\t\t\t\t<div class="name">\n\t\t\t\t\t<input type="radio" id="mal_'+item.slug+'" name="mal_id" value="'+x.mal_id+'" />\n\t\t\t\t\t<input type="radio" class="big-check" id="'+
item.slug+'" name="id" value="'+x.id+'" />\n\t\t\t\t\t<label for="'+item.slug+'">\n\t\t\t\t\t\t<picture width="220">\n\t\t\t\t\t\t\t<source srcset="/public/images/manga/'+x.id+'.webp" type="image/webp" />\n\t\t\t\t\t\t\t<source srcset="/public/images/manga/'+x.id+'.jpg" type="image/jpeg" />\n\t\t\t\t\t\t\t<img src="/public/images/manga/'+x.id+'.jpg" alt="" width="220" />\n\t\t\t\t\t\t</picture>\n\t\t\t\t\t\t<span class="name">\n\t\t\t\t\t\t\t'+item.canonicalTitle+"<br />\n\t\t\t\t\t\t\t<small>"+titles+
'</small>\n\t\t\t\t\t\t</span>\n\t\t\t\t\t</label>\n\t\t\t\t</div>\n\t\t\t\t<div class="table">\n\t\t\t\t\t<div class="row">\n\t\t\t\t\t\t<span class="edit">\n\t\t\t\t\t\t\t<a class="bracketed" href="/manga/details/'+item.slug+'">Info Page</a>\n\t\t\t\t\t\t</span>\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t</article>\n\t\t')});return results.join("")}var search=function(query){AnimeClient.show(".cssload-loader");return AnimeClient.get(AnimeClient.url("/anime-collection/search"),{query:query},function(searchResults,
status){searchResults=JSON.parse(searchResults);AnimeClient.hide(".cssload-loader");AnimeClient.$("#series-list")[0].innerHTML=renderAnimeSearchResults(searchResults.data)})};if(AnimeClient.hasElement(".anime #search")){var prevRequest=null;AnimeClient.on("#search","input",AnimeClient.throttle(250,function(e){var query=encodeURIComponent(e.target.value);if(query==="")return;if(prevRequest!==null)prevRequest.abort();prevRequest=search(query)}))}AnimeClient.on("body.anime.list","click",".plus-one",
function(e){var parentSel=AnimeClient.closestParent(e.target,"article");var watchedCount=parseInt(AnimeClient.$(".completed_number",parentSel)[0].textContent,10)||0;var totalCount=parseInt(AnimeClient.$(".total_number",parentSel)[0].textContent,10);var title=AnimeClient.$(".name a",parentSel)[0].textContent;var data={id:parentSel.dataset.kitsuId,mal_id:parentSel.dataset.malId,data:{progress:watchedCount+1}};if(isNaN(watchedCount)||watchedCount===0)data.data.status="CURRENT";if(!isNaN(watchedCount)&&
watchedCount+1===totalCount)data.data.status="COMPLETED";AnimeClient.show("#loading-shadow");AnimeClient.ajax(AnimeClient.url("/anime/increment"),{data:data,dataType:"json",type:"POST",success:function(res){var resData=JSON.parse(res);if(resData.errors){AnimeClient.hide("#loading-shadow");AnimeClient.showMessage("error","Failed to update "+title+". ");AnimeClient.scrollToTop();return}if(String(resData.data.status).toUpperCase()==="COMPLETED")AnimeClient.hide(parentSel);AnimeClient.hide("#loading-shadow");
AnimeClient.showMessage("success","Successfully updated "+title);AnimeClient.$(".completed_number",parentSel)[0].textContent=++watchedCount;AnimeClient.scrollToTop()},error:function(){AnimeClient.hide("#loading-shadow");AnimeClient.showMessage("error","Failed to update "+title+". ");AnimeClient.scrollToTop()}})});var search$1=function(query){AnimeClient.show(".cssload-loader");return AnimeClient.get(AnimeClient.url("/manga/search"),{query:query},function(searchResults,status){searchResults=JSON.parse(searchResults);
AnimeClient.hide(".cssload-loader");AnimeClient.$("#series-list")[0].innerHTML=renderMangaSearchResults(searchResults.data)})};if(AnimeClient.hasElement(".manga #search")){var prevRequest$1=null;AnimeClient.on("#search","input",AnimeClient.throttle(250,function(e){var query=encodeURIComponent(e.target.value);if(query==="")return;if(prevRequest$1!==null)prevRequest$1.abort();prevRequest$1=search$1(query)}))}AnimeClient.on(".manga.list","click",".edit-buttons button",function(e){var thisSel=e.target;
var parentSel=AnimeClient.closestParent(e.target,"article");var type=thisSel.classList.contains("plus-one-chapter")?"chapter":"volume";var completed=parseInt(AnimeClient.$("."+type+"s_read",parentSel)[0].textContent,10)||0;var total=parseInt(AnimeClient.$("."+type+"_count",parentSel)[0].textContent,10);var mangaName=AnimeClient.$(".name",parentSel)[0].textContent;if(isNaN(completed))completed=0;var data={id:parentSel.dataset.kitsuId,mal_id:parentSel.dataset.malId,data:{progress:completed}};if(isNaN(completed)||
completed===0)data.data.status="CURRENT";if(!isNaN(completed)&&completed+1===total)data.data.status="COMPLETED";data.data.progress=++completed;AnimeClient.show("#loading-shadow");AnimeClient.ajax(AnimeClient.url("/manga/increment"),{data:data,dataType:"json",type:"POST",mimeType:"application/json",success:function(){if(String(data.data.status).toUpperCase()==="COMPLETED")AnimeClient.hide(parentSel);AnimeClient.hide("#loading-shadow");AnimeClient.$("."+type+"s_read",parentSel)[0].textContent=completed;
AnimeClient.showMessage("success","Successfully updated "+mangaName);AnimeClient.scrollToTop()},error:function(){AnimeClient.hide("#loading-shadow");AnimeClient.showMessage("error","Failed to update "+mangaName);AnimeClient.scrollToTop()}})})})()
'</small>\n\t\t\t\t\t\t</span>\n\t\t\t\t\t</label>\n\t\t\t\t</div>\n\t\t\t\t<div class="table">\n\t\t\t\t\t<div class="row">\n\t\t\t\t\t\t<span class="edit">\n\t\t\t\t\t\t\t<a class="bracketed" href="/manga/details/'+item.slug+'">Info Page</a>\n\t\t\t\t\t\t</span>\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t</article>\n\t\t')});return results.join("")}var search=function(query){AnimeClient.show(".cssload-loader");AnimeClient.get(AnimeClient.url("/anime-collection/search"),{query:query},function(searchResults,
status){searchResults=JSON.parse(searchResults);AnimeClient.hide(".cssload-loader");AnimeClient.$("#series-list")[0].innerHTML=renderAnimeSearchResults(searchResults.data)})};if(AnimeClient.hasElement(".anime #search"))AnimeClient.on("#search","input",AnimeClient.throttle(250,function(e){var query=encodeURIComponent(e.target.value);if(query==="")return;search(query)}));AnimeClient.on("body.anime.list","click",".plus-one",function(e){var parentSel=AnimeClient.closestParent(e.target,"article");var watchedCount=
parseInt(AnimeClient.$(".completed_number",parentSel)[0].textContent,10)||0;var totalCount=parseInt(AnimeClient.$(".total_number",parentSel)[0].textContent,10);var title=AnimeClient.$(".name a",parentSel)[0].textContent;var data={id:parentSel.dataset.kitsuId,mal_id:parentSel.dataset.malId,data:{progress:watchedCount+1}};if(isNaN(watchedCount)||watchedCount===0)data.data.status="current";if(!isNaN(watchedCount)&&watchedCount+1===totalCount)data.data.status="completed";AnimeClient.show("#loading-shadow");
AnimeClient.ajax(AnimeClient.url("/anime/increment"),{data:data,dataType:"json",type:"POST",success:function(res){var resData=JSON.parse(res);if(resData.errors){AnimeClient.hide("#loading-shadow");AnimeClient.showMessage("error","Failed to update "+title+". ");AnimeClient.scrollToTop();return}if(resData.data.libraryEntry.update.libraryEntry.status==="COMPLETED")AnimeClient.hide(parentSel);AnimeClient.hide("#loading-shadow");AnimeClient.showMessage("success","Successfully updated "+title);AnimeClient.$(".completed_number",
parentSel)[0].textContent=++watchedCount;AnimeClient.scrollToTop()},error:function(){AnimeClient.hide("#loading-shadow");AnimeClient.showMessage("error","Failed to update "+title+". ");AnimeClient.scrollToTop()}})});var search$1=function(query){AnimeClient.show(".cssload-loader");return AnimeClient.get(AnimeClient.url("/manga/search"),{query:query},function(searchResults,status){searchResults=JSON.parse(searchResults);AnimeClient.hide(".cssload-loader");AnimeClient.$("#series-list")[0].innerHTML=
renderMangaSearchResults(searchResults.data)})};if(AnimeClient.hasElement(".manga #search")){var prevRequest=null;AnimeClient.on("#search","input",AnimeClient.throttle(250,function(e){var query=encodeURIComponent(e.target.value);if(query==="")return;if(prevRequest!==null)prevRequest.abort();prevRequest=search$1(query)}))}AnimeClient.on(".manga.list","click",".edit-buttons button",function(e){var thisSel=e.target;var parentSel=AnimeClient.closestParent(e.target,"article");var type=thisSel.classList.contains("plus-one-chapter")?
"chapter":"volume";var completed=parseInt(AnimeClient.$("."+type+"s_read",parentSel)[0].textContent,10)||0;var total=parseInt(AnimeClient.$("."+type+"_count",parentSel)[0].textContent,10);var mangaName=AnimeClient.$(".name",parentSel)[0].textContent;if(isNaN(completed))completed=0;var data={id:parentSel.dataset.kitsuId,mal_id:parentSel.dataset.malId,data:{progress:completed}};if(isNaN(completed)||completed===0)data.data.status="CURRENT";if(!isNaN(completed)&&completed+1===total)data.data.status="COMPLETED";
data.data.progress=++completed;AnimeClient.show("#loading-shadow");AnimeClient.ajax(AnimeClient.url("/manga/increment"),{data:data,dataType:"json",type:"POST",mimeType:"application/json",success:function(){if(String(data.data.status).toUpperCase()==="COMPLETED")AnimeClient.hide(parentSel);AnimeClient.hide("#loading-shadow");AnimeClient.$("."+type+"s_read",parentSel)[0].textContent=completed;AnimeClient.showMessage("success","Successfully updated "+mangaName);AnimeClient.scrollToTop()},error:function(){AnimeClient.hide("#loading-shadow");
AnimeClient.showMessage("error","Failed to update "+mangaName);AnimeClient.scrollToTop()}})})})()
//# sourceMappingURL=scripts.min.js.map

File diff suppressed because one or more lines are too long

View File

@ -4,8 +4,14 @@
mutation (
$userId: ID!
$id: ID!,
$mediaType: media_type!,
$status: MediaListStatus,
$mediaType: MediaTypeEnum!,
$status: LibraryEntryStatusEnum!,
$notes: String,
$private: Boolean,
$progress: Int,
$reconsumeCount: Int,
$reconsuming: Boolean,
$rating: Int,
) {
libraryEntry {
create(input: {
@ -13,9 +19,30 @@ mutation (
mediaId: $id
mediaType: $mediaType
status: $status
notes: $notes
private: $private
progress: $progress
reconsuming: $reconsuming
reconsumeCount: $reconsumeCount
rating: $rating
}) {
mediaId
libraryEntry {
user {
id
slug
}
media {
id
slug
}
status
notes
private
progress
reconsumeCount
reconsuming
rating
}
}
}
}

View File

@ -1028,32 +1028,32 @@ type LibraryEntryMutation {
"Update library entry progress by id"
updateProgressById(
"Update library entry progress by id"
input: UpdateProgressByIdInput!
input: LibraryEntryUpdateProgressByIdInput!
): LibraryEntryUpdateProgressByIdPayload
"Update library entry progress by media"
updateProgressByMedia(
"Update library entry progress by media"
input: UpdateProgressByMediaInput!
input: LibraryEntryUpdateProgressByMediaInput!
): LibraryEntryUpdateProgressByMediaPayload
"Update library entry rating by id"
updateRatingById(
"Update library entry rating by id"
input: UpdateRatingByIdInput!
input: LibraryEntryUpdateRatingByIdInput!
): LibraryEntryUpdateRatingByIdPayload
"Update library entry rating by media"
updateRatingByMedia(
"Update library entry rating by media"
input: UpdateRatingByMediaInput!
input: LibraryEntryUpdateRatingByMediaInput!
): LibraryEntryUpdateRatingByMediaPayload
"Update library entry status by id"
updateStatusById(
"Update library entry status by id"
input: UpdateStatusByIdInput!
input: LibraryEntryUpdateStatusByIdInput!
): LibraryEntryUpdateStatusByIdPayload
"Update library entry status by media"
updateStatusByMedia(
"Update library entry status by media"
input: UpdateStatusByMediaInput!
input: LibraryEntryUpdateStatusByMediaInput!
): LibraryEntryUpdateStatusByMediaPayload
}
@ -1352,6 +1352,20 @@ type MappingConnection {
totalCount: Int!
}
"Autogenerated return type of MappingCreate"
type MappingCreatePayload {
"Graphql Errors"
errors: [Generic!]
mapping: Mapping
}
"Autogenerated return type of MappingDelete"
type MappingDeletePayload {
"Graphql Errors"
errors: [Generic!]
mapping: GenericDelete
}
"An edge in a connection."
type MappingEdge {
"A cursor for use in pagination."
@ -1360,6 +1374,31 @@ type MappingEdge {
node: Mapping
}
type MappingMutation {
"Create a Mapping"
create(
"Create a Mapping"
input: MappingCreateInput!
): MappingCreatePayload
"Delete a Mapping"
delete(
"Delete a Mapping"
input: GenericDeleteInput!
): MappingDeletePayload
"Update a Mapping"
update(
"Update a Mapping"
input: MappingUpdateInput!
): MappingUpdatePayload
}
"Autogenerated return type of MappingUpdate"
type MappingUpdatePayload {
"Graphql Errors"
errors: [Generic!]
mapping: Mapping
}
"Information about a Character starring in a Media"
type MediaCharacter implements WithTimestamps {
"The character"
@ -1541,6 +1580,7 @@ type Mutation {
anime: AnimeMutation
episode: EpisodeMutation
libraryEntry: LibraryEntryMutation
mapping: MappingMutation
pro: ProMutation!
}
@ -1940,7 +1980,7 @@ type Query {
first: Int,
"Returns the last _n_ elements from the list."
last: Int,
medium: String!
mediaType: MediaTypeEnum!
): MediaConnection!
"List of Library Entries by MediaType and MediaId"
libraryEntriesByMedia(
@ -1977,7 +2017,7 @@ type Query {
first: Int,
"Returns the last _n_ elements from the list."
last: Int,
medium: String!
mediaType: MediaTypeEnum!
): MediaConnection!
"Find a specific Mapping Item by External ID and External Site."
lookupMapping(externalId: ID!, externalSite: MappingExternalSiteEnum!): MappingItemUnion
@ -2015,6 +2055,42 @@ type Query {
"Returns the last _n_ elements from the list."
last: Int
): ProfileConnection!
"Search for Anime by title using Algolia. The most relevant results will be at the top."
searchAnimeByTitle(
"Returns the elements in the list that come after the specified cursor."
after: String,
"Returns the elements in the list that come before the specified cursor."
before: String,
"Returns the first _n_ elements from the list."
first: Int,
"Returns the last _n_ elements from the list."
last: Int,
title: String!
): AnimeConnection!
"Search for Manga by title using Algolia. The most relevant results will be at the top."
searchMangaByTitle(
"Returns the elements in the list that come after the specified cursor."
after: String,
"Returns the elements in the list that come before the specified cursor."
before: String,
"Returns the first _n_ elements from the list."
first: Int,
"Returns the last _n_ elements from the list."
last: Int,
title: String!
): MangaConnection!
"Search for any media (Anime, Manga) by title using Algolia. The most relevant results will be at the top."
searchMediaByTitle(
"Returns the elements in the list that come after the specified cursor."
after: String,
"Returns the elements in the list that come before the specified cursor."
before: String,
"Returns the first _n_ elements from the list."
first: Int,
"Returns the last _n_ elements from the list."
last: Int,
title: String!
): MediaConnection!
"Get your current session info"
session: Session!
}
@ -2395,6 +2471,16 @@ enum MappingExternalSiteEnum {
TRAKT
}
enum MappingItemEnum {
ANIME
CATEGORY
CHARACTER
EPISODE
MANGA
PERSON
PRODUCER
}
"これはアニメやマンガです"
enum MediaTypeEnum {
ANIME
@ -2551,47 +2637,62 @@ input LibraryEntryUpdateInput {
volumesOwned: Int
}
input LibraryEntryUpdateProgressByIdInput {
id: ID!
progress: Int!
}
input LibraryEntryUpdateProgressByMediaInput {
mediaId: ID!
mediaType: MediaTypeEnum!
progress: Int!
}
input LibraryEntryUpdateRatingByIdInput {
id: ID!
"A number between 2 - 20"
rating: Int!
}
input LibraryEntryUpdateRatingByMediaInput {
mediaId: ID!
mediaType: MediaTypeEnum!
"A number between 2 - 20"
rating: Int!
}
input LibraryEntryUpdateStatusByIdInput {
id: ID!
status: LibraryEntryStatusEnum!
}
input LibraryEntryUpdateStatusByMediaInput {
mediaId: ID!
mediaType: MediaTypeEnum!
status: LibraryEntryStatusEnum!
}
input MappingCreateInput {
externalId: ID!
externalSite: MappingExternalSiteEnum!
itemId: ID!
itemType: MappingItemEnum!
}
input MappingUpdateInput {
externalId: ID
externalSite: MappingExternalSiteEnum
id: ID!
itemId: ID
itemType: MappingItemEnum
}
input TitlesListInput {
alternatives: [String!]
canonicalLocale: String
localized: Map
}
input UpdateProgressByIdInput {
id: ID!
progress: Int!
}
input UpdateProgressByMediaInput {
mediaId: ID!
mediaType: MediaTypeEnum!
progress: Int!
}
input UpdateRatingByIdInput {
id: ID!
"A number between 2 - 20"
rating: Int!
}
input UpdateRatingByMediaInput {
mediaId: ID!
mediaType: MediaTypeEnum!
"A number between 2 - 20"
rating: Int!
}
input UpdateStatusByIdInput {
id: ID!
status: LibraryEntryStatusEnum!
}
input UpdateStatusByMediaInput {
mediaId: ID!
mediaType: MediaTypeEnum!
status: LibraryEntryStatusEnum!
}
"A date, expressed as an ISO8601 string"
scalar Date