Renamed nullable utils into isDefined and isUndefinedOrNull (#4402)
* Renamed nullable utils into isDefined and isUndefinedOrNull
This commit is contained in:
@ -25,8 +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 { isDefined } from '~/utils/isDefined';
|
||||
import { isUndefinedOrNull } from '~/utils/isUndefinedOrNull';
|
||||
|
||||
import { blockSpecs } from '../blocks/blockSpecs';
|
||||
import { getSlashMenu } from '../blocks/slashMenu';
|
||||
@ -80,7 +80,7 @@ export const ActivityBodyEditor = ({
|
||||
const { upsertActivity } = useUpsertActivity();
|
||||
|
||||
const persistBodyDebounced = useDebouncedCallback((newBody: string) => {
|
||||
if (isNonNullable(activity)) {
|
||||
if (isDefined(activity)) {
|
||||
upsertActivity({
|
||||
activity,
|
||||
input: {
|
||||
@ -92,7 +92,7 @@ export const ActivityBodyEditor = ({
|
||||
|
||||
const persistTitleAndBodyDebounced = useDebouncedCallback(
|
||||
(newTitle: string, newBody: string) => {
|
||||
if (isNonNullable(activity)) {
|
||||
if (isDefined(activity)) {
|
||||
upsertActivity({
|
||||
activity,
|
||||
input: {
|
||||
@ -126,7 +126,7 @@ export const ActivityBodyEditor = ({
|
||||
const [uploadFile] = useUploadFileMutation();
|
||||
|
||||
const handleUploadAttachment = async (file: File): Promise<string> => {
|
||||
if (isNullable(file)) {
|
||||
if (isUndefinedOrNull(file)) {
|
||||
return '';
|
||||
}
|
||||
const result = await uploadFile({
|
||||
@ -228,7 +228,7 @@ export const ActivityBodyEditor = ({
|
||||
if (isNonEmptyString(activityBody) && activityBody !== '{}') {
|
||||
return JSON.parse(activityBody);
|
||||
} else if (
|
||||
isNonNullable(activity) &&
|
||||
isDefined(activity) &&
|
||||
isNonEmptyString(activity.body) &&
|
||||
activity?.body !== '{}'
|
||||
) {
|
||||
@ -253,7 +253,7 @@ export const ActivityBodyEditor = ({
|
||||
const handleImagePaste = async (event: ClipboardEvent) => {
|
||||
const clipboardItems = event.clipboardData?.items;
|
||||
|
||||
if (isNonNullable(clipboardItems)) {
|
||||
if (isDefined(clipboardItems)) {
|
||||
for (let i = 0; i < clipboardItems.length; i++) {
|
||||
if (clipboardItems[i].kind === 'file') {
|
||||
const isImage = clipboardItems[i].type.match('^image/');
|
||||
@ -268,7 +268,7 @@ export const ActivityBodyEditor = ({
|
||||
return;
|
||||
}
|
||||
|
||||
if (isNonNullable(isImage)) {
|
||||
if (isDefined(isImage)) {
|
||||
editor?.insertBlocks(
|
||||
[
|
||||
{
|
||||
@ -334,7 +334,7 @@ export const ActivityBodyEditor = ({
|
||||
const currentBlockContent = blockIdentifier?.content;
|
||||
|
||||
if (
|
||||
isNonNullable(currentBlockContent) &&
|
||||
isDefined(currentBlockContent) &&
|
||||
isArray(currentBlockContent) &&
|
||||
currentBlockContent.length === 0
|
||||
) {
|
||||
@ -346,7 +346,7 @@ export const ActivityBodyEditor = ({
|
||||
}
|
||||
|
||||
if (
|
||||
isNonNullable(currentBlockContent) &&
|
||||
isDefined(currentBlockContent) &&
|
||||
isArray(currentBlockContent) &&
|
||||
currentBlockContent[0] &&
|
||||
currentBlockContent[0].type === 'text'
|
||||
|
||||
@ -3,7 +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';
|
||||
import { isDefined } from '~/utils/isDefined';
|
||||
|
||||
export const ActivityBodyEffect = ({ activityId }: { activityId: string }) => {
|
||||
const [activityFromStore] = useRecoilState(
|
||||
@ -17,7 +17,7 @@ export const ActivityBodyEffect = ({ activityId }: { activityId: string }) => {
|
||||
useEffect(() => {
|
||||
if (
|
||||
activityBody === '' &&
|
||||
isNonNullable(activityFromStore) &&
|
||||
isDefined(activityFromStore) &&
|
||||
activityBody !== activityFromStore.body
|
||||
) {
|
||||
setActivityBody(activityFromStore.body);
|
||||
|
||||
@ -11,7 +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';
|
||||
import { isDefined } from '~/utils/isDefined';
|
||||
|
||||
export const ActivityEditorEffect = ({
|
||||
activityId,
|
||||
@ -58,7 +58,7 @@ export const ActivityEditorEffect = ({
|
||||
return;
|
||||
}
|
||||
|
||||
if (isActivityInCreateMode && isNonNullable(activity)) {
|
||||
if (isActivityInCreateMode && isDefined(activity)) {
|
||||
if (canCreateActivity) {
|
||||
upsertActivity({
|
||||
activity,
|
||||
@ -72,7 +72,7 @@ export const ActivityEditorEffect = ({
|
||||
}
|
||||
|
||||
set(isActivityInCreateModeState(), false);
|
||||
} else if (isNonNullable(activity)) {
|
||||
} else if (isDefined(activity)) {
|
||||
if (
|
||||
activity.title !== activityTitle ||
|
||||
activity.body !== activityBody
|
||||
|
||||
@ -13,7 +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';
|
||||
import { isDefined } from '~/utils/isDefined';
|
||||
|
||||
const StyledPropertyBox = styled(PropertyBox)`
|
||||
padding: 0;
|
||||
@ -36,7 +36,7 @@ export const ActivityEditorFields = ({
|
||||
const upsertActivityMutation = async ({
|
||||
variables,
|
||||
}: RecordUpdateHookParams) => {
|
||||
if (isNonNullable(activityFromStore)) {
|
||||
if (isDefined(activityFromStore)) {
|
||||
await upsertActivity({
|
||||
activity: activityFromStore as Activity,
|
||||
input: variables.updateOneRecordInput,
|
||||
|
||||
@ -22,7 +22,7 @@ import {
|
||||
} from '@/ui/input/components/Checkbox';
|
||||
import { usePreviousHotkeyScope } from '@/ui/utilities/hotkey/hooks/usePreviousHotkeyScope';
|
||||
import { useScopedHotkeys } from '@/ui/utilities/hotkey/hooks/useScopedHotkeys';
|
||||
import { isNonNullable } from '~/utils/isNonNullable';
|
||||
import { isDefined } from '~/utils/isDefined';
|
||||
|
||||
const StyledEditableTitleInput = styled.input<{
|
||||
completed: boolean;
|
||||
@ -166,7 +166,7 @@ export const ActivityTitle = ({ activityId }: ActivityTitleProps) => {
|
||||
});
|
||||
};
|
||||
|
||||
const completed = isNonNullable(activity.completedAt);
|
||||
const completed = isDefined(activity.completedAt);
|
||||
|
||||
return (
|
||||
<StyledContainer>
|
||||
|
||||
@ -3,7 +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';
|
||||
import { isDefined } from '~/utils/isDefined';
|
||||
|
||||
export const ActivityTitleEffect = ({ activityId }: { activityId: string }) => {
|
||||
const [activityFromStore] = useRecoilState(
|
||||
@ -17,7 +17,7 @@ export const ActivityTitleEffect = ({ activityId }: { activityId: string }) => {
|
||||
useEffect(() => {
|
||||
if (
|
||||
activityTitle === '' &&
|
||||
isNonNullable(activityFromStore) &&
|
||||
isDefined(activityFromStore) &&
|
||||
activityTitle !== activityFromStore.title
|
||||
) {
|
||||
setActivityTitle(activityFromStore.title);
|
||||
|
||||
Reference in New Issue
Block a user