Skip to content
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ const PropConditionValueControl = ({
const fetchProperties = useCallback(
async (body: ListPropertySuggestionsRequestBody) => {
const res = await fetchPropertySuggestionsApi(body)
if (!res.err) {
if (res != null && !res.err) {
setSuggestions(
(res.data as ListPropertySuggestionsResponseBody).data
.filter((property) => property.type === body.propertyType)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const CreateSmartViewModal = ({ onCreate }: CreateSmartViewModalProps) => {
setSending(true)
const res = await createSmartViewApi(team.id, body)

if (!res.err) {
if (res != null && !res.err) {
const { data: smartView } = res.data as CreateSmartViewResponseBody
closeModal()
if (onCreate != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const UpdateSmartViewModal = ({

const res = await updateSmartViewApi(smartView, body)

if (!res.err) {
if (res != null && !res.err) {
closeModal()
if (onUpdate != null) {
return onUpdate((res.data as UpdateSmartViewResponseBody).data)
Expand Down
2 changes: 1 addition & 1 deletion src/cloud/components/Props/PropPicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const PropPicker = ({
})
}

if (!res.err && onUpdate != null) {
if (res != null && !res.err && onUpdate != null) {
const props = res.data as {
data: Props
}
Expand Down
2 changes: 1 addition & 1 deletion src/cloud/components/Props/PropSelectorModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const PropSelectorModal = ({
team: doc.teamId,
doc: doc.id,
})
if (!res.err) {
if (res != null && !res.err) {
return (res.data as ListPropertySuggestionsResponseBody).data
} else {
return []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ const CalendarWatchedPropContext = ({
}

const res = await fetchPropertySuggestionsApi(body)
if (!res.err) {
if (res != null && !res.err) {
setSuggestions(
filterIter(
(val) => isPropType(val.type),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ const KanbanWatchedPropSetter = ({
}

const res = await fetchPropertySuggestionsApi(body)
if (!res.err) {
if (res != null && !res.err) {
setSuggestions(
filterIter(
(val) => isPropType(val.type),
Expand Down
4 changes: 2 additions & 2 deletions src/cloud/components/Views/Table/TableAddPropertyContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ interface TableAddPropertyContextProps {
view: SerializedView
teamId: string
columns: Record<string, Column>
addColumn: (col: Column) => Promise<BulkApiActionRes> | undefined
addColumn: (col: Column) => Promise<BulkApiActionRes | undefined> | undefined
close: () => void
}

Expand Down Expand Up @@ -55,7 +55,7 @@ const TableAddPropertyContext = ({
}

const res = await fetchPropertySuggestionsApi(body)
if (!res.err) {
if (res != null && !res.err) {
return (res.data as ListPropertySuggestionsResponseBody).data
} else {
return []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const TablePropertiesContext = ({

setSending(`${col.id}-delete`)
const res = await tableActionsRef.current.removeColumn(col)
if (!res.err) {
if (res != null && !res.err) {
setActiveColumns((prev) => {
return prev.slice().filter((elem) => elem.id !== col.id)
})
Expand Down
6 changes: 3 additions & 3 deletions src/cloud/components/Views/ViewsSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ const ViewContextModal = ({
const deleteView = useCallback(
async (view: SerializedView) => {
const res = await actionsRef.current.deleteView(view)
if (!res.err) {
if (res != null && !res.err) {
closeLastModal()
}
},
Expand All @@ -206,7 +206,7 @@ const ViewContextModal = ({
setSending(move)
const res = await actionsRef.current.moveView(view, move)
setSending(undefined)
if (!res.err) {
if (res != null && !res.err) {
closeLastModal()
}
},
Expand All @@ -218,7 +218,7 @@ const ViewContextModal = ({
setSending('name')
const res = await actionsRef.current.updateView(view, { name: newName })
setSending(undefined)
if (!res.err) {
if (res != null && !res.err) {
closeLastModal()
}
},
Expand Down
12 changes: 7 additions & 5 deletions src/cloud/lib/hooks/views/tableView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,15 @@ interface TableViewStoreProps {
}

export type TableViewActionsRef = React.MutableRefObject<{
updateTableSort: (sort: ViewTableSortingOptions) => Promise<BulkApiActionRes>
addColumn: (col: Column) => Promise<BulkApiActionRes> | undefined
removeColumn: (col: Column) => Promise<BulkApiActionRes>
updateTableSort: (
sort: ViewTableSortingOptions
) => Promise<BulkApiActionRes | undefined>
addColumn: (col: Column) => Promise<BulkApiActionRes | undefined> | undefined
removeColumn: (col: Column) => Promise<BulkApiActionRes | undefined>
moveColumn: (
column: Column,
move: ColumnMoveType
) => Promise<BulkApiActionRes> | undefined
) => Promise<BulkApiActionRes | undefined> | undefined
}>

export function useTableView({
Expand All @@ -55,7 +57,7 @@ export function useTableView({
{ data: newState }
)
)
if (!res.err) {
if (res != null && !res.err) {
selectNewView((res.data as CreateViewResponseBody).data.id)
}
return res
Expand Down
14 changes: 8 additions & 6 deletions src/cloud/lib/hooks/views/viewHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,18 @@ interface ViewHandlerStoreProps {
}

export type ViewHandlerActionsRef = React.MutableRefObject<{
createNewView: (type: SupportedViewTypes) => Promise<BulkApiActionRes>
createNewView: (
type: SupportedViewTypes
) => Promise<BulkApiActionRes | undefined>
updateView: (
view: SerializedView,
body: Omit<UpdateViewRequestBody, 'move'>
) => Promise<BulkApiActionRes>
deleteView: (view: SerializedView) => Promise<BulkApiActionRes>
) => Promise<BulkApiActionRes | undefined>
deleteView: (view: SerializedView) => Promise<BulkApiActionRes | undefined>
moveView: (
view: SerializedView,
move: ViewMoveType
) => Promise<BulkApiActionRes>
) => Promise<BulkApiActionRes | undefined>
}>

export function useViewHandler({
Expand Down Expand Up @@ -89,7 +91,7 @@ export function useViewHandler({
? { workspace: parent.target.id, type, name }
: { smartView: parent.target.id, type, name }
)
if (!res.err) {
if (res != null && !res.err) {
const view = (res.data as CreateViewResponseBody).data
trackEvent(MixpanelActionTrackTypes.ViewCreate, {
trueEventName: `view.${view.type}.create`,
Expand All @@ -105,7 +107,7 @@ export function useViewHandler({
const deleteView = useCallback(
async (view: SerializedView) => {
const res = await deleteViewApi(view)
if (!res.err) {
if (res != null && !res.err) {
trackEvent(MixpanelActionTrackTypes.ViewDelete, {
trueEventName: `view.${view.type}.delete`,
view: view.id,
Expand Down
2 changes: 1 addition & 1 deletion src/design/lib/hooks/useBulkApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export type BulkApiAction = (
id: string,
act: string,
body: { api: (args: any) => Promise<any>; cb?: (res: any) => any }
) => Promise<BulkApiActionRes>
) => Promise<BulkApiActionRes | undefined>

interface UseBulkApiRes {
sendingMap: Map<string, string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const SmartViewUpdateModal = ({

const res = await updateSmartViewApi(smartView, body)

if (!res.err) {
if (res != null && !res.err) {
closeModal()
if (onUpdate != null) {
return onUpdate((res.data as UpdateSmartViewResponseBody).data)
Expand Down