Passive UUID support
Co-authored-by: Scott Nonnenberg <scott@signal.org>
This commit is contained in:
parent
f64ca0ed21
commit
a90246cbe5
49 changed files with 2226 additions and 776 deletions
|
@ -148,7 +148,7 @@ function searchMessages(
|
|||
function searchDiscussions(
|
||||
query: string,
|
||||
options: {
|
||||
ourNumber: string;
|
||||
ourConversationId: string;
|
||||
noteToSelf: string;
|
||||
}
|
||||
): SearchDiscussionsResultsKickoffActionType {
|
||||
|
@ -180,15 +180,15 @@ async function doSearchMessages(
|
|||
async function doSearchDiscussions(
|
||||
query: string,
|
||||
options: {
|
||||
ourNumber: string;
|
||||
ourConversationId: string;
|
||||
noteToSelf: string;
|
||||
}
|
||||
): Promise<SearchDiscussionsResultsPayloadType> {
|
||||
const { ourNumber, noteToSelf } = options;
|
||||
const { ourConversationId, noteToSelf } = options;
|
||||
const { conversations, contacts } = await queryConversationsAndContacts(
|
||||
query,
|
||||
{
|
||||
ourNumber,
|
||||
ourConversationId,
|
||||
noteToSelf,
|
||||
}
|
||||
);
|
||||
|
@ -271,9 +271,12 @@ async function queryMessages(query: string, searchConversationId?: string) {
|
|||
|
||||
async function queryConversationsAndContacts(
|
||||
providedQuery: string,
|
||||
options: { ourNumber: string; noteToSelf: string }
|
||||
options: {
|
||||
ourConversationId: string;
|
||||
noteToSelf: string;
|
||||
}
|
||||
) {
|
||||
const { ourNumber, noteToSelf } = options;
|
||||
const { ourConversationId, noteToSelf } = options;
|
||||
const query = providedQuery.replace(/[+-.()]*/g, '');
|
||||
|
||||
const searchResults: Array<DBConversationType> = await dataSearchConversations(
|
||||
|
@ -294,13 +297,20 @@ async function queryConversationsAndContacts(
|
|||
}
|
||||
}
|
||||
|
||||
// // @ts-ignore
|
||||
// console._log(
|
||||
// '%cqueryConversationsAndContacts',
|
||||
// 'background:black;color:red;',
|
||||
// { searchResults, conversations, ourNumber, ourUuid }
|
||||
// );
|
||||
|
||||
// Inject synthetic Note to Self entry if query matches localized 'Note to Self'
|
||||
if (noteToSelf.indexOf(providedQuery.toLowerCase()) !== -1) {
|
||||
// ensure that we don't have duplicates in our results
|
||||
contacts = contacts.filter(id => id !== ourNumber);
|
||||
conversations = conversations.filter(id => id !== ourNumber);
|
||||
contacts = contacts.filter(id => id !== ourConversationId);
|
||||
conversations = conversations.filter(id => id !== ourConversationId);
|
||||
|
||||
contacts.unshift(ourNumber);
|
||||
contacts.unshift(ourConversationId);
|
||||
}
|
||||
|
||||
return { conversations, contacts };
|
||||
|
|
|
@ -6,6 +6,8 @@ export type UserStateType = {
|
|||
attachmentsPath: string;
|
||||
stickersPath: string;
|
||||
tempPath: string;
|
||||
ourConversationId: string;
|
||||
ourUuid: string;
|
||||
ourNumber: string;
|
||||
platform: string;
|
||||
regionCode: string;
|
||||
|
@ -18,6 +20,8 @@ export type UserStateType = {
|
|||
type UserChangedActionType = {
|
||||
type: 'USER_CHANGED';
|
||||
payload: {
|
||||
ourConversationId?: string;
|
||||
ourUuid?: string;
|
||||
ourNumber?: string;
|
||||
regionCode?: string;
|
||||
interactionMode?: 'mouse' | 'keyboard';
|
||||
|
@ -34,7 +38,9 @@ export const actions = {
|
|||
|
||||
function userChanged(attributes: {
|
||||
interactionMode?: 'mouse' | 'keyboard';
|
||||
ourConversationId: string;
|
||||
ourNumber: string;
|
||||
ourUuid: string;
|
||||
regionCode: string;
|
||||
}): UserChangedActionType {
|
||||
return {
|
||||
|
@ -50,6 +56,8 @@ function getEmptyState(): UserStateType {
|
|||
attachmentsPath: 'missing',
|
||||
stickersPath: 'missing',
|
||||
tempPath: 'missing',
|
||||
ourConversationId: 'missing',
|
||||
ourUuid: 'missing',
|
||||
ourNumber: 'missing',
|
||||
regionCode: 'missing',
|
||||
platform: 'missing',
|
||||
|
|
|
@ -22,6 +22,7 @@ import {
|
|||
getInteractionMode,
|
||||
getIntl,
|
||||
getRegionCode,
|
||||
getUserConversationId,
|
||||
getUserNumber,
|
||||
} from './user';
|
||||
|
||||
|
@ -181,9 +182,12 @@ export const getLeftPaneLists = createSelector(
|
|||
);
|
||||
|
||||
export const getMe = createSelector(
|
||||
[getConversationLookup, getUserNumber],
|
||||
(lookup: ConversationLookupType, ourNumber: string): ConversationType => {
|
||||
return lookup[ourNumber];
|
||||
[getConversationLookup, getUserConversationId],
|
||||
(
|
||||
lookup: ConversationLookupType,
|
||||
ourConversationId: string
|
||||
): ConversationType => {
|
||||
return lookup[ourConversationId];
|
||||
}
|
||||
);
|
||||
|
||||
|
|
|
@ -149,6 +149,7 @@ export const getSearchResults = createSelector(
|
|||
});
|
||||
contacts.forEach(id => {
|
||||
const data = lookup[id];
|
||||
|
||||
items.push({
|
||||
type: 'contact',
|
||||
data: {
|
||||
|
|
|
@ -17,6 +17,16 @@ export const getRegionCode = createSelector(
|
|||
(state: UserStateType): string => state.regionCode
|
||||
);
|
||||
|
||||
export const getUserConversationId = createSelector(
|
||||
getUser,
|
||||
(state: UserStateType): string => state.ourConversationId
|
||||
);
|
||||
|
||||
export const getUserUuid = createSelector(
|
||||
getUser,
|
||||
(state: UserStateType): string => state.ourUuid
|
||||
);
|
||||
|
||||
export const getIntl = createSelector(
|
||||
getUser,
|
||||
(state: UserStateType): LocalizerType => state.i18n
|
||||
|
|
|
@ -10,7 +10,13 @@ import {
|
|||
getSearchConversationName,
|
||||
getStartSearchCounter,
|
||||
} from '../selectors/search';
|
||||
import { getIntl, getRegionCode, getUserNumber } from '../selectors/user';
|
||||
import {
|
||||
getIntl,
|
||||
getRegionCode,
|
||||
getUserConversationId,
|
||||
getUserNumber,
|
||||
getUserUuid,
|
||||
} from '../selectors/user';
|
||||
import { getMe } from '../selectors/conversations';
|
||||
|
||||
const mapStateToProps = (state: StateType) => {
|
||||
|
@ -20,7 +26,9 @@ const mapStateToProps = (state: StateType) => {
|
|||
searchConversationName: getSearchConversationName(state),
|
||||
startSearchCounter: getStartSearchCounter(state),
|
||||
regionCode: getRegionCode(state),
|
||||
ourConversationId: getUserConversationId(state),
|
||||
ourNumber: getUserNumber(state),
|
||||
ourUuid: getUserUuid(state),
|
||||
...getMe(state),
|
||||
i18n: getIntl(state),
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue