Conform more code to strict null checking (#10153)
* Conform more code to strict null checking * Conform more code to strict null checking * Iterate * Iterate
This commit is contained in:
parent
a4ff959aa1
commit
145a5a8a8d
89 changed files with 520 additions and 551 deletions
|
@ -34,7 +34,7 @@ const SEARCH_LIMIT = 10;
|
|||
|
||||
async function serverSideSearch(
|
||||
term: string,
|
||||
roomId: string = undefined,
|
||||
roomId?: string,
|
||||
abortSignal?: AbortSignal,
|
||||
): Promise<{ response: ISearchResponse; query: ISearchRequestBody }> {
|
||||
const client = MatrixClientPeg.get();
|
||||
|
@ -67,7 +67,7 @@ async function serverSideSearch(
|
|||
|
||||
async function serverSideSearchProcess(
|
||||
term: string,
|
||||
roomId: string = undefined,
|
||||
roomId?: string,
|
||||
abortSignal?: AbortSignal,
|
||||
): Promise<ISearchResults> {
|
||||
const client = MatrixClientPeg.get();
|
||||
|
@ -158,7 +158,7 @@ async function combinedSearch(searchTerm: string, abortSignal?: AbortSignal): Pr
|
|||
|
||||
async function localSearch(
|
||||
searchTerm: string,
|
||||
roomId: string = undefined,
|
||||
roomId?: string,
|
||||
processResult = true,
|
||||
): Promise<{ response: IResultRoomEvents; query: ISearchArgs }> {
|
||||
const eventIndex = EventIndexPeg.get();
|
||||
|
@ -195,7 +195,7 @@ export interface ISeshatSearchResults extends ISearchResults {
|
|||
serverSideNextBatch?: string;
|
||||
}
|
||||
|
||||
async function localSearchProcess(searchTerm: string, roomId: string = undefined): Promise<ISeshatSearchResults> {
|
||||
async function localSearchProcess(searchTerm: string, roomId?: string): Promise<ISeshatSearchResults> {
|
||||
const emptyResult = {
|
||||
results: [],
|
||||
highlights: [],
|
||||
|
@ -244,7 +244,7 @@ async function localPagination(searchResult: ISeshatSearchResults): Promise<ISes
|
|||
const newSlice = result.results.slice(Math.max(result.results.length - newResultCount, 0));
|
||||
restoreEncryptionInfo(newSlice);
|
||||
|
||||
searchResult.pendingRequest = null;
|
||||
searchResult.pendingRequest = undefined;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@ -388,8 +388,8 @@ function combineEventSources(
|
|||
*/
|
||||
function combineEvents(
|
||||
previousSearchResult: ISeshatSearchResults,
|
||||
localEvents: IResultRoomEvents = undefined,
|
||||
serverEvents: IResultRoomEvents = undefined,
|
||||
localEvents?: IResultRoomEvents,
|
||||
serverEvents?: IResultRoomEvents,
|
||||
): IResultRoomEvents {
|
||||
const response = {} as IResultRoomEvents;
|
||||
|
||||
|
@ -451,8 +451,8 @@ function combineEvents(
|
|||
*/
|
||||
function combineResponses(
|
||||
previousSearchResult: ISeshatSearchResults,
|
||||
localEvents: IResultRoomEvents = undefined,
|
||||
serverEvents: IResultRoomEvents = undefined,
|
||||
localEvents: IResultRoomEvents,
|
||||
serverEvents: IResultRoomEvents,
|
||||
): IResultRoomEvents {
|
||||
// Combine our events first.
|
||||
const response = combineEvents(previousSearchResult, localEvents, serverEvents);
|
||||
|
@ -496,10 +496,10 @@ function combineResponses(
|
|||
}
|
||||
|
||||
interface IEncryptedSeshatEvent {
|
||||
curve25519Key: string;
|
||||
ed25519Key: string;
|
||||
algorithm: string;
|
||||
forwardingCurve25519KeyChain: string[];
|
||||
curve25519Key?: string;
|
||||
ed25519Key?: string;
|
||||
algorithm?: string;
|
||||
forwardingCurve25519KeyChain?: string[];
|
||||
}
|
||||
|
||||
function restoreEncryptionInfo(searchResultSlice: SearchResult[] = []): void {
|
||||
|
@ -514,7 +514,7 @@ function restoreEncryptionInfo(searchResultSlice: SearchResult[] = []): void {
|
|||
EventType.RoomMessageEncrypted,
|
||||
{ algorithm: ev.algorithm },
|
||||
ev.curve25519Key,
|
||||
ev.ed25519Key,
|
||||
ev.ed25519Key!,
|
||||
);
|
||||
// @ts-ignore
|
||||
mxEv.forwardingCurve25519KeyChain = ev.forwardingCurve25519KeyChain;
|
||||
|
@ -581,11 +581,7 @@ async function combinedPagination(searchResult: ISeshatSearchResults): Promise<I
|
|||
return result;
|
||||
}
|
||||
|
||||
function eventIndexSearch(
|
||||
term: string,
|
||||
roomId: string = undefined,
|
||||
abortSignal?: AbortSignal,
|
||||
): Promise<ISearchResults> {
|
||||
function eventIndexSearch(term: string, roomId?: string, abortSignal?: AbortSignal): Promise<ISearchResults> {
|
||||
let searchPromise: Promise<ISearchResults>;
|
||||
|
||||
if (roomId !== undefined) {
|
||||
|
@ -643,11 +639,7 @@ export function searchPagination(searchResult: ISearchResults): Promise<ISearchR
|
|||
else return eventIndexSearchPagination(searchResult);
|
||||
}
|
||||
|
||||
export default function eventSearch(
|
||||
term: string,
|
||||
roomId: string = undefined,
|
||||
abortSignal?: AbortSignal,
|
||||
): Promise<ISearchResults> {
|
||||
export default function eventSearch(term: string, roomId?: string, abortSignal?: AbortSignal): Promise<ISearchResults> {
|
||||
const eventIndex = EventIndexPeg.get();
|
||||
|
||||
if (eventIndex === null) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue