Skip to content

Commit

Permalink
Merge pull request #144 from Suwayomi/main
Browse files Browse the repository at this point in the history
more sorts in library + server settings
  • Loading branch information
Robonau authored Feb 1, 2024
2 parents f7bfdcd + fcc85d4 commit 2a80276
Show file tree
Hide file tree
Showing 17 changed files with 979 additions and 13 deletions.
26 changes: 26 additions & 0 deletions schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,11 @@ type PartialSettingsType implements Settings {
excludeNotStarted: Boolean
excludeUnreadChapters: Boolean
extensionRepos: [String!]
flareSolverrEnabled: Boolean
flareSolverrSessionName: String
flareSolverrSessionTtl: Int
flareSolverrTimeout: Int
flareSolverrUrl: String
globalUpdateInterval: Float
gqlDebugLogsEnabled: Boolean
initialOpenInBrowserEnabled: Boolean
Expand Down Expand Up @@ -566,6 +571,11 @@ type SettingsType implements Settings {
excludeNotStarted: Boolean!
excludeUnreadChapters: Boolean!
extensionRepos: [String!]!
flareSolverrEnabled: Boolean!
flareSolverrSessionName: String!
flareSolverrSessionTtl: Int!
flareSolverrTimeout: Int!
flareSolverrUrl: String!
globalUpdateInterval: Float!
gqlDebugLogsEnabled: Boolean!
initialOpenInBrowserEnabled: Boolean!
Expand Down Expand Up @@ -683,6 +693,10 @@ type TrackSearchType {
trackingUrl: String!
tracker: TrackerType!
}
type TrackStatusType {
name: String!
value: Int!
}
type TrackerEdge implements Edge {
cursor: Cursor!
node: TrackerType!
Expand All @@ -699,6 +713,8 @@ type TrackerType {
id: Int!
isLoggedIn: Boolean!
name: String!
scores: [String!]!
statuses: [TrackStatusType!]!
trackRecords: TrackRecordNodeList!
}
type TriStateFilter {
Expand Down Expand Up @@ -849,6 +865,11 @@ interface Settings {
excludeNotStarted: Boolean
excludeUnreadChapters: Boolean
extensionRepos: [String!]
flareSolverrEnabled: Boolean
flareSolverrSessionName: String
flareSolverrSessionTtl: Int
flareSolverrTimeout: Int
flareSolverrUrl: String
globalUpdateInterval: Float
gqlDebugLogsEnabled: Boolean
initialOpenInBrowserEnabled: Boolean
Expand Down Expand Up @@ -1377,6 +1398,11 @@ input PartialSettingsTypeInput {
excludeNotStarted: Boolean
excludeUnreadChapters: Boolean
extensionRepos: [String!]
flareSolverrEnabled: Boolean
flareSolverrSessionName: String
flareSolverrSessionTtl: Int
flareSolverrTimeout: Int
flareSolverrUrl: String
globalUpdateInterval: Float
gqlDebugLogsEnabled: Boolean
initialOpenInBrowserEnabled: Boolean
Expand Down
9 changes: 9 additions & 0 deletions src/gql/Fragments.gql
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,15 @@ fragment MangaTypeFragment on MangaType {
thumbnailUrl
unreadCount
downloadCount
latestFetchedChapter {
fetchedAt
}
latestUploadedChapter {
uploadDate
}
latestReadChapter {
lastReadAt
}
lastReadChapter {
lastReadAt
}
Expand Down
46 changes: 46 additions & 0 deletions src/gql/Mutations.gql
Original file line number Diff line number Diff line change
Expand Up @@ -503,3 +503,49 @@ mutation updateTrack($input: UpdateTrackInput!) {
}
}
}

mutation setServerSettings($settings: PartialSettingsTypeInput = {}) {
setSettings(input: { settings: $settings }) {
settings {
autoDownloadAheadLimit
autoDownloadNewChapters
backupInterval
backupPath
backupTTL
backupTime
basicAuthEnabled
basicAuthPassword
basicAuthUsername
debugLogsEnabled
downloadAsCbz
downloadsPath
electronPath
excludeCompleted
excludeNotStarted
excludeEntryWithUnreadChapters
excludeUnreadChapters
flareSolverrEnabled
extensionRepos
flareSolverrSessionName
flareSolverrSessionTtl
flareSolverrTimeout
flareSolverrUrl
globalUpdateInterval
gqlDebugLogsEnabled
initialOpenInBrowserEnabled
ip
localSourcePath
maxSourcesInParallel
port
socksProxyEnabled
socksProxyHost
socksProxyPort
systemTrayEnabled
updateMangas
webUIChannel
webUIFlavor
webUIInterface
webUIUpdateCheckInterval
}
}
}
52 changes: 51 additions & 1 deletion src/gql/Queries.gql
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,13 @@ query category($id: Int!) {
thumbnailUrl
unreadCount
downloadCount
lastReadChapter {
latestFetchedChapter {
fetchedAt
}
latestUploadedChapter {
uploadDate
}
latestReadChapter {
lastReadAt
}
chapters {
Expand Down Expand Up @@ -412,3 +418,47 @@ query trackRecords {
}
}
}

query serverSettings {
settings {
autoDownloadAheadLimit
autoDownloadNewChapters
backupInterval
backupPath
backupTTL
backupTime
basicAuthEnabled
basicAuthPassword
basicAuthUsername
debugLogsEnabled
downloadAsCbz
downloadsPath
electronPath
excludeCompleted
excludeEntryWithUnreadChapters
excludeNotStarted
extensionRepos
excludeUnreadChapters
flareSolverrEnabled
flareSolverrSessionName
flareSolverrSessionTtl
flareSolverrTimeout
flareSolverrUrl
globalUpdateInterval
gqlDebugLogsEnabled
initialOpenInBrowserEnabled
ip
localSourcePath
maxSourcesInParallel
port
socksProxyEnabled
socksProxyHost
socksProxyPort
systemTrayEnabled
updateMangas
webUIChannel
webUIFlavor
webUIInterface
webUIUpdateCheckInterval
}
}
213 changes: 208 additions & 5 deletions src/lib/generated.ts

Large diffs are not rendered by default.

6 changes: 4 additions & 2 deletions src/lib/simpleStores.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,10 @@ type mangaMeta = typeof mangaMetaDefaults;
export enum sort {
Unread = 'Unread',
Alphabetical = 'Alphabetical',
'Last Read' = 'Last Read',
ID = 'ID'
ID = 'ID',
'Latest Read' = 'Latest Read',
'Latest Fetched' = 'Latest Fetched',
'Latest Uploaded' = 'Latest Uploaded'
}

export enum display {
Expand Down
31 changes: 30 additions & 1 deletion src/lib/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@ import {
type BindTrackMutation,
type UpdateTrackMutation,
type GetMangaQuery,
GetMangaDoc
GetMangaDoc,
type SetServerSettingsMutation,
ServerSettingsDoc,
setServerSettings,
type PartialSettingsTypeInput
} from './generated';
import type { FetchResult } from '@apollo/client/link/core';

Expand Down Expand Up @@ -217,6 +221,12 @@ export type PartialBy<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
export function enumKeys<E extends object>(e: E): (keyof E)[] {
return Object.keys(e) as (keyof E)[];
}
export function enumValues<E extends object>(e: E): E[keyof E][] {
return Object.values(e) as E[keyof E][];
}
export function enumEntries<E extends object>(e: E): [keyof E, E[keyof E]][] {
return Object.entries(e) as [keyof E, E[keyof E]][];
}

export function groupBy<T extends object, K extends T[keyof T]>(
list: T[],
Expand Down Expand Up @@ -290,3 +300,22 @@ export function bindTrackUpdater(
data: { manga: mga }
});
}

export function setServerSettingsUpdater(
cache: ApolloCache<unknown>,
{ data }: FetchResult<SetServerSettingsMutation>
) {
if (!data) return;
const settings = data.setSettings.settings;
cache.writeQuery({
query: ServerSettingsDoc,
data: { settings }
});
}

export function setSettings(settings: PartialSettingsTypeInput) {
ErrorHelp(
'failed to set server settings',
setServerSettings({ variables: { settings }, update: setServerSettingsUpdater })
);
}
15 changes: 13 additions & 2 deletions src/routes/(app)/(library)/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,20 @@
case sort.Alphabetical:
tru = a.title > b.title;
break;
case sort['Last Read']:
tru = a.lastReadChapter?.lastReadAt > b.lastReadChapter?.lastReadAt;
case sort['Latest Read']:
tru =
parseInt(a.latestReadChapter?.lastReadAt ?? 0) >
parseInt(b.latestReadChapter?.lastReadAt ?? 0);
break;
case sort['Latest Fetched']:
tru =
parseInt(a.latestFetchedChapter?.fetchedAt ?? 0) >
parseInt(b.latestFetchedChapter?.fetchedAt ?? 0);
break;
case sort['Latest Uploaded']:
tru =
parseInt(a.latestUploadedChapter?.uploadDate ?? 0) >
parseInt(b.latestUploadedChapter?.uploadDate ?? 0);
}
if ($Meta.Asc) tru = !tru;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,9 @@
thumbnailUrl: dat.manga.thumbnailUrl,
unreadCount: dat.manga.unreadCount ?? 0,
downloadCount: dat.manga.downloadCount ?? 0,
lastReadChapter: dat.manga.lastReadChapter ?? undefined,
latestFetchedChapter: dat.manga.latestFetchedChapter,
latestReadChapter: dat.manga.latestReadChapter,
latestUploadedChapter: dat.manga.latestUploadedChapter,
chapters: dat.manga.chapters ?? {
totalCount: 0
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,9 @@
thumbnailUrl: manga.thumbnailUrl,
unreadCount: manga.unreadCount,
downloadCount: manga.downloadCount,
lastReadChapter: manga.lastReadChapter,
latestFetchedChapter: manga.latestFetchedChapter,
latestReadChapter: manga.latestReadChapter,
latestUploadedChapter: manga.latestUploadedChapter,
chapters: manga.chapters
};
// add to categories that now have it
Expand Down
7 changes: 7 additions & 0 deletions src/routes/(app)/settings/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -141,3 +141,10 @@
<IconWrapper class="h-full w-auto p-2" name="mdi:files" />
<div class="w-full">Cache</div>
</button>
<a
href="/settings/server"
class=" text-left flex items-center w-full h-16 hover:variant-glass-surface cursor-pointer"
>
<IconWrapper class="h-full w-auto p-2" name="mdi:server" />
<div class="w-full">Server Settings</div>
</a>
Loading

0 comments on commit 2a80276

Please sign in to comment.