-
Notifications
You must be signed in to change notification settings - Fork 54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/mark-chapters-as-read-based-on-tracker-history #708
Closed
taos15
wants to merge
15
commits into
Suwayomi:master
from
taos15:feature/mark-chapters-as-read-based-on-tracker-history
Closed
Changes from 8 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
4434467
refactor: creates utilities functions to work with lists
taos15 fee6af5
refactor(chapters): removes commented out code, and implement ultil f…
taos15 17ed5f7
refactor TrackMangaButton to update local source if the tracker last …
taos15 7018000
Merge branch 'master' of github.com:Suwayomi/Suwayomi-WebUI into feat…
taos15 6303749
refactor(packe.json): adds --host flag to the vite command to be able…
taos15 7e2dacb
refactor(findElement.ts): removes commented code
taos15 d518d8f
fix(gerPartialList): changes the if statement to return an empty arra…
taos15 d673e50
fix(getPartialList): returns the whole array if the index is 0
taos15 ffd6f82
feat(apolloClient): adds credential properties to the client to sent …
taos15 90308e6
feat(fetch class): adds credential property to the config of the fetc…
taos15 112857c
fix: adds logic to mark partial chapters as read
taos15 7b0ed6e
fix: adds condition to check that the chapter to be updated is not read.
taos15 1a7a8d0
removes local files from .gitignore
taos15 80527ce
Merge branch 'master' into feature/mark-chapters-as-read-based-on-tra…
taos15 9b8f66e
fix(tracke): awaits for the tracker modal to update the tracker befor…
taos15 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,3 +9,7 @@ build/* | |
tools/scripts/github_token.json | ||
|
||
src/lib/graphql/schema.json | ||
|
||
# local dev | ||
pnpm-*.yaml | ||
compose.yml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* | ||
* Copyright (C) Contributors to the Suwayomi project | ||
* | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. | ||
*/ | ||
|
||
import { findIndexOfElement } from '@/components/util/findIndexOfElement.ts'; | ||
|
||
// fieldToSearch string | any[] | ||
export const findElement = <T>( | ||
elements: T[], | ||
fieldToSearch: string, | ||
fieldToMatch: unknown, | ||
isFieldToSearchArray?: boolean, | ||
): T | undefined => { | ||
const index = findIndexOfElement(elements, fieldToSearch, fieldToMatch, isFieldToSearchArray); | ||
|
||
if (!index) { | ||
return undefined; | ||
} | ||
return elements[index]; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* | ||
* Copyright (C) Contributors to the Suwayomi project | ||
* | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. | ||
*/ | ||
|
||
/** | ||
* | ||
* @param elements The array that will be search | ||
* @param fieldToSearch The key of the elements that will be search | ||
* @param fieldToMatch The value the fieldToSearch key needs to match | ||
* @param isFieldToSearchArray Whether the key of the fieldToSearch is an array or not. Default to false | ||
* @example findIndexOfElement(mangas, "id", passedManga.id) | ||
* @returns The index of the element if found, or undefine if not found. | ||
*/ | ||
export const findIndexOfElement = <T>( | ||
elements: T[], | ||
fieldToSearch: string, | ||
fieldToMatch: unknown, | ||
isFieldToSearchArray: boolean = false, | ||
): number | undefined => { | ||
let elementFoundIndex: number; | ||
|
||
if (isFieldToSearchArray) { | ||
elementFoundIndex = elements.findIndex((element: T | any) => | ||
element[fieldToSearch].some((field: any) => field === fieldToMatch), | ||
); | ||
} else { | ||
// do a some() logic checking for boolean, so fieldToMatch fieldToMatch | ||
elementFoundIndex = elements.findIndex((element: T | any) => element[fieldToSearch] === fieldToMatch); | ||
} | ||
return elementFoundIndex; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* | ||
* Copyright (C) Contributors to the Suwayomi project | ||
* | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. | ||
*/ | ||
|
||
import { findIndexOfElement } from '@/components/util/findIndexOfElement.ts'; | ||
|
||
/** | ||
*@description This function takes a element's id and a list of the same element, and it return either the first | ||
of second half of the list using the element id as the pivot point. | ||
* @param elementId The Id of the emeent to be use as pivot. | ||
* @param allElements The list of elements to be firtered. | ||
* @param halfOfList There part of the list to be return. Either the first half or the second. | ||
* @param indexOffset The offsett to set for the index. By default set to 1, so the first have will not include the pivot element | ||
* and the second half will include the first element. | ||
* @returns The first of the second half of a list using the elementId passed as the pivots. | ||
*/ | ||
export const getPartialList = <T>( | ||
elementId: number, | ||
allElements: T[], | ||
halfOfList: 'first' | 'second' = 'first', | ||
indexOffset: number = 1, | ||
): T[] => { | ||
const index = findIndexOfElement(allElements, 'id', elementId); | ||
if (index === undefined) { | ||
return [] as T[]; | ||
} | ||
if (halfOfList === 'second') { | ||
if (index + indexOffset > allElements.length - 1) { | ||
return [] as T[]; | ||
} | ||
if (index === 0) { | ||
return allElements; | ||
} | ||
return allElements.slice(index + indexOffset); | ||
} | ||
|
||
return allElements.slice(0, index + indexOffset); | ||
}; |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use the
Chapters
class - same for all the added util functions