move NotificationOption and ListActivityOption fields into User.ts

This commit is contained in:
DrakeTDL 2023-10-10 17:17:01 -07:00
parent 4a73d9460d
commit 06277ce868
No known key found for this signature in database
2 changed files with 24 additions and 25 deletions

View File

@ -158,28 +158,6 @@ export const FuzzyDate = ({ query, level }: Fields<typeof updateOperation>) => (
},
})
export const NotificationOption = (query: ReturnType<typeof updateOperation>[], level: number) => ({
withEnabled() {
query[0] = query[0].set({ subField: "enabled", level })
return this
},
withType() {
query[0] = query[0].set({ subField: "type", level })
return this
},
})
export const ListActivityOption = (query: ReturnType<typeof updateOperation>[], level: number) => ({
withDisabled() {
query[0] = query[0].set({ subField: "disabled", level })
return this
},
withType() {
query[0] = query[0].set({ subField: "type", level })
return this
},
})
export const PageInfo = ({ query, level }: Fields<typeof updateOperation>) => ({
/** The total number of items. Note: This value is not guaranteed to be accurate, do not rely on this for logic */
withTotal() {

View File

@ -1,6 +1,27 @@
import { ListActivityOption, NotificationOption } from "../anilist.ts"
import { Fields, Fn, UpdateOperation } from "../types/Anilist.ts"
const NotificationOption = ({ query, level }: Fields<UpdateOperation>) => ({
withEnabled() {
query[0] = query[0].set({ subField: "enabled", level })
return this
},
withType() {
query[0] = query[0].set({ subField: "type", level })
return this
},
})
const ListActivityOption = ({ query, level }: Fields<UpdateOperation>) => ({
withDisabled() {
query[0] = query[0].set({ subField: "disabled", level })
return this
},
withType() {
query[0] = query[0].set({ subField: "type", level })
return this
},
})
export const UserPreviousName = ({ query, level }: Fields<UpdateOperation>) => ({
/** A previous name of the user. */
withName() {
@ -52,7 +73,7 @@ export const UserOptions = ({ query, level }: Fields<UpdateOperation>) => ({
if (!fn) query[0] = query[0].set({ subField: "type", level: level + 1 })
else {
let tmpQuery
fn(NotificationOption(tmpQuery = [query[0]], level + 1))
fn(NotificationOption({ query: tmpQuery = [query[0]], level: level + 1 }))
query[0] = tmpQuery[0]
}
return this
@ -94,7 +115,7 @@ export const UserOptions = ({ query, level }: Fields<UpdateOperation>) => ({
if (!fn) query[0] = query[0].set({ subField: "type", level: level + 1 })
else {
let tmpQuery
fn(ListActivityOption(tmpQuery = [query[0]], level + 1))
fn(ListActivityOption({ query: tmpQuery = [query[0]], level: level + 1 }))
query[0] = tmpQuery[0]
}
return this