This commit is contained in:
commit
1258d31007
7 changed files with 94 additions and 23 deletions
|
@ -104,7 +104,7 @@ const defaultModeSpecificProps = {
|
||||||
pinnedConversations,
|
pinnedConversations,
|
||||||
conversations: defaultConversations,
|
conversations: defaultConversations,
|
||||||
archivedConversations: defaultArchivedConversations,
|
archivedConversations: defaultArchivedConversations,
|
||||||
isAboutToSearchInAConversation: false,
|
isAboutToSearch: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
const emptySearchResultsGroup = { isLoading: false, results: [] };
|
const emptySearchResultsGroup = { isLoading: false, results: [] };
|
||||||
|
@ -278,7 +278,7 @@ export function InboxNoConversations(): JSX.Element {
|
||||||
pinnedConversations: [],
|
pinnedConversations: [],
|
||||||
conversations: [],
|
conversations: [],
|
||||||
archivedConversations: [],
|
archivedConversations: [],
|
||||||
isAboutToSearchInAConversation: false,
|
isAboutToSearch: false,
|
||||||
},
|
},
|
||||||
})}
|
})}
|
||||||
/>
|
/>
|
||||||
|
@ -299,7 +299,7 @@ export function InboxOnlyPinnedConversations(): JSX.Element {
|
||||||
pinnedConversations,
|
pinnedConversations,
|
||||||
conversations: [],
|
conversations: [],
|
||||||
archivedConversations: [],
|
archivedConversations: [],
|
||||||
isAboutToSearchInAConversation: false,
|
isAboutToSearch: false,
|
||||||
},
|
},
|
||||||
})}
|
})}
|
||||||
/>
|
/>
|
||||||
|
@ -320,7 +320,7 @@ export function InboxOnlyNonPinnedConversations(): JSX.Element {
|
||||||
pinnedConversations: [],
|
pinnedConversations: [],
|
||||||
conversations: defaultConversations,
|
conversations: defaultConversations,
|
||||||
archivedConversations: [],
|
archivedConversations: [],
|
||||||
isAboutToSearchInAConversation: false,
|
isAboutToSearch: false,
|
||||||
},
|
},
|
||||||
})}
|
})}
|
||||||
/>
|
/>
|
||||||
|
@ -341,7 +341,7 @@ export function InboxOnlyArchivedConversations(): JSX.Element {
|
||||||
pinnedConversations: [],
|
pinnedConversations: [],
|
||||||
conversations: [],
|
conversations: [],
|
||||||
archivedConversations: defaultArchivedConversations,
|
archivedConversations: defaultArchivedConversations,
|
||||||
isAboutToSearchInAConversation: false,
|
isAboutToSearch: false,
|
||||||
},
|
},
|
||||||
})}
|
})}
|
||||||
/>
|
/>
|
||||||
|
@ -362,7 +362,7 @@ export function InboxPinnedAndArchivedConversations(): JSX.Element {
|
||||||
pinnedConversations,
|
pinnedConversations,
|
||||||
conversations: [],
|
conversations: [],
|
||||||
archivedConversations: defaultArchivedConversations,
|
archivedConversations: defaultArchivedConversations,
|
||||||
isAboutToSearchInAConversation: false,
|
isAboutToSearch: false,
|
||||||
},
|
},
|
||||||
})}
|
})}
|
||||||
/>
|
/>
|
||||||
|
@ -383,7 +383,7 @@ export function InboxNonPinnedAndArchivedConversations(): JSX.Element {
|
||||||
pinnedConversations: [],
|
pinnedConversations: [],
|
||||||
conversations: defaultConversations,
|
conversations: defaultConversations,
|
||||||
archivedConversations: defaultArchivedConversations,
|
archivedConversations: defaultArchivedConversations,
|
||||||
isAboutToSearchInAConversation: false,
|
isAboutToSearch: false,
|
||||||
},
|
},
|
||||||
})}
|
})}
|
||||||
/>
|
/>
|
||||||
|
@ -404,7 +404,7 @@ export function InboxPinnedAndNonPinnedConversations(): JSX.Element {
|
||||||
pinnedConversations,
|
pinnedConversations,
|
||||||
conversations: defaultConversations,
|
conversations: defaultConversations,
|
||||||
archivedConversations: [],
|
archivedConversations: [],
|
||||||
isAboutToSearchInAConversation: false,
|
isAboutToSearch: false,
|
||||||
},
|
},
|
||||||
})}
|
})}
|
||||||
/>
|
/>
|
||||||
|
@ -946,7 +946,7 @@ export function CaptchaDialogRequired(): JSX.Element {
|
||||||
pinnedConversations,
|
pinnedConversations,
|
||||||
conversations: defaultConversations,
|
conversations: defaultConversations,
|
||||||
archivedConversations: [],
|
archivedConversations: [],
|
||||||
isAboutToSearchInAConversation: false,
|
isAboutToSearch: false,
|
||||||
searchTerm: '',
|
searchTerm: '',
|
||||||
},
|
},
|
||||||
challengeStatus: 'required',
|
challengeStatus: 'required',
|
||||||
|
@ -969,7 +969,7 @@ export function CaptchaDialogPending(): JSX.Element {
|
||||||
pinnedConversations,
|
pinnedConversations,
|
||||||
conversations: defaultConversations,
|
conversations: defaultConversations,
|
||||||
archivedConversations: [],
|
archivedConversations: [],
|
||||||
isAboutToSearchInAConversation: false,
|
isAboutToSearch: false,
|
||||||
searchTerm: '',
|
searchTerm: '',
|
||||||
},
|
},
|
||||||
challengeStatus: 'pending',
|
challengeStatus: 'pending',
|
||||||
|
@ -991,7 +991,7 @@ export const _CrashReportDialog = (): JSX.Element => (
|
||||||
pinnedConversations,
|
pinnedConversations,
|
||||||
conversations: defaultConversations,
|
conversations: defaultConversations,
|
||||||
archivedConversations: [],
|
archivedConversations: [],
|
||||||
isAboutToSearchInAConversation: false,
|
isAboutToSearch: false,
|
||||||
searchTerm: '',
|
searchTerm: '',
|
||||||
},
|
},
|
||||||
crashReportCount: 42,
|
crashReportCount: 42,
|
||||||
|
@ -1163,7 +1163,7 @@ export function SearchingConversation(): JSX.Element {
|
||||||
pinnedConversations: [],
|
pinnedConversations: [],
|
||||||
conversations: defaultConversations,
|
conversations: defaultConversations,
|
||||||
archivedConversations: [],
|
archivedConversations: [],
|
||||||
isAboutToSearchInAConversation: false,
|
isAboutToSearch: false,
|
||||||
searchConversation: getDefaultConversation(),
|
searchConversation: getDefaultConversation(),
|
||||||
searchTerm: '',
|
searchTerm: '',
|
||||||
},
|
},
|
||||||
|
|
|
@ -24,7 +24,7 @@ export type LeftPaneInboxPropsType = {
|
||||||
conversations: ReadonlyArray<ConversationListItemPropsType>;
|
conversations: ReadonlyArray<ConversationListItemPropsType>;
|
||||||
archivedConversations: ReadonlyArray<ConversationListItemPropsType>;
|
archivedConversations: ReadonlyArray<ConversationListItemPropsType>;
|
||||||
pinnedConversations: ReadonlyArray<ConversationListItemPropsType>;
|
pinnedConversations: ReadonlyArray<ConversationListItemPropsType>;
|
||||||
isAboutToSearchInAConversation: boolean;
|
isAboutToSearch: boolean;
|
||||||
startSearchCounter: number;
|
startSearchCounter: number;
|
||||||
searchDisabled: boolean;
|
searchDisabled: boolean;
|
||||||
searchTerm: string;
|
searchTerm: string;
|
||||||
|
@ -38,7 +38,7 @@ export class LeftPaneInboxHelper extends LeftPaneHelper<LeftPaneInboxPropsType>
|
||||||
|
|
||||||
private readonly pinnedConversations: ReadonlyArray<ConversationListItemPropsType>;
|
private readonly pinnedConversations: ReadonlyArray<ConversationListItemPropsType>;
|
||||||
|
|
||||||
private readonly isAboutToSearchInAConversation: boolean;
|
private readonly isAboutToSearch: boolean;
|
||||||
|
|
||||||
private readonly startSearchCounter: number;
|
private readonly startSearchCounter: number;
|
||||||
|
|
||||||
|
@ -52,7 +52,7 @@ export class LeftPaneInboxHelper extends LeftPaneHelper<LeftPaneInboxPropsType>
|
||||||
conversations,
|
conversations,
|
||||||
archivedConversations,
|
archivedConversations,
|
||||||
pinnedConversations,
|
pinnedConversations,
|
||||||
isAboutToSearchInAConversation,
|
isAboutToSearch,
|
||||||
startSearchCounter,
|
startSearchCounter,
|
||||||
searchDisabled,
|
searchDisabled,
|
||||||
searchTerm,
|
searchTerm,
|
||||||
|
@ -63,7 +63,7 @@ export class LeftPaneInboxHelper extends LeftPaneHelper<LeftPaneInboxPropsType>
|
||||||
this.conversations = conversations;
|
this.conversations = conversations;
|
||||||
this.archivedConversations = archivedConversations;
|
this.archivedConversations = archivedConversations;
|
||||||
this.pinnedConversations = pinnedConversations;
|
this.pinnedConversations = pinnedConversations;
|
||||||
this.isAboutToSearchInAConversation = isAboutToSearchInAConversation;
|
this.isAboutToSearch = isAboutToSearch;
|
||||||
this.startSearchCounter = startSearchCounter;
|
this.startSearchCounter = startSearchCounter;
|
||||||
this.searchDisabled = searchDisabled;
|
this.searchDisabled = searchDisabled;
|
||||||
this.searchTerm = searchTerm;
|
this.searchTerm = searchTerm;
|
||||||
|
@ -245,7 +245,7 @@ export class LeftPaneInboxHelper extends LeftPaneHelper<LeftPaneInboxPropsType>
|
||||||
!this.conversations.length &&
|
!this.conversations.length &&
|
||||||
!this.pinnedConversations.length &&
|
!this.pinnedConversations.length &&
|
||||||
!this.archivedConversations.length;
|
!this.archivedConversations.length;
|
||||||
return hasNoConversations || this.isAboutToSearchInAConversation;
|
return hasNoConversations || this.isAboutToSearch;
|
||||||
}
|
}
|
||||||
|
|
||||||
shouldRecomputeRowHeights(old: Readonly<LeftPaneInboxPropsType>): boolean {
|
shouldRecomputeRowHeights(old: Readonly<LeftPaneInboxPropsType>): boolean {
|
||||||
|
|
|
@ -57,6 +57,7 @@ export type MessageSearchResultLookupType = ReadonlyDeep<{
|
||||||
export type SearchStateType = ReadonlyDeep<{
|
export type SearchStateType = ReadonlyDeep<{
|
||||||
startSearchCounter: number;
|
startSearchCounter: number;
|
||||||
searchConversationId?: string;
|
searchConversationId?: string;
|
||||||
|
globalSearch?: boolean;
|
||||||
contactIds: Array<string>;
|
contactIds: Array<string>;
|
||||||
conversationIds: Array<string>;
|
conversationIds: Array<string>;
|
||||||
query: string;
|
query: string;
|
||||||
|
@ -94,7 +95,7 @@ type UpdateSearchTermActionType = ReadonlyDeep<{
|
||||||
}>;
|
}>;
|
||||||
type StartSearchActionType = ReadonlyDeep<{
|
type StartSearchActionType = ReadonlyDeep<{
|
||||||
type: 'SEARCH_START';
|
type: 'SEARCH_START';
|
||||||
payload: null;
|
payload: { globalSearch: boolean };
|
||||||
}>;
|
}>;
|
||||||
type ClearSearchActionType = ReadonlyDeep<{
|
type ClearSearchActionType = ReadonlyDeep<{
|
||||||
type: 'SEARCH_CLEAR';
|
type: 'SEARCH_CLEAR';
|
||||||
|
@ -137,7 +138,7 @@ export const actions = {
|
||||||
function startSearch(): StartSearchActionType {
|
function startSearch(): StartSearchActionType {
|
||||||
return {
|
return {
|
||||||
type: 'SEARCH_START',
|
type: 'SEARCH_START',
|
||||||
payload: null,
|
payload: { globalSearch: true },
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
function clearSearch(): ClearSearchActionType {
|
function clearSearch(): ClearSearchActionType {
|
||||||
|
@ -341,6 +342,7 @@ export function reducer(
|
||||||
return {
|
return {
|
||||||
...state,
|
...state,
|
||||||
searchConversationId: undefined,
|
searchConversationId: undefined,
|
||||||
|
globalSearch: true,
|
||||||
startSearchCounter: state.startSearchCounter + 1,
|
startSearchCounter: state.startSearchCounter + 1,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,6 +54,18 @@ export const getIsSearchingInAConversation = createSelector(
|
||||||
Boolean
|
Boolean
|
||||||
);
|
);
|
||||||
|
|
||||||
|
export const getIsSearchingGlobally = createSelector(
|
||||||
|
getSearch,
|
||||||
|
(state: SearchStateType): boolean => Boolean(state.globalSearch)
|
||||||
|
);
|
||||||
|
|
||||||
|
export const getIsSearching = createSelector(
|
||||||
|
getIsSearchingInAConversation,
|
||||||
|
getIsSearchingGlobally,
|
||||||
|
(isSearchingInAConversation, isSearchingGlobally): boolean =>
|
||||||
|
isSearchingInAConversation || isSearchingGlobally
|
||||||
|
);
|
||||||
|
|
||||||
export const getSearchConversation = createSelector(
|
export const getSearchConversation = createSelector(
|
||||||
getSearchConversationId,
|
getSearchConversationId,
|
||||||
getConversationLookup,
|
getConversationLookup,
|
||||||
|
|
|
@ -16,7 +16,7 @@ import { isDone as isRegistrationDone } from '../../util/registration';
|
||||||
|
|
||||||
import { ComposerStep, OneTimeModalState } from '../ducks/conversationsEnums';
|
import { ComposerStep, OneTimeModalState } from '../ducks/conversationsEnums';
|
||||||
import {
|
import {
|
||||||
getIsSearchingInAConversation,
|
getIsSearching,
|
||||||
getQuery,
|
getQuery,
|
||||||
getSearchConversation,
|
getSearchConversation,
|
||||||
getSearchResults,
|
getSearchResults,
|
||||||
|
@ -152,7 +152,7 @@ const getModeSpecificProps = (
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
mode: LeftPaneMode.Inbox,
|
mode: LeftPaneMode.Inbox,
|
||||||
isAboutToSearchInAConversation: getIsSearchingInAConversation(state),
|
isAboutToSearch: getIsSearching(state),
|
||||||
searchConversation: getSearchConversation(state),
|
searchConversation: getSearchConversation(state),
|
||||||
searchDisabled: state.network.challengeStatus !== 'idle',
|
searchDisabled: state.network.challengeStatus !== 'idle',
|
||||||
searchTerm: getQuery(state),
|
searchTerm: getQuery(state),
|
||||||
|
|
|
@ -14,6 +14,8 @@ import type { MessageSearchResultType } from '../../../state/ducks/search';
|
||||||
import { getEmptyState as getEmptySearchState } from '../../../state/ducks/search';
|
import { getEmptyState as getEmptySearchState } from '../../../state/ducks/search';
|
||||||
import { getEmptyState as getEmptyUserState } from '../../../state/ducks/user';
|
import { getEmptyState as getEmptyUserState } from '../../../state/ducks/user';
|
||||||
import {
|
import {
|
||||||
|
getIsSearching,
|
||||||
|
getIsSearchingGlobally,
|
||||||
getIsSearchingInAConversation,
|
getIsSearchingInAConversation,
|
||||||
getMessageSearchResultSelector,
|
getMessageSearchResultSelector,
|
||||||
getSearchResults,
|
getSearchResults,
|
||||||
|
@ -93,6 +95,61 @@ describe('both/state/selectors/search', () => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('#getIsSearchingGlobally', () => {
|
||||||
|
it('returns false if not searching', () => {
|
||||||
|
const state = getEmptyRootState();
|
||||||
|
|
||||||
|
assert.isFalse(getIsSearchingGlobally(state));
|
||||||
|
});
|
||||||
|
|
||||||
|
it('returns true if searching globally', () => {
|
||||||
|
const state = {
|
||||||
|
...getEmptyRootState(),
|
||||||
|
search: {
|
||||||
|
...getEmptySearchState(),
|
||||||
|
globalSearch: true,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
assert.isTrue(getIsSearchingGlobally(state));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('#getIsSearching', () => {
|
||||||
|
it('returns false if not searching in any manner', () => {
|
||||||
|
const state = getEmptyRootState();
|
||||||
|
|
||||||
|
assert.isFalse(getIsSearching(state));
|
||||||
|
});
|
||||||
|
|
||||||
|
it('returns true if searching in a conversation', () => {
|
||||||
|
const state = {
|
||||||
|
...getEmptyRootState(),
|
||||||
|
search: {
|
||||||
|
...getEmptySearchState(),
|
||||||
|
searchConversationId: 'abc123',
|
||||||
|
searchConversationName: 'Test Conversation',
|
||||||
|
globalSearch: false,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
assert.isTrue(getIsSearching(state));
|
||||||
|
});
|
||||||
|
|
||||||
|
it('returns true if searching globally', () => {
|
||||||
|
const state = {
|
||||||
|
...getEmptyRootState(),
|
||||||
|
search: {
|
||||||
|
...getEmptySearchState(),
|
||||||
|
searchConversationId: undefined,
|
||||||
|
globalSearch: true,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
assert.isTrue(getIsSearchingGlobally(state));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe('#getMessageSearchResultSelector', () => {
|
describe('#getMessageSearchResultSelector', () => {
|
||||||
it('returns undefined if message not found in lookup', () => {
|
it('returns undefined if message not found in lookup', () => {
|
||||||
const state = getEmptyRootState();
|
const state = getEmptyRootState();
|
||||||
|
|
|
@ -14,7 +14,7 @@ describe('LeftPaneInboxHelper', () => {
|
||||||
const defaultProps: LeftPaneInboxPropsType = {
|
const defaultProps: LeftPaneInboxPropsType = {
|
||||||
archivedConversations: [],
|
archivedConversations: [],
|
||||||
conversations: [],
|
conversations: [],
|
||||||
isAboutToSearchInAConversation: false,
|
isAboutToSearch: false,
|
||||||
pinnedConversations: [],
|
pinnedConversations: [],
|
||||||
searchConversation: undefined,
|
searchConversation: undefined,
|
||||||
searchDisabled: false,
|
searchDisabled: false,
|
||||||
|
@ -616,7 +616,7 @@ describe('LeftPaneInboxHelper', () => {
|
||||||
it("returns true if we're about to search in a conversation", () => {
|
it("returns true if we're about to search in a conversation", () => {
|
||||||
const helper = new LeftPaneInboxHelper({
|
const helper = new LeftPaneInboxHelper({
|
||||||
...defaultProps,
|
...defaultProps,
|
||||||
isAboutToSearchInAConversation: true,
|
isAboutToSearch: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
assert.isTrue(helper.requiresFullWidth());
|
assert.isTrue(helper.requiresFullWidth());
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue