Skip to content

Commit

Permalink
fix cannot create new notes (#14)
Browse files Browse the repository at this point in the history
  • Loading branch information
shuding authored Feb 22, 2022
1 parent f76ca7c commit f7afd46
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 10 deletions.
12 changes: 3 additions & 9 deletions components/EditorPage.server.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,17 @@ export default function EditNote({ login, router, searchText }) {

let note =
selectedId != null
? useData(apiKey, url =>
fetch(url).then(res => res.json())
)
? useData(apiKey, url => fetch(url).then(res => res.json()))
: defaultNote

note = note || defaultNote

const isCreator = note.created_by === login
const isCreator = !selectedId || note.created_by === login

return (
<Page login={login} searchText={searchText}>
<Suspense fallback={<NoteSkeleton isEditing={isCreator} />}>
<NoteUI
note={note}
isEditing={isCreator}
selectedId={selectedId}
/>
<NoteUI note={note} isEditing={isCreator} selectedId={selectedId} />
</Suspense>
</Page>
)
Expand Down
2 changes: 1 addition & 1 deletion components/NoteUI.server.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import AuthButton from './AuthButton.server'

export default function NoteUI({ note, isEditing, login }) {
const { id, title, body, updated_at, created_by: createdBy } = note
const updatedAt = new Date(updated_at)
const updatedAt = new Date(updated_at || 0)

if (isEditing) {
return <NoteEditor noteId={id} initialTitle={title} initialBody={body} />
Expand Down

1 comment on commit f7afd46

@vercel
Copy link

@vercel vercel bot commented on f7afd46 Feb 22, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.