Skip to content

Commit

Permalink
Add label to viewWork, fix UpdateChapter and DeleteChapter
Browse files Browse the repository at this point in the history
  • Loading branch information
luminamystere committed Jul 20, 2024
1 parent 73a2847 commit 0c82132
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 36 deletions.
85 changes: 58 additions & 27 deletions src/Fluff4me.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ export default class Fluff4me {
profileButtons.append(createButton({
name: "View Profile 1",
async execute () {
await BUTTON_REGISTRY.viewAuthor.execute("somanystories");
await BUTTON_REGISTRY.viewAuthor.execute("author with many stories", "somanystories");
},
}));

Expand All @@ -139,15 +139,30 @@ export default class Fluff4me {
await BUTTON_REGISTRY.createWork.execute("one big work", "it's long", "bigstory", "Ongoing", "Public");
await BUTTON_REGISTRY.createChapter.execute("big story", "start of a long story", "bigstory", "Public");
await BUTTON_REGISTRY.createChapter.execute("big story 2", "middle of a long story", "bigstory", "Public");
await BUTTON_REGISTRY.createChapter.execute("big story 3", "still the middle of a long story", "bigstory", "Public");
await BUTTON_REGISTRY.follow.execute("work", "debut");
await BUTTON_REGISTRY.createChapter.execute("big story 3", "aaaa", "bigstory", "Public");
await BUTTON_REGISTRY.createChapter.execute("big story 4", "aaaaaaa", "bigstory", "Public");
await BUTTON_REGISTRY.createChapter.execute("big story 5", "aaaaaaaaaaaaaaaaaaa", "bigstory", "Public");
await BUTTON_REGISTRY.viewWork.execute("big story five chapters", "bigstory");
// await BUTTON_REGISTRY.follow.execute("work", "debut");
await BUTTON_REGISTRY.createWork.execute("tried a new story", "test thing", "anotherstory", "Hiatus", "Public");
await BUTTON_REGISTRY.viewWork.execute("on creation 0 chapters", "anotherstory");
await BUTTON_REGISTRY.createChapter.execute("chapter one", "some chapter data", "anotherstory", "Public");
await BUTTON_REGISTRY.createChapter.execute("chapter two", "some chapter data", "anotherstory", "Private");
await BUTTON_REGISTRY.viewWork.execute("one public one private", "anotherstory");
await BUTTON_REGISTRY.updateChapter.execute("anotherstory", 2, undefined, undefined, "Patreon");
await BUTTON_REGISTRY.viewWork.execute("one public one patreon", "anotherstory");
await BUTTON_REGISTRY.deleteChapter.execute("anotherstory", 2);
await BUTTON_REGISTRY.viewWork.execute("delete second chapter", "anotherstory");
await BUTTON_REGISTRY.deleteChapter.execute("anotherstory", 1);
await BUTTON_REGISTRY.viewWork.execute("delete first chapter", "anotherstory");
await BUTTON_REGISTRY.deleteWork.execute("anotherstory");
},
}));

profileButtons.append(createButton({
name: "View Profile 2",
async execute () {
await BUTTON_REGISTRY.viewAuthor.execute("justonestory");
await BUTTON_REGISTRY.viewAuthor.execute("justonestory author", "justonestory");
},
}));

