Skip to content

Commit

Permalink
Merge pull request #45 from mysilio-co/create-public-note
Browse files Browse the repository at this point in the history
fix public note creation
  • Loading branch information
travis authored Oct 20, 2021
2 parents 0e7ddfa + 7e979ae commit a2f5480
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 3 deletions.
6 changes: 3 additions & 3 deletions components/modals/NewNote.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const TabId = {

export const NewNote = ({ setOpen, isPublic = false }) => {
const [pub, setPublic] = useState(isPublic)
const privacy = pub ? 'public' : 'private'
const [value, setNoteValue] = useState(EmptySlateJSON);

const tabs = [TabId.Concept, TabId.Bookmark];
Expand All @@ -35,17 +36,16 @@ export const NewNote = ({ setOpen, isPublic = false }) => {
const { setValue, resetEditor } = usePlateActions(editorId);

const webId = useWebId();
const { workspace, slug: workspaceSlug } = useCurrentWorkspace();
const { workspace, slug: workspaceSlug } = useCurrentWorkspace(privacy);
const [name, setName] = useState("");

const {
concept,
index: conceptIndex,
saveIndex: saveConceptIndex,
} = useConcept(webId, workspaceSlug, name, pub ? 'public' : 'private');
} = useConcept(webId, workspaceSlug, name, privacy);
const conceptNames = useConceptNames(webId)
const conceptExists = concept && !isThingLocal(concept);

const save = async function save() {
const newNote = createOrUpdateSlateJSON(value);
const newConceptIndex = createOrUpdateConceptIndex(
Expand Down
9 changes: 9 additions & 0 deletions hooks/concepts.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,15 @@ export function useConcept(
saveIndex: savePrivateIndex,
privacy: 'private'
};
} else if (thisConcept) {
// this means there's no public or private concept but we did successfully create a new one
return {
conceptUri,
concept,
index: (newConceptPrivacy == 'private') ? privateIndex : publicIndex,
saveIndex: (newConceptPrivacy == 'private') ? savePrivateIndex : savePublicIndex,
privacy: 'newConceptPrivacy'
}
} else if (privateIndex && publicIndex) {
return {
conceptUri,
Expand Down
16 changes: 16 additions & 0 deletions pages/logout.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { useEffect } from 'react'
import { useRouter } from 'next/router'
import { useAuthentication } from 'swrlit'

import { Loader } from '../components/elements'

export default function LogoutPage() {
const { logout } = useAuthentication()
const router = useRouter()

useEffect(function () {
logout()
router.push('/')
}, [])
return <Loader />
}

1 comment on commit a2f5480

@vercel
Copy link

@vercel vercel bot commented on a2f5480 Oct 20, 2021

Choose a reason for hiding this comment

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

Successfully deployed to the following URLs:

Please sign in to comment.