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

Inherit Extra Fields From Parent View #414

Merged
merged 4 commits into from
Apr 19, 2023
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
5 changes: 5 additions & 0 deletions .changeset/proud-apples-do.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'mexit-webapp': patch
---

Inherit Extra Fields From Parent View
57 changes: 30 additions & 27 deletions apps/extension/src/Hooks/useSaveChanges.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
useAuthStore,
useContentStore,
useDataStore,
useFloatingStore,
useHighlightStore,
useRecentsStore
} from '@mexit/core'
Expand Down Expand Up @@ -48,6 +49,7 @@ export function useSaveChanges() {
const setActiveItem = useSputlitStore((s) => s.setActiveItem)
const ilinks = useDataStore((s) => s.ilinks)
const sharedNodes = useDataStore((s) => s.sharedNodes)
const setFloatingElement = useFloatingStore((store) => store.setFloatingElement)

const setContent = useContentStore((s) => s.setContent)
const appendContent = useContentStore((s) => s.appendContent)
Expand Down Expand Up @@ -262,35 +264,36 @@ export function useSaveChanges() {
setActiveItem()
// mog('Request and things', { request, node, nodeContent, content })
// TODO: Merge this with the savit request call. DRY
chrome.runtime.sendMessage(request, (response) => {
const { message, error } = response
const response = await chrome.runtime.sendMessage(request)

if (error && notification) {
toast.error('An Error Occured. Please try again.')
} else {
// mog('Response and things', { response })
const bulkCreateRequest = request.subType === 'BULK_CREATE_NODES'
const nodeid = !bulkCreateRequest ? message.id : message.node.id
const content = message.content ?? request.body.content
appendContent(node.nodeid, content)
const title = !bulkCreateRequest ? message.title : message.node.title
updateBlocks({
id: node.nodeid,
contents: content,
title
})

if (notification) {
toast.success('Saved to Cloud')
}

if (saveAndExit) {
setVisualState(VisualState.animatingOut)
// So that sputlit opens with preview true when it opens the next time
setPreviewMode(true)
}
const { message, error } = response

if (error && notification) {
toast.error('An Error Occured. Please try again.')
} else {
// mog('Response and things', { response })
const bulkCreateRequest = request.subType === 'BULK_CREATE_NODES'
const nodeid = !bulkCreateRequest ? message.id : message.node.id
const content = message.content ?? request.body.content
appendContent(node.nodeid, content)
const title = !bulkCreateRequest ? message.title : message.node.title
updateBlocks({
id: node.nodeid,
contents: content,
title
})

if (notification) {
toast.success('Saved to Cloud')
}
})

if (saveAndExit) {
setVisualState(VisualState.animatingOut)
// So that sputlit opens with preview true when it opens the next time
setPreviewMode(true)
setFloatingElement(undefined)
}
}
}

return {
Expand Down
13 changes: 12 additions & 1 deletion apps/webapp/src/Components/Views/ViewRenderer/KanbanView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,14 @@ import {
} from '@mexit/core'
import {
Count,
Description,
Group,
GroupHeader,
IconDisplay,
OverlaySidebarWindowWidth,
StyledTasksKanban,
TaskColumnHeader
TaskColumnHeader,
TaskListWrapper
} from '@mexit/shared'

import { useViewFilterStore } from '../../../Hooks/todo/useTodoFilters'
Expand Down Expand Up @@ -315,6 +317,15 @@ const KanbanView: React.FC<any> = (props) => {
)
}

if (!board?.columns?.length)
return (
<TaskListWrapper>
<Description>
Could not find any results for your search, please try again with different search terms.
</Description>
</TaskListWrapper>
)

return (
<StyledTasksKanban sidebarExpanded={sidebar.show && sidebar.expanded && !overlaySidebar}>
{!!board && (
Expand Down
1 change: 0 additions & 1 deletion apps/webapp/src/Hooks/todo/useTodoFilters.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ export const useViewFilters = () => {
}

const addCurrentFilter = (filter: Filter) => {
mog('Change Current Filter: ', { s: currentFilters, f: filter })
setCurrentFilters([...currentFilters, filter])
}

Expand Down
4 changes: 3 additions & 1 deletion apps/webapp/src/Hooks/useCreateNewMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,9 @@ export const useCreateNewMenu = () => {
viewType: view.viewType,
sortOrder: view.sortOrder,
sortType: view.sortType,
globalJoin: view.globalJoin
globalJoin: view.globalJoin,
entities: view.entities,
groupBy: view.groupBy
}
})
}
Expand Down
2 changes: 1 addition & 1 deletion apps/webapp/src/Hooks/useSocket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ const useSocket = () => {
queryParams: { userId, Authorizer: idToken },
share: true
},
!!(idToken && userId)
false // !!(idToken && userId)
)

return utilFunctions
Expand Down
10 changes: 5 additions & 5 deletions libs/shared/src/Components/AIPreview/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,12 @@ const AIPreviewContainer: React.FC<AIPreviewProps> = (props) => {
if (Array.isArray(deserializedContent) && deserializedContent.length > 0) {
const at = replace ? editor?.selection : getPointAfter(editor, editor.selection)

insertNodes(editor, deserializedContent, {
at
})

try {
focusEditor(editor)
insertNodes(editor, deserializedContent, {
at,
select: true
})
focusEditor(editor, at)
} catch (err) {
console.error('Unable to focus editor', err)
}
Expand Down
2 changes: 1 addition & 1 deletion libs/shared/src/Components/AIPreview/styled.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ export const FloaterContainer = styled.div`
backdrop-filter: blur(2rem);
border: 1px solid ${({ theme }) => theme.tokens.surfaces.app};
transform-origin: top;
z-index: 10;
z-index: 11;
border: 1px solid ${({ theme }) => theme.tokens.surfaces.s[3]};
animation: ${float} 150ms ease-out;
`
Expand Down