Skip to content

Commit 6ca55ab

Browse files
committed
small helper flow tweaks
1 parent 2754b77 commit 6ca55ab

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

helpers/paragraph.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ export function findStartOfActivePartOfNote(note: CoreNoteFields, allowPreamble?
298298
return 0
299299
}
300300

301-
const endOfFMIndex = endOfFrontmatterLineIndex(note)
301+
const endOfFMIndex: number = endOfFrontmatterLineIndex(note) || 0
302302
if (endOfFMIndex === 0) {
303303
// No frontmatter found
304304
if (paras[0].type === 'title' && paras[0].headingLevel === 1) {

helpers/userInput.js

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -255,8 +255,8 @@ export async function chooseFolder(msg: string, includeArchive?: boolean = false
255255
}
256256
}
257257
}
258-
logDebug(`helpers/userInput`, `chooseFolder folder chosen: "${folder}"`)
259-
return folder
258+
logDebug(`helpers/userInput`, `chooseFolder folder chosen: "${folder}"`)
259+
return folder
260260
}
261261

262262
/**
@@ -361,6 +361,7 @@ export async function datePicker(dateParams: string, config?: { [string]: ?mixed
361361
logDebug('userInput / datePicker', `params: ${dateParams} -> ${JSON.stringify(paramConfig)}`)
362362
// '...' = "gather the remaining parameters into an array"
363363
const allSettings: { [string]: mixed } = {
364+
// $FlowIgnore[exponential-spread] known to be very small objects
364365
...dateConfig,
365366
...paramConfig,
366367
}
@@ -492,7 +493,7 @@ export async function inputMood(moodArray: Array<string>): Promise<string> {
492493
*/
493494
export const multipleInputAnswersAsArray = async (question: string, submit: string, showCounter: boolean, minAnswers: number = 0, maxAnswers?: number): Promise<Array<string>> => {
494495
let input = '-'
495-
const answers = []
496+
const answers: Array<string> = []
496497

497498
while ((maxAnswers ? answers.length < maxAnswers : true) && (input || answers.length < minAnswers)) {
498499
const placeholder = maxAnswers && showCounter ? `${question} (${answers.length + 1}/${maxAnswers})` : question
@@ -572,7 +573,7 @@ export async function chooseNote(
572573
currentNoteFirst?: boolean = false,
573574
allowNewNoteCreation?: boolean = false,
574575
): Promise<TNote | null> {
575-
let noteList = []
576+
let noteList: Array<TNote> = []
576577
const projectNotes = DataStore.projectNotes
577578
const calendarNotes = DataStore.calendarNotes
578579
if (includeProjectNotes) {
@@ -599,17 +600,17 @@ export async function chooseNote(
599600
const { note } = Editor
600601
if (allowNewNoteCreation) {
601602
opts.unshift('[New note]')
603+
// $FlowIgnore[incompatible-type] just to keep the indexes matching; won't be used
602604
sortedNoteListFiltered.unshift('[New note]') // just keep the indexes matching
603605
}
604606
if (currentNoteFirst && note) {
605607
sortedNoteListFiltered.unshift(note)
606608
opts.unshift(`[Current note: "${displayTitleWithRelDate(Editor)}"]`)
607609
}
608610
const { index } = await CommandBar.showOptions(opts, promptText)
609-
let noteToReturn = sortedNoteListFiltered[index]
610-
if (noteToReturn === '[New note]') {
611-
noteToReturn = await createNewNote()
612-
}
611+
const noteToReturn = (opts[index] === '[New note]')
612+
? await createNewNote()
613+
: sortedNoteListFiltered[index]
613614
return noteToReturn ?? null
614615
}
615616

0 commit comments

Comments
 (0)