Skip to content

chore: typo on naming types, remove unnecessary plugin options #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion demo/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "demo",
"version": "0.0.2",
"version": "0.0.1",
"private": true,
"license": "MIT",
"dependencies": {
Expand Down
8 changes: 4 additions & 4 deletions demo/src/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import { graphql } from "gatsby"
import * as React from "react"

const DiscordUserListsItems = ({ userPlaylists }) => (
const DiscogsUserListsItems = ({ userPlaylists }) => (
<React.Fragment>
{userPlaylists.map((p) => {
if (!p.id) return null
Expand All @@ -26,7 +26,7 @@ const DiscordUserListsItems = ({ userPlaylists }) => (
</React.Fragment>
)

const DiscordUserLists = ({ userPlaylists }) => (
const DiscogsUserLists = ({ userPlaylists }) => (
<React.Fragment>
{userPlaylists.map((p) => {
if (!p.name) return null
Expand All @@ -49,7 +49,7 @@ const DiscordUserLists = ({ userPlaylists }) => (
<p>Resource URL: {p.resource_url}</p>
<p>Is public: {p.public === true ? `Yes` : `No`}</p>
<h3>Items</h3>
{p.items.length > 0 ? <DiscordUserListsItems userPlaylists={p.items} /> : <p>No items found</p>}
{p.items.length > 0 ? <DiscogsUserListsItems userPlaylists={p.items} /> : <p>No items found</p>}
</React.Fragment>
)
})}
Expand All @@ -65,7 +65,7 @@ const IndexPage = ({ data: { allDiscogsUserLists } }: { data: Queries.IndexPageQ
</p>
{allDiscogsUserLists.nodes &&
(allDiscogsUserLists.nodes.length > 0 ? (
<DiscordUserLists userPlaylists={allDiscogsUserLists.nodes} />
<DiscogsUserLists userPlaylists={allDiscogsUserLists.nodes} />
) : (
<p>No playlists found</p>
))}
Expand Down
2 changes: 1 addition & 1 deletion plugin/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ Your Discogs API token. Create an account on Discogs, go to [Settings > Develope

### username (**required**)

Your Discogs username.
The Discogs username to search.

**Field type**: `String`

Expand Down
13 changes: 0 additions & 13 deletions plugin/src/__tests__/plugin-options-schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ describe(`pluginOptionsSchema`, () => {
const options = {
api_token: undefined,
username: undefined,
endpoints: `test`,
}

const { isValid, errors } = await testPluginOptionsSchema(pluginOptionsSchema, options)
Expand All @@ -19,18 +18,6 @@ describe(`pluginOptionsSchema`, () => {
const options = {
api_token: undefined,
username: undefined,
endpoints: [
{
method: undefined,
args: `test`,
extension: {
method: undefined,
mapping: {
test: `test`,
},
},
},
],
}

const { isValid, errors } = await testPluginOptionsSchema(pluginOptionsSchema, options)
Expand Down
17 changes: 0 additions & 17 deletions plugin/src/constants.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,5 @@
export const DEFAULT_OPTIONS = {}

export const BASE_URL = `https://api.discogs.com/`

export const SIZES = {
sq: `sq_75px`,
q: `sq_150px`,
t: `_100px`,
s: `_240px`,
n: `_320px`,
m: `_500px`,
z: `_640px`,
c: `_800px`,
l: `_1024px`,
h: `_1600px`,
k: `_2048px`,
o: `original`,
}

export const NODE_TYPE_BASE = `Discogs`
export const NODE_SUBTYPE_USERLISTS = `UserLists`

Expand Down
4 changes: 2 additions & 2 deletions plugin/src/source-nodes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ export const sourceNodes: GatsbyNode["sourceNodes"] = async (gatsbyApi, pluginOp
auth = { userToken: api_token }
}
const user = new Discogs(auth).user()
const userLists = promisify(user.getLists)
const userGetListsPromisse = promisify(user.getLists)

let userListsRes

try {
userListsRes = await userLists(username)
userListsRes = await userGetListsPromisse(username)
} catch (error) {
gatsbyApi.reporter.panicOnBuild({
id: ERROR_CODES.createDiscogsUser,
Expand Down
Loading