TWNTY-3794 - ESLint rule: only take explicit boolean predicates in if statements (#4354)
* ESLint rule: only take explicit boolean predicates in if statements Co-authored-by: v1b3m <vibenjamin6@gmail.com> Co-authored-by: Toledodev <rafael.toledo@engenharia.ufjf.br> * Merge main Co-authored-by: v1b3m <vibenjamin6@gmail.com> Co-authored-by: Toledodev <rafael.toledo@engenharia.ufjf.br> * Fix frontend linter errors Co-authored-by: v1b3m <vibenjamin6@gmail.com> Co-authored-by: Toledodev <rafael.toledo@engenharia.ufjf.br> * Fix jest Co-authored-by: v1b3m <vibenjamin6@gmail.com> Co-authored-by: Toledodev <rafael.toledo@engenharia.ufjf.br> * Refactor according to review Co-authored-by: v1b3m <vibenjamin6@gmail.com> Co-authored-by: Toledodev <rafael.toledo@engenharia.ufjf.br> * Refactor according to review Co-authored-by: v1b3m <vibenjamin6@gmail.com> Co-authored-by: Toledodev <rafael.toledo@engenharia.ufjf.br> * Fix lint on new code Co-authored-by: v1b3m <vibenjamin6@gmail.com> Co-authored-by: Toledodev <rafael.toledo@engenharia.ufjf.br> --------- Co-authored-by: gitstart-twenty <gitstart-twenty@users.noreply.github.com> Co-authored-by: v1b3m <vibenjamin6@gmail.com> Co-authored-by: Toledodev <rafael.toledo@engenharia.ufjf.br>
This commit is contained in:
committed by
GitHub
parent
40bea0d95e
commit
17511be0cf
@ -8,9 +8,12 @@ import {
|
||||
} from '@blocknote/core';
|
||||
import { createReactBlockSpec } from '@blocknote/react';
|
||||
import styled from '@emotion/styled';
|
||||
import { isNonEmptyString } from '@sniptt/guards';
|
||||
|
||||
import { Button } from '@/ui/input/button/components/Button';
|
||||
import { AppThemeProvider } from '@/ui/theme/components/AppThemeProvider';
|
||||
import { isNonNullable } from '~/utils/isNonNullable';
|
||||
import { isNullable } from '~/utils/isNullable';
|
||||
|
||||
import { AttachmentIcon } from '../files/components/AttachmentIcon';
|
||||
import { AttachmentType } from '../files/types/Attachment';
|
||||
@ -77,7 +80,7 @@ const FileBlockRenderer = ({
|
||||
const inputFileRef = useRef<HTMLInputElement>(null);
|
||||
|
||||
const handleUploadAttachment = async (file: File) => {
|
||||
if (!file) {
|
||||
if (isNullable(file)) {
|
||||
return '';
|
||||
}
|
||||
const fileUrl = await editor.uploadFile?.(file);
|
||||
@ -93,10 +96,11 @@ const FileBlockRenderer = ({
|
||||
inputFileRef?.current?.click?.();
|
||||
};
|
||||
const handleFileChange = (e: ChangeEvent<HTMLInputElement>) => {
|
||||
if (e.target.files) handleUploadAttachment?.(e.target.files[0]);
|
||||
if (isNonNullable(e.target.files))
|
||||
handleUploadAttachment?.(e.target.files[0]);
|
||||
};
|
||||
|
||||
if (block.props.url) {
|
||||
if (isNonEmptyString(block.props.url)) {
|
||||
return (
|
||||
<AppThemeProvider>
|
||||
<StyledFileLine>
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
import { CalendarEvent } from '@/activities/calendar/types/CalendarEvent';
|
||||
import { isNonNullable } from '~/utils/isNonNullable';
|
||||
import { sortAsc } from '~/utils/sort';
|
||||
|
||||
export const sortCalendarEventsAsc = (
|
||||
@ -10,7 +11,11 @@ export const sortCalendarEventsAsc = (
|
||||
calendarEventB.startsAt.getTime(),
|
||||
);
|
||||
|
||||
if (startsAtSort === 0 && calendarEventA.endsAt && calendarEventB.endsAt) {
|
||||
if (
|
||||
startsAtSort === 0 &&
|
||||
isNonNullable(calendarEventA.endsAt) &&
|
||||
isNonNullable(calendarEventB.endsAt)
|
||||
) {
|
||||
return sortAsc(
|
||||
calendarEventA.endsAt.getTime(),
|
||||
calendarEventB.endsAt.getTime(),
|
||||
|
||||
@ -25,6 +25,8 @@ import { useScopedHotkeys } from '@/ui/utilities/hotkey/hooks/useScopedHotkeys';
|
||||
import { isNonTextWritingKey } from '@/ui/utilities/hotkey/utils/isNonTextWritingKey';
|
||||
import { REACT_APP_SERVER_BASE_URL } from '~/config';
|
||||
import { FileFolder, useUploadFileMutation } from '~/generated/graphql';
|
||||
import { isNonNullable } from '~/utils/isNonNullable';
|
||||
import { isNullable } from '~/utils/isNullable';
|
||||
|
||||
import { blockSpecs } from '../blocks/blockSpecs';
|
||||
import { getSlashMenu } from '../blocks/slashMenu';
|
||||
@ -78,7 +80,7 @@ export const ActivityBodyEditor = ({
|
||||
const { upsertActivity } = useUpsertActivity();
|
||||
|
||||
const persistBodyDebounced = useDebouncedCallback((newBody: string) => {
|
||||
if (activity) {
|
||||
if (isNonNullable(activity)) {
|
||||
upsertActivity({
|
||||
activity,
|
||||
input: {
|
||||
@ -90,7 +92,7 @@ export const ActivityBodyEditor = ({
|
||||
|
||||
const persistTitleAndBodyDebounced = useDebouncedCallback(
|
||||
(newTitle: string, newBody: string) => {
|
||||
if (activity) {
|
||||
if (isNonNullable(activity)) {
|
||||
upsertActivity({
|
||||
activity,
|
||||
input: {
|
||||
@ -124,7 +126,7 @@ export const ActivityBodyEditor = ({
|
||||
const [uploadFile] = useUploadFileMutation();
|
||||
|
||||
const handleUploadAttachment = async (file: File): Promise<string> => {
|
||||
if (!file) {
|
||||
if (isNullable(file)) {
|
||||
return '';
|
||||
}
|
||||
const result = await uploadFile({
|
||||
@ -226,7 +228,7 @@ export const ActivityBodyEditor = ({
|
||||
if (isNonEmptyString(activityBody) && activityBody !== '{}') {
|
||||
return JSON.parse(activityBody);
|
||||
} else if (
|
||||
activity &&
|
||||
isNonNullable(activity) &&
|
||||
isNonEmptyString(activity.body) &&
|
||||
activity?.body !== '{}'
|
||||
) {
|
||||
@ -251,7 +253,7 @@ export const ActivityBodyEditor = ({
|
||||
const handleImagePaste = async (event: ClipboardEvent) => {
|
||||
const clipboardItems = event.clipboardData?.items;
|
||||
|
||||
if (clipboardItems) {
|
||||
if (isNonNullable(clipboardItems)) {
|
||||
for (let i = 0; i < clipboardItems.length; i++) {
|
||||
if (clipboardItems[i].kind === 'file') {
|
||||
const isImage = clipboardItems[i].type.match('^image/');
|
||||
@ -266,7 +268,7 @@ export const ActivityBodyEditor = ({
|
||||
return;
|
||||
}
|
||||
|
||||
if (isImage) {
|
||||
if (isNonNullable(isImage)) {
|
||||
editor?.insertBlocks(
|
||||
[
|
||||
{
|
||||
@ -332,7 +334,7 @@ export const ActivityBodyEditor = ({
|
||||
const currentBlockContent = blockIdentifier?.content;
|
||||
|
||||
if (
|
||||
currentBlockContent &&
|
||||
isNonNullable(currentBlockContent) &&
|
||||
isArray(currentBlockContent) &&
|
||||
currentBlockContent.length === 0
|
||||
) {
|
||||
@ -344,7 +346,7 @@ export const ActivityBodyEditor = ({
|
||||
}
|
||||
|
||||
if (
|
||||
currentBlockContent &&
|
||||
isNonNullable(currentBlockContent) &&
|
||||
isArray(currentBlockContent) &&
|
||||
currentBlockContent[0] &&
|
||||
currentBlockContent[0].type === 'text'
|
||||
|
||||
@ -3,6 +3,7 @@ import { useRecoilState } from 'recoil';
|
||||
|
||||
import { activityBodyFamilyState } from '@/activities/states/activityBodyFamilyState';
|
||||
import { recordStoreFamilyState } from '@/object-record/record-store/states/recordStoreFamilyState';
|
||||
import { isNonNullable } from '~/utils/isNonNullable';
|
||||
|
||||
export const ActivityBodyEffect = ({ activityId }: { activityId: string }) => {
|
||||
const [activityFromStore] = useRecoilState(
|
||||
@ -16,7 +17,7 @@ export const ActivityBodyEffect = ({ activityId }: { activityId: string }) => {
|
||||
useEffect(() => {
|
||||
if (
|
||||
activityBody === '' &&
|
||||
activityFromStore &&
|
||||
isNonNullable(activityFromStore) &&
|
||||
activityBody !== activityFromStore.body
|
||||
) {
|
||||
setActivityBody(activityFromStore.body);
|
||||
|
||||
@ -11,6 +11,7 @@ import { Activity } from '@/activities/types/Activity';
|
||||
import { recordStoreFamilyState } from '@/object-record/record-store/states/recordStoreFamilyState';
|
||||
import { RIGHT_DRAWER_CLICK_OUTSIDE_LISTENER_ID } from '@/ui/layout/right-drawer/constants/RightDrawerClickOutsideListener';
|
||||
import { useClickOutsideListener } from '@/ui/utilities/pointer-event/hooks/useClickOutsideListener';
|
||||
import { isNonNullable } from '~/utils/isNonNullable';
|
||||
|
||||
export const ActivityEditorEffect = ({
|
||||
activityId,
|
||||
@ -57,7 +58,7 @@ export const ActivityEditorEffect = ({
|
||||
return;
|
||||
}
|
||||
|
||||
if (isActivityInCreateMode && activity) {
|
||||
if (isActivityInCreateMode && isNonNullable(activity)) {
|
||||
if (canCreateActivity) {
|
||||
upsertActivity({
|
||||
activity,
|
||||
@ -71,7 +72,7 @@ export const ActivityEditorEffect = ({
|
||||
}
|
||||
|
||||
set(isActivityInCreateModeState, false);
|
||||
} else if (activity) {
|
||||
} else if (isNonNullable(activity)) {
|
||||
if (
|
||||
activity.title !== activityTitle ||
|
||||
activity.body !== activityBody
|
||||
|
||||
@ -13,6 +13,7 @@ import {
|
||||
import { RecordInlineCell } from '@/object-record/record-inline-cell/components/RecordInlineCell';
|
||||
import { PropertyBox } from '@/object-record/record-inline-cell/property-box/components/PropertyBox';
|
||||
import { recordStoreFamilyState } from '@/object-record/record-store/states/recordStoreFamilyState';
|
||||
import { isNonNullable } from '~/utils/isNonNullable';
|
||||
|
||||
const StyledPropertyBox = styled(PropertyBox)`
|
||||
padding: 0;
|
||||
@ -35,7 +36,7 @@ export const ActivityEditorFields = ({
|
||||
const upsertActivityMutation = async ({
|
||||
variables,
|
||||
}: RecordUpdateHookParams) => {
|
||||
if (activityFromStore) {
|
||||
if (isNonNullable(activityFromStore)) {
|
||||
await upsertActivity({
|
||||
activity: activityFromStore as Activity,
|
||||
input: variables.updateOneRecordInput,
|
||||
|
||||
@ -3,6 +3,7 @@ import { useRecoilState } from 'recoil';
|
||||
|
||||
import { activityTitleFamilyState } from '@/activities/states/activityTitleFamilyState';
|
||||
import { recordStoreFamilyState } from '@/object-record/record-store/states/recordStoreFamilyState';
|
||||
import { isNonNullable } from '~/utils/isNonNullable';
|
||||
|
||||
export const ActivityTitleEffect = ({ activityId }: { activityId: string }) => {
|
||||
const [activityFromStore] = useRecoilState(
|
||||
@ -16,7 +17,7 @@ export const ActivityTitleEffect = ({ activityId }: { activityId: string }) => {
|
||||
useEffect(() => {
|
||||
if (
|
||||
activityTitle === '' &&
|
||||
activityFromStore &&
|
||||
isNonNullable(activityFromStore) &&
|
||||
activityTitle !== activityFromStore.title
|
||||
) {
|
||||
setActivityTitle(activityFromStore.title);
|
||||
|
||||
@ -33,6 +33,7 @@ import {
|
||||
TimelineThread,
|
||||
TimelineThreadsWithTotal,
|
||||
} from '~/generated/graphql';
|
||||
import { isNonNullable } from '~/utils/isNonNullable';
|
||||
|
||||
const StyledContainer = styled.div`
|
||||
display: flex;
|
||||
@ -140,7 +141,7 @@ export const EmailThreads = ({
|
||||
}
|
||||
};
|
||||
|
||||
if (error) {
|
||||
if (isNonNullable(error)) {
|
||||
enqueueSnackBar(error.message || 'Error loading email threads', {
|
||||
variant: 'error',
|
||||
});
|
||||
|
||||
@ -1,4 +1,7 @@
|
||||
import { isNonEmptyString } from '@sniptt/guards';
|
||||
|
||||
import { EmailThreadMessageParticipant } from '@/activities/emails/types/EmailThreadMessageParticipant';
|
||||
import { isNonNullable } from '~/utils/isNonNullable';
|
||||
|
||||
export const getDisplayNameFromParticipant = ({
|
||||
participant,
|
||||
@ -7,14 +10,14 @@ export const getDisplayNameFromParticipant = ({
|
||||
participant: EmailThreadMessageParticipant;
|
||||
shouldUseFullName?: boolean;
|
||||
}) => {
|
||||
if (participant.person) {
|
||||
if (isNonNullable(participant.person)) {
|
||||
return (
|
||||
`${participant.person?.name?.firstName}` +
|
||||
(shouldUseFullName ? ` ${participant.person?.name?.lastName}` : '')
|
||||
);
|
||||
}
|
||||
|
||||
if (participant.workspaceMember) {
|
||||
if (isNonNullable(participant.workspaceMember)) {
|
||||
return (
|
||||
participant.workspaceMember?.name?.firstName +
|
||||
(shouldUseFullName
|
||||
@ -23,11 +26,11 @@ export const getDisplayNameFromParticipant = ({
|
||||
);
|
||||
}
|
||||
|
||||
if (participant.displayName) {
|
||||
if (isNonEmptyString(participant.displayName)) {
|
||||
return participant.displayName;
|
||||
}
|
||||
|
||||
if (participant.handle) {
|
||||
if (isNonEmptyString(participant.handle)) {
|
||||
return participant.handle;
|
||||
}
|
||||
|
||||
|
||||
@ -16,6 +16,7 @@ import {
|
||||
AnimatedPlaceholderEmptyTextContainer,
|
||||
AnimatedPlaceholderEmptyTitle,
|
||||
} from '@/ui/layout/animated-placeholder/components/EmptyPlaceholderStyled';
|
||||
import { isNonNullable } from '~/utils/isNonNullable';
|
||||
|
||||
const StyledAttachmentsContainer = styled.div`
|
||||
display: flex;
|
||||
@ -46,7 +47,7 @@ export const Attachments = ({
|
||||
const [isDraggingFile, setIsDraggingFile] = useState(false);
|
||||
|
||||
const handleFileChange = (e: ChangeEvent<HTMLInputElement>) => {
|
||||
if (e.target.files) onUploadFile?.(e.target.files[0]);
|
||||
if (isNonNullable(e.target.files)) onUploadFile?.(e.target.files[0]);
|
||||
};
|
||||
|
||||
const handleUploadFileClick = () => {
|
||||
|
||||
@ -49,7 +49,7 @@ export const useOpenCreateActivityDrawerForSelectedRowIds = (
|
||||
})
|
||||
.filter(isNonNullable);
|
||||
|
||||
if (relatedEntities) {
|
||||
if (isNonNullable(relatedEntities)) {
|
||||
activityTargetableObjectArray =
|
||||
activityTargetableObjectArray.concat(relatedEntities);
|
||||
}
|
||||
|
||||
@ -112,7 +112,10 @@ export const useUpsertActivity = () => {
|
||||
}
|
||||
|
||||
// Call optimistic effects
|
||||
if (weAreOnObjectShowPage && objectShowPageTargetableObject) {
|
||||
if (
|
||||
weAreOnObjectShowPage &&
|
||||
isNonNullable(objectShowPageTargetableObject)
|
||||
) {
|
||||
injectIntoTimelineActivitiesQueries({
|
||||
timelineTargetableObject: objectShowPageTargetableObject,
|
||||
activityToInject: activityWithConnection,
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import { useLocation } from 'react-router-dom';
|
||||
import styled from '@emotion/styled';
|
||||
import { isNonEmptyArray } from '@sniptt/guards';
|
||||
import { isNonEmptyArray, isNonEmptyString } from '@sniptt/guards';
|
||||
import { useRecoilCallback, useRecoilState, useRecoilValue } from 'recoil';
|
||||
|
||||
import { useDeleteActivityFromCache } from '@/activities/hooks/useDeleteActivityFromCache';
|
||||
@ -108,91 +108,87 @@ export const ActivityActionBar = () => {
|
||||
|
||||
setIsRightDrawerOpen(false);
|
||||
|
||||
if (viewableActivityId) {
|
||||
if (isNonEmptyString(viewableActivityId)) {
|
||||
if (
|
||||
isActivityInCreateMode &&
|
||||
isNonNullable(temporaryActivityForEditor)
|
||||
) {
|
||||
deleteActivityFromCache(temporaryActivityForEditor);
|
||||
setTemporaryActivityForEditor(null);
|
||||
} else {
|
||||
if (activityIdInDrawer) {
|
||||
const activityTargetIdsToDelete: string[] =
|
||||
activityTargets.map(mapToRecordId) ?? [];
|
||||
} else if (isNonEmptyString(activityIdInDrawer)) {
|
||||
const activityTargetIdsToDelete: string[] =
|
||||
activityTargets.map(mapToRecordId) ?? [];
|
||||
|
||||
if (weAreOnTaskPage) {
|
||||
if (weAreOnTaskPage) {
|
||||
removeFromActivitiesQueries({
|
||||
activityIdToRemove: viewableActivityId,
|
||||
targetableObjects: [],
|
||||
activitiesFilters: currentCompletedTaskQueryVariables?.filter,
|
||||
activitiesOrderByVariables:
|
||||
currentCompletedTaskQueryVariables?.orderBy,
|
||||
});
|
||||
|
||||
removeFromActivitiesQueries({
|
||||
activityIdToRemove: viewableActivityId,
|
||||
targetableObjects: [],
|
||||
activitiesFilters: currentIncompleteTaskQueryVariables?.filter,
|
||||
activitiesOrderByVariables:
|
||||
currentIncompleteTaskQueryVariables?.orderBy,
|
||||
});
|
||||
} else if (
|
||||
weAreOnObjectShowPage &&
|
||||
isNonNullable(objectShowPageTargetableObject)
|
||||
) {
|
||||
removeFromActivitiesQueries({
|
||||
activityIdToRemove: viewableActivityId,
|
||||
targetableObjects: [objectShowPageTargetableObject],
|
||||
activitiesFilters: {},
|
||||
activitiesOrderByVariables:
|
||||
FIND_MANY_TIMELINE_ACTIVITIES_ORDER_BY,
|
||||
});
|
||||
|
||||
if (isNonNullable(currentCompletedTaskQueryVariables)) {
|
||||
removeFromActivitiesQueries({
|
||||
activityIdToRemove: viewableActivityId,
|
||||
targetableObjects: [],
|
||||
targetableObjects: [objectShowPageTargetableObject],
|
||||
activitiesFilters: currentCompletedTaskQueryVariables?.filter,
|
||||
activitiesOrderByVariables:
|
||||
currentCompletedTaskQueryVariables?.orderBy,
|
||||
});
|
||||
}
|
||||
|
||||
if (isNonNullable(currentIncompleteTaskQueryVariables)) {
|
||||
removeFromActivitiesQueries({
|
||||
activityIdToRemove: viewableActivityId,
|
||||
targetableObjects: [],
|
||||
targetableObjects: [objectShowPageTargetableObject],
|
||||
activitiesFilters:
|
||||
currentIncompleteTaskQueryVariables?.filter,
|
||||
activitiesOrderByVariables:
|
||||
currentIncompleteTaskQueryVariables?.orderBy,
|
||||
});
|
||||
} else if (
|
||||
weAreOnObjectShowPage &&
|
||||
isNonNullable(objectShowPageTargetableObject)
|
||||
) {
|
||||
}
|
||||
|
||||
if (isNonNullable(currentNotesQueryVariables)) {
|
||||
removeFromActivitiesQueries({
|
||||
activityIdToRemove: viewableActivityId,
|
||||
targetableObjects: [objectShowPageTargetableObject],
|
||||
activitiesFilters: {},
|
||||
activitiesFilters: currentNotesQueryVariables?.filter,
|
||||
activitiesOrderByVariables:
|
||||
FIND_MANY_TIMELINE_ACTIVITIES_ORDER_BY,
|
||||
});
|
||||
|
||||
if (isNonNullable(currentCompletedTaskQueryVariables)) {
|
||||
removeFromActivitiesQueries({
|
||||
activityIdToRemove: viewableActivityId,
|
||||
targetableObjects: [objectShowPageTargetableObject],
|
||||
activitiesFilters:
|
||||
currentCompletedTaskQueryVariables?.filter,
|
||||
activitiesOrderByVariables:
|
||||
currentCompletedTaskQueryVariables?.orderBy,
|
||||
});
|
||||
}
|
||||
|
||||
if (isNonNullable(currentIncompleteTaskQueryVariables)) {
|
||||
removeFromActivitiesQueries({
|
||||
activityIdToRemove: viewableActivityId,
|
||||
targetableObjects: [objectShowPageTargetableObject],
|
||||
activitiesFilters:
|
||||
currentIncompleteTaskQueryVariables?.filter,
|
||||
activitiesOrderByVariables:
|
||||
currentIncompleteTaskQueryVariables?.orderBy,
|
||||
});
|
||||
}
|
||||
|
||||
if (isNonNullable(currentNotesQueryVariables)) {
|
||||
removeFromActivitiesQueries({
|
||||
activityIdToRemove: viewableActivityId,
|
||||
targetableObjects: [objectShowPageTargetableObject],
|
||||
activitiesFilters: currentNotesQueryVariables?.filter,
|
||||
activitiesOrderByVariables:
|
||||
currentNotesQueryVariables?.orderBy,
|
||||
});
|
||||
}
|
||||
|
||||
removeFromActivityTargetsQueries({
|
||||
activityTargetsToRemove: activity?.activityTargets ?? [],
|
||||
targetableObjects: [objectShowPageTargetableObject],
|
||||
currentNotesQueryVariables?.orderBy,
|
||||
});
|
||||
}
|
||||
|
||||
if (isNonEmptyArray(activityTargetIdsToDelete)) {
|
||||
await deleteManyActivityTargets(activityTargetIdsToDelete);
|
||||
}
|
||||
|
||||
await deleteOneActivity?.(viewableActivityId);
|
||||
removeFromActivityTargetsQueries({
|
||||
activityTargetsToRemove: activity?.activityTargets ?? [],
|
||||
targetableObjects: [objectShowPageTargetableObject],
|
||||
});
|
||||
}
|
||||
|
||||
if (isNonEmptyArray(activityTargetIdsToDelete)) {
|
||||
await deleteManyActivityTargets(activityTargetIdsToDelete);
|
||||
}
|
||||
|
||||
await deleteOneActivity?.(viewableActivityId);
|
||||
}
|
||||
}
|
||||
},
|
||||
@ -223,10 +219,13 @@ export const ActivityActionBar = () => {
|
||||
|
||||
const addActivity = () => {
|
||||
setIsRightDrawerOpen(false);
|
||||
if (record && objectShowPageTargetableObject) {
|
||||
if (
|
||||
isNonNullable(record) &&
|
||||
isNonNullable(objectShowPageTargetableObject)
|
||||
) {
|
||||
openCreateActivity({
|
||||
type: record.type,
|
||||
customAssignee: record.assignee,
|
||||
type: record?.type,
|
||||
customAssignee: record?.assignee,
|
||||
targetableObjects: activityTargetableEntityArray,
|
||||
});
|
||||
}
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
import { Activity } from '@/activities/types/Activity';
|
||||
import { isNonNullable } from '~/utils/isNonNullable';
|
||||
|
||||
export type ActivityForActivityGroup = Pick<Activity, 'id' | 'createdAt'>;
|
||||
|
||||
@ -21,7 +22,7 @@ export const groupActivitiesByMonth = (
|
||||
const matchingGroup = acitivityGroups.find(
|
||||
(x) => x.year === year && x.month === month,
|
||||
);
|
||||
if (matchingGroup) {
|
||||
if (isNonNullable(matchingGroup)) {
|
||||
matchingGroup.items.push(activity);
|
||||
} else {
|
||||
acitivityGroups.push({
|
||||
|
||||
@ -1,3 +1,5 @@
|
||||
import { isNonNullable } from '~/utils/isNonNullable';
|
||||
|
||||
import { ActivityTargetableObject } from '../types/ActivityTargetableEntity';
|
||||
|
||||
export const flattenTargetableObjectsAndTheirRelatedTargetableObjects = (
|
||||
@ -9,7 +11,7 @@ export const flattenTargetableObjectsAndTheirRelatedTargetableObjects = (
|
||||
[]) {
|
||||
flattenedTargetableObjects.push(targetableObject);
|
||||
|
||||
if (targetableObject.relatedTargetableObjects) {
|
||||
if (isNonNullable(targetableObject.relatedTargetableObjects)) {
|
||||
for (const relatedEntity of targetableObject.relatedTargetableObjects ??
|
||||
[]) {
|
||||
flattenedTargetableObjects.push(relatedEntity);
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { isArray } from '@sniptt/guards';
|
||||
import { isArray, isNonEmptyString } from '@sniptt/guards';
|
||||
|
||||
export const getActivitySummary = (activityBody: string) => {
|
||||
const noteBody = activityBody ? JSON.parse(activityBody) : [];
|
||||
@ -13,7 +13,7 @@ export const getActivitySummary = (activityBody: string) => {
|
||||
return '';
|
||||
}
|
||||
|
||||
if (firstNoteBlockContent.text) {
|
||||
if (isNonEmptyString(firstNoteBlockContent.text)) {
|
||||
return noteBody[0].content.text;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user