Skip to content

Commit

Permalink
bugfix 修復 gist
Browse files Browse the repository at this point in the history
  • Loading branch information
hys committed Mar 18, 2018
1 parent c782043 commit 6337564
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/component/comments/src/gitment.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,9 @@ export default class Gitment {

loadMeta() {
const { id, owner, repo, gistId, type = 'issues' } = this
if (type === 'gist') {
if (type === 'gists') {
return http
.get(`/repos/${owner}/${repo}/${type}/${gistId}`, {
.get(`/${type}/${gistId}`, {
creator: owner,
})
.then(issue => {
Expand Down
9 changes: 5 additions & 4 deletions src/component/comments/src/theme/default.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
} from '../icons'
import { NOT_INITIALIZED_ERROR } from '../constants'

function renderHeader({ meta, user, reactions }, instance) {
function renderHeader({ meta, user, reactions = {} }, instance) {
const container = document.createElement('div')
container.lang = 'en-US'
container.className = 'gitment-container gitment-header-container'
Expand Down Expand Up @@ -52,7 +52,7 @@ function renderHeader({ meta, user, reactions }, instance) {
}

function renderComments(
{ meta, comments, commentReactions, currentPage, user, error },
{ meta, comments, commentReactions = {}, currentPage, user, error },
instance
) {
const container = document.createElement('div')
Expand Down Expand Up @@ -110,8 +110,9 @@ function renderComments(
? ` • <span title="comment was edited at ${updateDate}">edited</span>`
: ''
}
<div class="gitment-comment-like-btn">${heartIcon} ${comment.reactions
.heart || ''}</div>
<div class="gitment-comment-like-btn">${heartIcon} ${(comment.reactions &&
comment.reactions.heart) ||
''}</div>
</div>
<div class="gitment-comment-body gitment-markdown">${
comment.body_html
Expand Down
2 changes: 1 addition & 1 deletion src/pages/gist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ class Gist extends Component {

<hr className="hr" />

<Comments type="gist" gistId={this.props.match.params.id} />
<Comments type="gists" gistId={this.props.match.params.id} />
</div>
</Spin>
</DocumentTitle>
Expand Down

0 comments on commit 6337564

Please sign in to comment.