Skip to content

Commit

Permalink
refactor: scope functions to userId
Browse files Browse the repository at this point in the history
  • Loading branch information
EnergoStalin committed Mar 18, 2024
1 parent 4e61a5f commit 51cc313
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
8 changes: 5 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ const addUserLinks: typeof unsafeWindow.vviewHooks.addUserLinks = ({
for (const link of [...extraLinks, ...getLinksFromDescription(extraLinks)]) {
switch (link.label) {
case "Fanbox":
fanbox(toBeChecked, userInfo)
fanbox(toBeChecked, userInfo.userId)
break
case "patreon.com":
patreon(link, toBeChecked, userInfo)
patreon(link, toBeChecked, userInfo.userId)
break
case "fantia.jp":
fantia(link, toBeChecked)
Expand All @@ -24,7 +24,9 @@ const addUserLinks: typeof unsafeWindow.vviewHooks.addUserLinks = ({
}
}

extraLinks.push(...disableDeadLinks(toBeChecked, userInfo))
const discoveredLinks = disableDeadLinks(toBeChecked, userInfo)

extraLinks.push(...discoveredLinks)
}

unsafeWindow.vviewHooks = {
Expand Down
4 changes: 2 additions & 2 deletions src/sites/fanbox.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export function fanbox(extraLinks: UserLink[], userInfo: User) {
export function fanbox(extraLinks: UserLink[], userId: number) {
extraLinks.push({
url: new URL(`https://kemono.su/fanbox/user/${userInfo.userId}`),
url: new URL(`https://kemono.su/fanbox/user/${userId}`),
icon: "mat:money_off",
type: "kemono_fanbox",
label: "Kemono fanbox",
Expand Down
4 changes: 2 additions & 2 deletions src/sites/parteon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const cachedPatreonUsers = {}
export function patreon(
link: UserLink,
extraLinks: UserLink[],
userInfo: User,
userId: number,
) {
normalizePatreonLink(link)
const url = link.url.toString()
Expand All @@ -30,7 +30,7 @@ export function patreon(
ripPatreonId(url)
.then((id) => {
cachedPatreonUsers[url] = id
notifyUserUpdated(userInfo.userId)
notifyUserUpdated(userId)
})
.catch(console.error)
} else {
Expand Down

0 comments on commit 51cc313

Please sign in to comment.