Expand All @@ -167,42 +182,58 @@ export default class Fluff4me {
profileButtons.append(createButton({
name: "View Profile 3",
async execute () {
await BUTTON_REGISTRY.viewAuthor.execute("ifollowpeople");
await BUTTON_REGISTRY.viewAuthor.execute("ifollowpeople author", "ifollowpeople");
},
}));

const testButtons = document.createElement("div");
document.body.append(testButtons);

testButtons.append(createButton({
name: "Test Following Private Works",
name: "Test New Following",
async execute () {
await BUTTON_REGISTRY.createWork.execute("private from start", "aaaaaaa", "story1", "Ongoing", "Private");
await BUTTON_REGISTRY.createChapter.execute("aaaaa", "aaaaaaa", "story1", "Private");
await BUTTON_REGISTRY.follow.execute("work", "story1");
await BUTTON_REGISTRY.getFollow.execute("work", "story1");
await BUTTON_REGISTRY.createAuthor.execute("new follows", "thefollower");
await BUTTON_REGISTRY.createWork.execute("wow a work", "test pls ignore", "wowawork", "Ongoing", "Public");
await BUTTON_REGISTRY.follow.execute("author", "thefollower");
await BUTTON_REGISTRY.follow.execute("work", "wowawork");
await BUTTON_REGISTRY.getFollow.execute("author", "thefollower");
await BUTTON_REGISTRY.getAllFollows.execute("work");
await BUTTON_REGISTRY.getAllFollowsMerged.execute();
await BUTTON_REGISTRY.unignore.execute("work", "wowawork");
// await BUTTON_REGISTRY.unfollow.execute("work", "wowawork");
await BUTTON_REGISTRY.getFollow.execute("work", "wowawork");
},
}));

testButtons.append(createButton({
name: "Test Following Works Made Private",
async execute () {
await BUTTON_REGISTRY.createWork.execute("made private later", "bbbbbbbb", "story2", "Ongoing", "Public");
await BUTTON_REGISTRY.createChapter.execute("bbbbbb", "bbbbbbbb", "story2", "Public");
await BUTTON_REGISTRY.follow.execute("work", "story2");
await BUTTON_REGISTRY.getFollow.execute("work", "story2");
await BUTTON_REGISTRY.getAllFollows.execute("work");
await BUTTON_REGISTRY.getAllFollowsMerged.execute();
await BUTTON_REGISTRY.updateWork.execute("story2", undefined, undefined, undefined, undefined, "Private");
await BUTTON_REGISTRY.viewWork.execute("story2");
await BUTTON_REGISTRY.getFollow.execute("work", "story2");
await BUTTON_REGISTRY.getAllFollows.execute("work");
await BUTTON_REGISTRY.getAllFollowsMerged.execute();

},
}));
// testButtons.append(createButton({
// name: "Test Following Private Works",
// async execute () {
// await BUTTON_REGISTRY.createWork.execute("private from start", "aaaaaaa", "story1", "Ongoing", "Private");
// await BUTTON_REGISTRY.createChapter.execute("aaaaa", "aaaaaaa", "story1", "Private");
// await BUTTON_REGISTRY.follow.execute("work", "story1");
// await BUTTON_REGISTRY.getFollow.execute("work", "story1");
// await BUTTON_REGISTRY.getAllFollows.execute("work");
// await BUTTON_REGISTRY.getAllFollowsMerged.execute();
// },
// }));

// testButtons.append(createButton({
// name: "Test Following Works Made Private",
// async execute () {
// await BUTTON_REGISTRY.createWork.execute("made private later", "bbbbbbbb", "story2", "Ongoing", "Public");
// await BUTTON_REGISTRY.createChapter.execute("bbbbbb", "bbbbbbbb", "story2", "Public");
// await BUTTON_REGISTRY.follow.execute("work", "story2");
// await BUTTON_REGISTRY.getFollow.execute("work", "story2");
// await BUTTON_REGISTRY.getAllFollows.execute("work");
// await BUTTON_REGISTRY.getAllFollowsMerged.execute();
// await BUTTON_REGISTRY.updateWork.execute("story2", undefined, undefined, undefined, undefined, "Private");
// await BUTTON_REGISTRY.viewWork.execute("story2");
// await BUTTON_REGISTRY.getFollow.execute("work", "story2");
// await BUTTON_REGISTRY.getAllFollows.execute("work");
// await BUTTON_REGISTRY.getAllFollowsMerged.execute();

// },
// }));

testButtons.append(createButton({
name: "Create 40 works",
Expand Down
18 changes: 9 additions & 9 deletions src/dev/ButtonRegistry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,11 @@ export const BUTTON_REGISTRY = {

viewAuthor: {
name: "View Author",
async execute (vanity: string) {
async execute (label: string, vanity: string) {
const response = await fetch(`${Env.API_ORIGIN}author/${vanity}/get`, {
credentials: "include",
}).then(response => response.json());
console.log(response);
console.log(label, response);
},
},

Expand Down Expand Up @@ -129,11 +129,11 @@ export const BUTTON_REGISTRY = {

viewWork: {
name: "View Work",
async execute (url: string) {
async execute (label: string, url: string) {
const response = await fetch(`${Env.API_ORIGIN}work/${url}/get`, {
credentials: "include",
}).then(response => response.json());
console.log(response);
console.log(label, response);
},
},

Expand All @@ -157,8 +157,8 @@ export const BUTTON_REGISTRY = {

updateChapter: {
name: "Update Chapter",
async execute (name?: string, body?: string, visibility?: string) {
await fetch(`${Env.API_ORIGIN}work/a-fancy-story/chapter/1/update`, {
async execute (workVanity: string, index: number, name?: string, body?: string, visibility?: string) {
await fetch(`${Env.API_ORIGIN}work/${workVanity}/chapter/${index}/update`, {
method: "POST",
credentials: "include",
headers: {
Expand All @@ -175,7 +175,7 @@ export const BUTTON_REGISTRY = {

deleteChapter: {
name: "Delete Chapter",
async execute (work_url: string, index: string) {
async execute (work_url: string, index: number) {
await fetch(`${Env.API_ORIGIN}work/${work_url}/chapter/${index}/delete`, {
method: "POST",
credentials: "include",
Expand All @@ -188,11 +188,11 @@ export const BUTTON_REGISTRY = {

viewChapter: {
name: "View Chapter",
async execute (work_url: string, index: string) {
async execute (label: string, work_url: string, index: string) {
const response = await fetch(`${Env.API_ORIGIN}work/${work_url}/chapter/${index}/get`, {
credentials: "include",
}).then(response => response.json());
console.log(response);
console.log(label, response);
},
},

Expand Down

0 comments on commit 0c82132

Please sign in to comment.