Skip to content

Commit

Permalink
Add debug button for notifications, 2000 chapters
Browse files Browse the repository at this point in the history
  • Loading branch information
luminamystere committed Dec 3, 2024
1 parent 7afeeb5 commit 1dca41b
Show file tree
Hide file tree
Showing 2 changed files with 82 additions and 11 deletions.
41 changes: 32 additions & 9 deletions src/ui/view/DebugView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,9 @@ export default ViewDefinition({
await BUTTON_REGISTRY.createAuthor.execute("single story author", "justonestory", "<mention vanity=\"somanystories\"> writes so much")
await BUTTON_REGISTRY.createWork.execute("one big work", "made by <mention vanity=\"justonestory\">", "wow description", "bigstory", "Ongoing", "Public")
await BUTTON_REGISTRY.createChapter.execute("justonestory", "bigstory", "big story 1", "start of a long story", "Public")
await BUTTON_REGISTRY.createChapter.execute("justonestory", "bigstory", "big story interlude", "middle of a long story", "Public", false)
await BUTTON_REGISTRY.createChapter.execute("justonestory", "bigstory", "big story 2", "aaaa", "Public")
await BUTTON_REGISTRY.createChapter.execute("justonestory", "bigstory", "big story 3", "aaaaaaa", "Public")
await BUTTON_REGISTRY.createChapter.execute("justonestory", "bigstory", "big story interlude", "middle of a long story", "Public", false, "only notes before")
await BUTTON_REGISTRY.createChapter.execute("justonestory", "bigstory", "big story 2", "aaaa", "Public", undefined, "only notes after")
await BUTTON_REGISTRY.createChapter.execute("justonestory", "bigstory", "big story 3", "aaaaaaa", "Public", true, "both notes before", "and notes after")
await BUTTON_REGISTRY.createChapter.execute("justonestory", "bigstory", "big story 3.1", "aaaaaaaaaaaaaaaaaaa", "Public", false)
await BUTTON_REGISTRY.createChapter.execute("justonestory", "bigstory", "big story 3.2", "aaaaaaaaaaaaaaaaaaa", "Private", false)
await BUTTON_REGISTRY.createChapter.execute("justonestory", "bigstory", "big story 3.3", "aaaaaaaaaaaaaaaaaaa", "Public")
Expand Down Expand Up @@ -147,6 +147,13 @@ export default ViewDefinition({
},
}))

profileButtons.append(createButton({
name: "Set Chiri Patreon chapters",
async execute () {
await BUTTON_REGISTRY.patreonSetThresholds.execute("justonestory", "bigstory", "Patreon", ["8", "9"], "4392761")
},
}))


const followButtons = Block().appendTo(view)

Expand All @@ -172,13 +179,11 @@ export default ViewDefinition({
}))

followButtons.append(createButton({
name: "Create 40 works",
name: "Create a work with loads of chapters",
async execute () {
for (let i = 0; i < 30; i++) {
await BUTTON_REGISTRY.createWork.execute(`test story ${i}`, "aaaaaaaaa", "short description aaaaa", `teststory${i}`, "Ongoing", "Public")
}
for (let i = 0; i < 30; i++) {
await BUTTON_REGISTRY.follow.execute("work", `teststory${i}`)
await BUTTON_REGISTRY.createWork.execute("even longer story", "aaaaaaaaa", "short description aaaaa", "wowbig", "Ongoing", "Public")
for (let i = 0; i < 2000; i++) {
await BUTTON_REGISTRY.createChapter.execute("justonestory", "wowbig", `chapter ${i}`, `wow chapter body ${i}`, "Public")
}

},
Expand Down Expand Up @@ -564,6 +569,24 @@ export default ViewDefinition({
},
}))

const notifButtons = Block().appendTo(view)

notifButtons.append(createButton({
name: "Get Notifications",
async execute () {
await BUTTON_REGISTRY.notificationsGet.execute()
await BUTTON_REGISTRY.notificationsGetUnread.execute()
},
}))

notifButtons.append(createButton({
name: "Mark Notifications Read",
async execute () {
await BUTTON_REGISTRY.notificationsMark.execute("read", ["ba397c1b-02e5-462c-b367-04b007d1f09a", "d8830a0c-3e2c-4caa-ae4b-679a8c5cefa5"])
await BUTTON_REGISTRY.notificationsMark.execute("unread", ["ba397c1b-02e5-462c-b367-04b007d1f09a", "3b9781ea-d15d-4915-bbeb-4788ed734453"])
},
}))

return view
},
})
52 changes: 50 additions & 2 deletions src/ui/view/debug/ButtonRegistry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ export const BUTTON_REGISTRY = {

createChapter: {
name: "Create Chapter",
async execute (author: string, work_url: string, name: string, body: string, visibility?: string, is_numbered?: boolean) {
async execute (author: string, work_url: string, name: string, body: string, visibility?: string, is_numbered?: boolean, notesBefore?: string, notesAfter?: string) {
const response = await fetch(`${Env.API_ORIGIN}work/${author}/${work_url}/chapter/create`, {
method: "POST",
credentials: "include",
Expand All @@ -181,6 +181,8 @@ export const BUTTON_REGISTRY = {
body: body,
visibility: visibility,
is_numbered: is_numbered,
notes_before: notesBefore,
notes_after: notesAfter,
}),
}).then(response => response.json())
console.log(response)
Expand All @@ -189,7 +191,7 @@ export const BUTTON_REGISTRY = {

updateChapter: {
name: "Update Chapter",
async execute (author: string, work_url: string, index: number, name?: string, body?: string, visibility?: string, is_numbered?: boolean) {
async execute (author: string, work_url: string, index: number, name?: string, body?: string, visibility?: string, is_numbered?: boolean, notesBefore?: string, notesAfter?: string) {
const response = await fetch(`${Env.API_ORIGIN}work/${author}/${work_url}/chapter/${index}/update`, {
method: "POST",
credentials: "include",
Expand All @@ -201,6 +203,8 @@ export const BUTTON_REGISTRY = {
body,
visibility,
is_numbered,
notes_before: notesBefore,
notes_after: notesAfter,
}),
}).then(response => response.json())
console.log(response)
Expand Down Expand Up @@ -888,4 +892,48 @@ export const BUTTON_REGISTRY = {
},
},

notificationsGet: {
name: "Get Notifications",
async execute () {
const response = await fetch(`${Env.API_ORIGIN}notifications/get/all`, {
method: "GET",
credentials: "include",
headers: {
"Content-Type": "application/json",
},
}).then(response => response.json())
console.log(response)
},
},

notificationsGetUnread: {
name: "Get Unread Notifications",
async execute () {
const response = await fetch(`${Env.API_ORIGIN}notifications/get/unread`, {
method: "GET",
credentials: "include",
headers: {
"Content-Type": "application/json",
},
}).then(response => response.json())
console.log(response)
},
},

notificationsMark: {
name: "Mark Notifications Read/Unread",
async execute (state: "read" | "unread", notifications: string[]) {
await fetch(`${Env.API_ORIGIN}notifications/mark/${state}`, {
method: "POST",
credentials: "include",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
notification_ids: notifications,
}),
})
},
},

} satisfies Record<string, IButtonImplementation<any[]>>

0 comments on commit 1dca41b

Please sign in to comment.