Skip to content
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

Gist content not loaded on double click #8

Closed
SalomonBrys opened this issue Jan 11, 2022 · 2 comments
Closed

Gist content not loaded on double click #8

SalomonBrys opened this issue Jan 11, 2022 · 2 comments
Assignees
Labels

Comments

@SalomonBrys
Copy link

I have been using Code-Medium for a while (thanks for a great tool!).

Recently, modifying a gist stopped working properly.
When I double click an existing gist when editing my story, the code-medium interface appears but completely empty.
The "View on Github" button still works, though.

I get the following error:

Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'content')
    at App.js:2:2522360

The json object of the gist being retrieved:

{
    "url": "https://api.github.com/gists/b85b9abae5c2efea5835addfcb827f67",
    "forks_url": "https://api.github.com/gists/b85b9abae5c2efea5835addfcb827f67/forks",
    "commits_url": "https://api.github.com/gists/b85b9abae5c2efea5835addfcb827f67/commits",
    "id": "b85b9abae5c2efea5835addfcb827f67",
    "node_id": "G_kwDOAAPQAdoAIGI4NWI5YWJhZTVjMmVmZWE1ODM1YWRkZmNiODI3ZjY3",
    "git_pull_url": "https://gist.github.com/b85b9abae5c2efea5835addfcb827f67.git",
    "git_push_url": "https://gist.github.com/b85b9abae5c2efea5835addfcb827f67.git",
    "html_url": "https://gist.github.com/b85b9abae5c2efea5835addfcb827f67",
    "files": {
        "mocking-with-mockk.kt": {
            "filename": "mocking-with-mockk.kt",
            "type": "text/plain",
            "language": "Kotlin",
            "raw_url": "https://gist.githubusercontent.com/SalomonBrys/b85b9abae5c2efea5835addfcb827f67/raw/00c6dae9c142f190c1b7b846e6a43e3bf6ac883f/mocking-with-mockk.kt",
            "size": 128,
            "truncated": false,
            "content": "val repo = mockk<Repository>()\nevery { repo.getUser(id = any()) } returns fakeUser()\n\nassertEquals(fakeUser(), repo.getUser(42))"
        }
    },
    "public": false,
    "created_at": "2022-01-10T18:42:00Z",
    "updated_at": "2022-01-10T18:51:14Z",
    "description": "",
    "comments": 0,
    "user": null,
    "comments_url": "https://api.github.com/gists/b85b9abae5c2efea5835addfcb827f67/comments",
    "owner": {
        "login": "SalomonBrys",
        "id": 249857,
        "node_id": "MDQ6VXNlcjI0OTg1Nw==",
        "avatar_url": "https://avatars.githubusercontent.com/u/249857?v=4",
        "gravatar_id": "",
        "url": "https://api.github.com/users/SalomonBrys",
        "html_url": "https://github.com/SalomonBrys",
        "followers_url": "https://api.github.com/users/SalomonBrys/followers",
        "following_url": "https://api.github.com/users/SalomonBrys/following{/other_user}",
        "gists_url": "https://api.github.com/users/SalomonBrys/gists{/gist_id}",
        "starred_url": "https://api.github.com/users/SalomonBrys/starred{/owner}{/repo}",
        "subscriptions_url": "https://api.github.com/users/SalomonBrys/subscriptions",
        "organizations_url": "https://api.github.com/users/SalomonBrys/orgs",
        "repos_url": "https://api.github.com/users/SalomonBrys/repos",
        "events_url": "https://api.github.com/users/SalomonBrys/events{/privacy}",
        "received_events_url": "https://api.github.com/users/SalomonBrys/received_events",
        "type": "User",
        "site_admin": false
    },
    "forks": [],
    "history": [
        {
            "user": {
                "login": "SalomonBrys",
                "id": 249857,
                "node_id": "MDQ6VXNlcjI0OTg1Nw==",
                "avatar_url": "https://avatars.githubusercontent.com/u/249857?v=4",
                "gravatar_id": "",
                "url": "https://api.github.com/users/SalomonBrys",
                "html_url": "https://github.com/SalomonBrys",
                "followers_url": "https://api.github.com/users/SalomonBrys/followers",
                "following_url": "https://api.github.com/users/SalomonBrys/following{/other_user}",
                "gists_url": "https://api.github.com/users/SalomonBrys/gists{/gist_id}",
                "starred_url": "https://api.github.com/users/SalomonBrys/starred{/owner}{/repo}",
                "subscriptions_url": "https://api.github.com/users/SalomonBrys/subscriptions",
                "organizations_url": "https://api.github.com/users/SalomonBrys/orgs",
                "repos_url": "https://api.github.com/users/SalomonBrys/repos",
                "events_url": "https://api.github.com/users/SalomonBrys/events{/privacy}",
                "received_events_url": "https://api.github.com/users/SalomonBrys/received_events",
                "type": "User",
                "site_admin": false
            },
            "version": "bd383f0b464434ea01e90785fc24e420775da5d0",
            "committed_at": "2022-01-10T18:51:14Z",
            "change_status": {
                "total": 4,
                "additions": 3,
                "deletions": 1
            },
            "url": "https://api.github.com/gists/b85b9abae5c2efea5835addfcb827f67/bd383f0b464434ea01e90785fc24e420775da5d0"
        },
        {
            "user": {
                "login": "SalomonBrys",
                "id": 249857,
                "node_id": "MDQ6VXNlcjI0OTg1Nw==",
                "avatar_url": "https://avatars.githubusercontent.com/u/249857?v=4",
                "gravatar_id": "",
                "url": "https://api.github.com/users/SalomonBrys",
                "html_url": "https://github.com/SalomonBrys",
                "followers_url": "https://api.github.com/users/SalomonBrys/followers",
                "following_url": "https://api.github.com/users/SalomonBrys/following{/other_user}",
                "gists_url": "https://api.github.com/users/SalomonBrys/gists{/gist_id}",
                "starred_url": "https://api.github.com/users/SalomonBrys/starred{/owner}{/repo}",
                "subscriptions_url": "https://api.github.com/users/SalomonBrys/subscriptions",
                "organizations_url": "https://api.github.com/users/SalomonBrys/orgs",
                "repos_url": "https://api.github.com/users/SalomonBrys/repos",
                "events_url": "https://api.github.com/users/SalomonBrys/events{/privacy}",
                "received_events_url": "https://api.github.com/users/SalomonBrys/received_events",
                "type": "User",
                "site_admin": false
            },
            "version": "a032c65d2abe1a0d007192d396c2cf018c6a88bf",
            "committed_at": "2022-01-10T18:46:51Z",
            "change_status": {
                "total": 2,
                "additions": 1,
                "deletions": 1
            },
            "url": "https://api.github.com/gists/b85b9abae5c2efea5835addfcb827f67/a032c65d2abe1a0d007192d396c2cf018c6a88bf"
        },
        {
            "user": {
                "login": "SalomonBrys",
                "id": 249857,
                "node_id": "MDQ6VXNlcjI0OTg1Nw==",
                "avatar_url": "https://avatars.githubusercontent.com/u/249857?v=4",
                "gravatar_id": "",
                "url": "https://api.github.com/users/SalomonBrys",
                "html_url": "https://github.com/SalomonBrys",
                "followers_url": "https://api.github.com/users/SalomonBrys/followers",
                "following_url": "https://api.github.com/users/SalomonBrys/following{/other_user}",
                "gists_url": "https://api.github.com/users/SalomonBrys/gists{/gist_id}",
                "starred_url": "https://api.github.com/users/SalomonBrys/starred{/owner}{/repo}",
                "subscriptions_url": "https://api.github.com/users/SalomonBrys/subscriptions",
                "organizations_url": "https://api.github.com/users/SalomonBrys/orgs",
                "repos_url": "https://api.github.com/users/SalomonBrys/repos",
                "events_url": "https://api.github.com/users/SalomonBrys/events{/privacy}",
                "received_events_url": "https://api.github.com/users/SalomonBrys/received_events",
                "type": "User",
                "site_admin": false
            },
            "version": "de330dc4602a34cef88176cc8a37a5b4060e034a",
            "committed_at": "2022-01-10T18:42:00Z",
            "change_status": {
                "total": 2,
                "additions": 2,
                "deletions": 0
            },
            "url": "https://api.github.com/gists/b85b9abae5c2efea5835addfcb827f67/de330dc4602a34cef88176cc8a37a5b4060e034a"
        }
    ],
    "truncated": false
}
@Maluen
Copy link
Owner

Maluen commented Jan 11, 2022

The gist name detection was broken, it is extracted from the gist iframe, but it contained an extra trailing space, e.g. react.js instead of react.js, as a result, it failed when trying to access gist.files[gistName].content.

I've published v0.5.3 with the fix to both chrome and firefox store. We'll have to wait for review and approval, hopefully they don't take long.

Thanks for the detailed bug report!

@Maluen Maluen added the fixed label Jan 11, 2022
@SalomonBrys
Copy link
Author

Confirmed fixed in 0.5.3.
Thanks a lot :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants