diff --git a/lib/actions/entry-actions.js b/lib/actions/entry-actions.js --- a/lib/actions/entry-actions.js +++ b/lib/actions/entry-actions.js @@ -37,7 +37,10 @@ } from '../types/entry-types.js'; import type { HistoryRevisionInfo } from '../types/history-types.js'; import type { ThreadInfo } from '../types/minimally-encoded-thread-permissions-types'; -import { thickThreadTypes } from '../types/thread-types-enum.js'; +import { + thickThreadTypes, + threadTypeIsThick, +} from '../types/thread-types-enum.js'; import { dateFromString, dateString as stringFromDate, @@ -198,17 +201,10 @@ }; }; -export type UseCreateEntryInput = $ReadOnly< - | { - +thick: false, - +createEntryInfo: CreateEntryInfo, - } - | { - +thick: true, - +threadInfo: ThreadInfo, - +createEntryInfo: CreateEntryInfo, - }, ->; +export type UseCreateEntryInput = { + +threadInfo: ThreadInfo, + +createEntryInfo: CreateEntryInfo, +}; function useCreateEntry(): ( input: UseCreateEntryInput, ) => Promise { @@ -221,7 +217,7 @@ return React.useCallback( async (input: UseCreateEntryInput) => { - if (!input.thick) { + if (!threadTypeIsThick(input.threadInfo.type)) { const result = await keyserverCall(input.createEntryInfo); return result; } @@ -301,17 +297,10 @@ }; }; -export type UseSaveEntryInput = $ReadOnly< - | { - +thick: false, - +saveEntryInfo: SaveEntryInfo, - } - | { - +thick: true, - +threadInfo: ThreadInfo, - +saveEntryInfo: SaveEntryInfo, - }, ->; +export type UseSaveEntryInput = { + +threadInfo: ThreadInfo, + +saveEntryInfo: SaveEntryInfo, +}; function useSaveEntry(): ( input: UseSaveEntryInput, ) => Promise { @@ -325,7 +314,7 @@ return React.useCallback( async (input: UseSaveEntryInput) => { - if (!input.thick) { + if (!threadTypeIsThick(input.threadInfo.type)) { const result = await keyserverCall(input.saveEntryInfo); return result; } @@ -408,17 +397,10 @@ }; }; -export type UseDeleteEntryInput = $ReadOnly< - | { - +thick: false, - +deleteEntryInfo: DeleteEntryInfo, - } - | { - +thick: true, - +threadInfo: ThreadInfo, - +deleteEntryInfo: DeleteEntryInfo, - }, ->; +export type UseDeleteEntryInput = { + +threadInfo: ThreadInfo, + +deleteEntryInfo: DeleteEntryInfo, +}; function useDeleteEntry(): ( input: UseDeleteEntryInput, ) => Promise { @@ -432,7 +414,7 @@ return React.useCallback( async (input: UseDeleteEntryInput) => { - if (!input.thick) { + if (!threadTypeIsThick(input.threadInfo.type)) { const result = await keyserverCall(input.deleteEntryInfo); return result; } diff --git a/native/calendar/entry.react.js b/native/calendar/entry.react.js --- a/native/calendar/entry.react.js +++ b/native/calendar/entry.react.js @@ -652,16 +652,10 @@ calendarQuery: this.props.calendarQuery(), }; - const useCreateEntryInput = threadTypeIsThick(this.props.threadInfo.type) - ? { - thick: true, - threadInfo: this.props.threadInfo, - createEntryInfo, - } - : { - thick: false, - createEntryInfo, - }; + const useCreateEntryInput = { + threadInfo: this.props.threadInfo, + createEntryInfo, + }; const response = await this.props.createEntry(useCreateEntryInput); @@ -706,16 +700,10 @@ calendarQuery: this.props.calendarQuery(), }; - const useSaveEntryInput = threadTypeIsThick(this.props.threadInfo.type) - ? { - thick: true, - threadInfo: this.props.threadInfo, - saveEntryInfo, - } - : { - thick: false, - saveEntryInfo, - }; + const useSaveEntryInput = { + threadInfo: this.props.threadInfo, + saveEntryInfo, + }; const response = await this.props.saveEntry(useSaveEntryInput); if (curSaveAttempt + 1 === this.nextSaveAttemptIndex) { @@ -797,16 +785,10 @@ calendarQuery: this.props.calendarQuery(), }; - const useDeleteEntryInput = threadTypeIsThick(this.props.threadInfo.type) - ? { - thick: true, - threadInfo: this.props.threadInfo, - deleteEntryInfo, - } - : { - thick: false, - deleteEntryInfo, - }; + const useDeleteEntryInput = { + threadInfo: this.props.threadInfo, + deleteEntryInfo, + }; return await this.props.deleteEntry(useDeleteEntryInput); } else if (this.creating || this.currentlySaving) { diff --git a/web/calendar/entry.react.js b/web/calendar/entry.react.js --- a/web/calendar/entry.react.js +++ b/web/calendar/entry.react.js @@ -341,16 +341,10 @@ calendarQuery: this.props.calendarQuery(), }; - const useCreateEntryInput = threadTypeIsThick(this.props.threadInfo.type) - ? { - thick: true, - threadInfo: this.props.threadInfo, - createEntryInfo, - } - : { - thick: false, - createEntryInfo, - }; + const useCreateEntryInput = { + threadInfo: this.props.threadInfo, + createEntryInfo, + }; const response = await this.props.createEntry(useCreateEntryInput); if (curSaveAttempt + 1 === this.nextSaveAttemptIndex) { @@ -391,16 +385,10 @@ calendarQuery: this.props.calendarQuery(), }; - const useSaveEntryInput = threadTypeIsThick(this.props.threadInfo.type) - ? { - thick: true, - threadInfo: this.props.threadInfo, - saveEntryInfo, - } - : { - thick: false, - saveEntryInfo, - }; + const useSaveEntryInput = { + threadInfo: this.props.threadInfo, + saveEntryInfo, + }; const response = await this.props.saveEntry(useSaveEntryInput); if (curSaveAttempt + 1 === this.nextSaveAttemptIndex) { @@ -466,16 +454,10 @@ calendarQuery: this.props.calendarQuery(), }; - const useDeleteEntryInput = threadTypeIsThick(this.props.threadInfo.type) - ? { - thick: true, - threadInfo: this.props.threadInfo, - deleteEntryInfo, - } - : { - thick: false, - deleteEntryInfo, - }; + const useDeleteEntryInput = { + threadInfo: this.props.threadInfo, + deleteEntryInfo, + }; return await this.props.deleteEntry(useDeleteEntryInput); } else if (this.creating) {