Skip to content

Commit

Permalink
Merge pull request Expensify#34496 from software-mansion-labs/ts/Rema…
Browse files Browse the repository at this point in the history
…iningGroup3

[TS migration] Migrate '[Remaining Group 3]' lib to TypeScript
  • Loading branch information
tgolen authored Jan 24, 2024
2 parents 036a4be + fe4fd49 commit a052156
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
let isReadyToFocusPromise = Promise.resolve();
let resolveIsReadyToFocus;
let resolveIsReadyToFocus: (value: void | PromiseLike<void>) => void;

function resetReadyToFocus() {
isReadyToFocusPromise = new Promise((resolve) => {
resolveIsReadyToFocus = resolve;
});
}

function setReadyToFocus() {
if (!resolveIsReadyToFocus) {
return;
}
resolveIsReadyToFocus();
}
function isReadyToFocus() {

function isReadyToFocus(): Promise<void> {
return isReadyToFocusPromise;
}

Expand Down
13 changes: 3 additions & 10 deletions src/libs/SuggestionUtils.js → src/libs/SuggestionUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,14 @@ import CONST from '@src/CONST';

/**
* Trims first character of the string if it is a space
* @param {String} str
* @returns {String}
*/
function trimLeadingSpace(str) {
return str.slice(0, 1) === ' ' ? str.slice(1) : str;
function trimLeadingSpace(str: string): string {
return str.startsWith(' ') ? str.slice(1) : str;
}

/**
* Checks if space is available to render large suggestion menu
* @param {Number} listHeight
* @param {Number} composerHeight
* @param {Number} totalSuggestions
* @returns {Boolean}
*/
function hasEnoughSpaceForLargeSuggestionMenu(listHeight, composerHeight, totalSuggestions) {
function hasEnoughSpaceForLargeSuggestionMenu(listHeight: number, composerHeight: number, totalSuggestions: number): boolean {
const maxSuggestions = CONST.AUTO_COMPLETE_SUGGESTER.MAX_AMOUNT_OF_VISIBLE_SUGGESTIONS_IN_CONTAINER;
const chatFooterHeight = CONST.CHAT_FOOTER_SECONDARY_ROW_HEIGHT + 2 * CONST.CHAT_FOOTER_SECONDARY_ROW_PADDING;
const availableHeight = listHeight - composerHeight - chatFooterHeight;
Expand Down

0 comments on commit a052156

Please sign in to comment.