mirror of
https://github.com/urbit/shrub.git
synced 2024-11-28 05:22:27 +03:00
Omnibox: fix tsc
This commit is contained in:
parent
5af7e3d28c
commit
d0d274cb47
@ -10,8 +10,18 @@ const makeIndexes = () => new Map([
|
||||
['other', []]
|
||||
]);
|
||||
|
||||
export interface OmniboxItem {
|
||||
title: string;
|
||||
link: string;
|
||||
app: string;
|
||||
host: string;
|
||||
description: string;
|
||||
shiftLink: string;
|
||||
shiftDescription: string;
|
||||
}
|
||||
|
||||
// result schematic
|
||||
const result = function(title, link, app, host, description = 'Open', shiftLink = null, shiftDescription = null) {
|
||||
const result = function(title: string, link: string, app: string, host: string, description = 'Open', shiftLink = null as string | null, shiftDescription = null as string | null): OmniboxItem {
|
||||
return {
|
||||
'title': title,
|
||||
'link': link,
|
||||
@ -93,7 +103,7 @@ const otherIndex = function(config) {
|
||||
return other;
|
||||
};
|
||||
|
||||
export default function index(contacts, associations, apps, currentGroup, groups, hide) {
|
||||
export default function index(contacts, associations, apps, currentGroup, groups, hide): Map<string, OmniboxItem[]> {
|
||||
const indexes = makeIndexes();
|
||||
indexes.set('ships', shipIndex(contacts));
|
||||
// all metadata from all apps is indexed
|
||||
@ -117,7 +127,7 @@ export default function index(contacts, associations, apps, currentGroup, groups
|
||||
let app = each['app-name'];
|
||||
if (each['app-name'] === 'contacts') {
|
||||
app = 'groups';
|
||||
};
|
||||
}
|
||||
|
||||
if (each['app-name'] === 'graph') {
|
||||
app = each.metadata.config.graph;
|
||||
@ -159,4 +169,4 @@ export default function index(contacts, associations, apps, currentGroup, groups
|
||||
indexes.set('other', otherIndex(hide));
|
||||
|
||||
return indexes;
|
||||
};
|
||||
}
|
@ -13,7 +13,7 @@ import React, {
|
||||
import { useHistory, useLocation } from 'react-router-dom';
|
||||
import * as ob from 'urbit-ob';
|
||||
import defaultApps from '~/logic/lib/default-apps';
|
||||
import makeIndex from '~/logic/lib/omnibox';
|
||||
import makeIndex, { OmniboxItem } from '~/logic/lib/omnibox';
|
||||
import { useOutsideClick } from '~/logic/lib/useOutsideClick';
|
||||
import { deSig } from '~/logic/lib/util';
|
||||
import useContactState from '~/logic/state/contact';
|
||||
@ -114,7 +114,7 @@ export function Omnibox(props: OmniboxProps): ReactElement {
|
||||
}, [props.show]);
|
||||
|
||||
const initialResults = useMemo(() => {
|
||||
return new Map(
|
||||
return new Map<string, OmniboxItem[]>(
|
||||
SEARCHED_CATEGORIES.map((category) => {
|
||||
if (category === 'other') {
|
||||
return [
|
||||
@ -132,7 +132,7 @@ export function Omnibox(props: OmniboxProps): ReactElement {
|
||||
return initialResults;
|
||||
}
|
||||
const q = query.toLowerCase();
|
||||
const resultsMap = new Map();
|
||||
const resultsMap = new Map<string, OmniboxItem[]>();
|
||||
SEARCHED_CATEGORIES.map((category) => {
|
||||
const categoryIndex = index.get(category);
|
||||
resultsMap.set(
|
||||
@ -317,7 +317,7 @@ export function Omnibox(props: OmniboxProps): ReactElement {
|
||||
borderBottomRightRadius={2}
|
||||
>
|
||||
{SEARCHED_CATEGORIES.map(category =>
|
||||
Object({
|
||||
({
|
||||
category,
|
||||
categoryResults: _.take(results.get(category).sort(sortResults), CAT_LIMIT)
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user