Skip to content

Commit 477c174

Browse files
authored
Inherit Extra Fields From Parent View (#414)
#414 * Inherit groupBy & entities from Parent View * Changeset added * Disable Live User Socket Connection * Await for chrome runtime response added in append note
1 parent 26c5aac commit 477c174

File tree

8 files changed

+57
-37
lines changed

8 files changed

+57
-37
lines changed

.changeset/proud-apples-do.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'mexit-webapp': patch
3+
---
4+
5+
Inherit Extra Fields From Parent View

apps/extension/src/Hooks/useSaveChanges.ts

+30-27
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {
1313
useAuthStore,
1414
useContentStore,
1515
useDataStore,
16+
useFloatingStore,
1617
useHighlightStore,
1718
useRecentsStore
1819
} from '@mexit/core'
@@ -48,6 +49,7 @@ export function useSaveChanges() {
4849
const setActiveItem = useSputlitStore((s) => s.setActiveItem)
4950
const ilinks = useDataStore((s) => s.ilinks)
5051
const sharedNodes = useDataStore((s) => s.sharedNodes)
52+
const setFloatingElement = useFloatingStore((store) => store.setFloatingElement)
5153

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

268-
if (error && notification) {
269-
toast.error('An Error Occured. Please try again.')
270-
} else {
271-
// mog('Response and things', { response })
272-
const bulkCreateRequest = request.subType === 'BULK_CREATE_NODES'
273-
const nodeid = !bulkCreateRequest ? message.id : message.node.id
274-
const content = message.content ?? request.body.content
275-
appendContent(node.nodeid, content)
276-
const title = !bulkCreateRequest ? message.title : message.node.title
277-
updateBlocks({
278-
id: node.nodeid,
279-
contents: content,
280-
title
281-
})
282-
283-
if (notification) {
284-
toast.success('Saved to Cloud')
285-
}
286-
287-
if (saveAndExit) {
288-
setVisualState(VisualState.animatingOut)
289-
// So that sputlit opens with preview true when it opens the next time
290-
setPreviewMode(true)
291-
}
269+
const { message, error } = response
270+
271+
if (error && notification) {
272+
toast.error('An Error Occured. Please try again.')
273+
} else {
274+
// mog('Response and things', { response })
275+
const bulkCreateRequest = request.subType === 'BULK_CREATE_NODES'
276+
const nodeid = !bulkCreateRequest ? message.id : message.node.id
277+
const content = message.content ?? request.body.content
278+
appendContent(node.nodeid, content)
279+
const title = !bulkCreateRequest ? message.title : message.node.title
280+
updateBlocks({
281+
id: node.nodeid,
282+
contents: content,
283+
title
284+
})
285+
286+
if (notification) {
287+
toast.success('Saved to Cloud')
292288
}
293-
})
289+
290+
if (saveAndExit) {
291+
setVisualState(VisualState.animatingOut)
292+
// So that sputlit opens with preview true when it opens the next time
293+
setPreviewMode(true)
294+
setFloatingElement(undefined)
295+
}
296+
}
294297
}
295298

296299
return {

apps/webapp/src/Components/Views/ViewRenderer/KanbanView.tsx

+12-1
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,14 @@ import {
2121
} from '@mexit/core'
2222
import {
2323
Count,
24+
Description,
2425
Group,
2526
GroupHeader,
2627
IconDisplay,
2728
OverlaySidebarWindowWidth,
2829
StyledTasksKanban,
29-
TaskColumnHeader
30+
TaskColumnHeader,
31+
TaskListWrapper
3032
} from '@mexit/shared'
3133

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

320+
if (!board?.columns?.length)
321+
return (
322+
<TaskListWrapper>
323+
<Description>
324+
Could not find any results for your search, please try again with different search terms.
325+
</Description>
326+
</TaskListWrapper>
327+
)
328+
318329
return (
319330
<StyledTasksKanban sidebarExpanded={sidebar.show && sidebar.expanded && !overlaySidebar}>
320331
{!!board && (

apps/webapp/src/Hooks/todo/useTodoFilters.tsx

-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@ export const useViewFilters = () => {
7676
}
7777

7878
const addCurrentFilter = (filter: Filter) => {
79-
mog('Change Current Filter: ', { s: currentFilters, f: filter })
8079
setCurrentFilters([...currentFilters, filter])
8180
}
8281

apps/webapp/src/Hooks/useCreateNewMenu.tsx

+3-1
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,9 @@ export const useCreateNewMenu = () => {
213213
viewType: view.viewType,
214214
sortOrder: view.sortOrder,
215215
sortType: view.sortType,
216-
globalJoin: view.globalJoin
216+
globalJoin: view.globalJoin,
217+
entities: view.entities,
218+
groupBy: view.groupBy
217219
}
218220
})
219221
}

apps/webapp/src/Hooks/useSocket.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ const useSocket = () => {
5858
queryParams: { userId, Authorizer: idToken },
5959
share: true
6060
},
61-
!!(idToken && userId)
61+
false // !!(idToken && userId)
6262
)
6363

6464
return utilFunctions

libs/shared/src/Components/AIPreview/index.tsx

+5-5
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,12 @@ const AIPreviewContainer: React.FC<AIPreviewProps> = (props) => {
5353
if (Array.isArray(deserializedContent) && deserializedContent.length > 0) {
5454
const at = replace ? editor?.selection : getPointAfter(editor, editor.selection)
5555

56-
insertNodes(editor, deserializedContent, {
57-
at
58-
})
59-
6056
try {
61-
focusEditor(editor)
57+
insertNodes(editor, deserializedContent, {
58+
at,
59+
select: true
60+
})
61+
focusEditor(editor, at)
6262
} catch (err) {
6363
console.error('Unable to focus editor', err)
6464
}

libs/shared/src/Components/AIPreview/styled.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ export const FloaterContainer = styled.div`
107107
backdrop-filter: blur(2rem);
108108
border: 1px solid ${({ theme }) => theme.tokens.surfaces.app};
109109
transform-origin: top;
110-
z-index: 10;
110+
z-index: 11;
111111
border: 1px solid ${({ theme }) => theme.tokens.surfaces.s[3]};
112112
animation: ${float} 150ms ease-out;
113113
`

0 commit comments

Comments
 (0)