Skip to content

Commit

Permalink
#212 Avoid naming collision with author page tag insertion
Browse files Browse the repository at this point in the history
  • Loading branch information
braxtonhall committed Jan 12, 2023
1 parent 9a487ae commit 40d78cb
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/ts/content/extensions/author/authorPage/authorUI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ const appendUI = (container: Element, handlers: ButtonHandlers, getTagsCallback:
viewExistingTags();
};

const insertTags = (tags: string[]) => {
const renderAuthorTags = (tags: string[]) => {
const list = document.getElementById(TAG_LIST_ID);
const input = document.getElementById(AUTHOR_TAG_INPUT_ID) as HTMLInputElement;
if (tags.length === 0) {
Expand All @@ -144,4 +144,4 @@ const getInputElement = () => document.getElementById(AUTHOR_TAG_INPUT_ID) as HT
const viewExistingTags = toggleViews(TAG_LIST_CONTAINER_ID, TAG_INPUT_CONTAINER_ID);
const viewTagEditor = toggleViews(TAG_INPUT_CONTAINER_ID, TAG_LIST_CONTAINER_ID);

export {appendUI, insertTags, getInput, viewExistingTags, viewTagEditor, AUTHOR_TAG_INPUT_ID};
export {appendUI, renderAuthorTags, getInput, viewExistingTags, viewTagEditor, AUTHOR_TAG_INPUT_ID};
4 changes: 2 additions & 2 deletions src/ts/content/extensions/author/authorPage/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Author, {AuthorRecord} from "../../../adapters/author";
import {appendUI, getInput, insertTags, AUTHOR_TAG_INPUT_ID, viewExistingTags, viewTagEditor} from "./authorUI";
import {appendUI, getInput, renderAuthorTags, AUTHOR_TAG_INPUT_ID, viewExistingTags, viewTagEditor} from "./authorUI";
import {loaderOverlaid} from "../../../../common/ui/loadingIndicator";
import Book from "../../../adapters/book";
import {createPushBookTags, createSyncBookTags} from "../util/bookEditor";
Expand All @@ -18,7 +18,7 @@ const onEdit = () => {
const onBackToExistingTags = (getAuthor: () => Promise<AuthorRecord>) => () =>
loaderOverlaid(async () => {
const author = await getAuthor();
author && insertTags(author.tags);
author && renderAuthorTags(author.tags);
viewExistingTags();
});

Expand Down
6 changes: 3 additions & 3 deletions src/ts/content/extensions/author/authorPage/pull.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {createModal} from "../../../../common/ui/modal";
import {getInput, insertTags} from "./authorUI";
import {getInput, renderAuthorTags} from "./authorUI";
import {showToast, ToastType} from "../../../../common/ui/toast";
import {loaderOverlaid} from "../../../../common/ui/loadingIndicator";
import {authorTagsFromBooksWhere, getAuthorInfo} from "./util";
Expand Down Expand Up @@ -30,7 +30,7 @@ const uncertainTagModal =
kind: "button",
text: `Add${strings.all}`,
colour: UIColour.RED,
onClick: async () => insertTags([...certainTags, ...uncertainTags]),
onClick: async () => renderAuthorTags([...certainTags, ...uncertainTags]),
},
{kind: "button", text: "Back", colour: UIColour.BLUE},
],
Expand Down Expand Up @@ -63,7 +63,7 @@ const onPull = async () =>
const multiAuthorTags = authorTagsFromBooksWhere(books, (book) => book.authorIds.length !== 1);
const certainTags = new Set([...getInput(), ...(author?.tags ?? []), ...singleAuthorTags]);
const uncertainTags = new Set(multiAuthorTags.filter((tag) => !certainTags.has(tag)));
insertTags([...certainTags]);
renderAuthorTags([...certainTags]);
return {certainTags, uncertainTags, name};
}).then(finishPull);

Expand Down
4 changes: 2 additions & 2 deletions src/ts/content/extensions/author/authorPage/util.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Author from "../../../adapters/author";
import {insertTags} from "./authorUI";
import {renderAuthorTags} from "./authorUI";
import {filterAuthorTags} from "../../../util/filterAuthorTags";
import {BookRecord} from "../../../adapters/book";

Expand All @@ -11,7 +11,7 @@ const getAuthorInfo = () => {

const getTags = async () => {
const author = await Author.getAuthor(getAuthorInfo().uuid);
insertTags(author?.tags ?? []);
renderAuthorTags(author?.tags ?? []);
};

const authorTagsFromBooksWhere = (books: BookRecord[], where: (book: BookRecord) => boolean) =>
Expand Down

0 comments on commit 40d78cb

Please sign in to comment.