Display SMS/MMS disclaimer in empty search results
This commit is contained in:
parent
d1d53b645d
commit
80da8bb47b
10 changed files with 113 additions and 16 deletions
|
@ -739,6 +739,10 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"noSearchResults--sms-only": {
|
||||
"message": "SMS/MMS contacts are not available on Desktop.",
|
||||
"description": "Shown in the search left pane when no results were found and primary device has SMS/MMS handling enabled"
|
||||
},
|
||||
"noSearchResultsInConversation": {
|
||||
"message": "No results for \"$searchTerm$\" in $conversationName$",
|
||||
"description": "Shown in the search left pane when no results were found",
|
||||
|
|
|
@ -129,4 +129,5 @@ message AccountRecord {
|
|||
optional PhoneNumberSharingMode phoneNumberSharingMode = 12;
|
||||
optional bool notDiscoverableByPhoneNumber = 13;
|
||||
repeated PinnedConversation pinnedConversations = 14;
|
||||
optional bool primarySendsSms = 18;
|
||||
}
|
||||
|
|
|
@ -7331,6 +7331,16 @@ button.module-image__border-overlay:focus {
|
|||
outline: none;
|
||||
}
|
||||
|
||||
.module-left-pane__no-search-results__sms-only {
|
||||
margin-top: 12px;
|
||||
@include light-theme {
|
||||
color: $color-gray-60;
|
||||
}
|
||||
@include dark-theme {
|
||||
color: $color-gray-25;
|
||||
}
|
||||
}
|
||||
|
||||
.module-left-pane__compose-search-form {
|
||||
&__input {
|
||||
flex-grow: 1;
|
||||
|
|
|
@ -249,6 +249,22 @@ story.add('Search: no results when searching everywhere', () => (
|
|||
contactResults: emptySearchResultsGroup,
|
||||
messageResults: emptySearchResultsGroup,
|
||||
searchTerm: 'foo bar',
|
||||
primarySendsSms: false,
|
||||
},
|
||||
})}
|
||||
/>
|
||||
));
|
||||
|
||||
story.add('Search: no results when searching everywhere (SMS)', () => (
|
||||
<LeftPane
|
||||
{...createProps({
|
||||
modeSpecificProps: {
|
||||
mode: LeftPaneMode.Search,
|
||||
conversationResults: emptySearchResultsGroup,
|
||||
contactResults: emptySearchResultsGroup,
|
||||
messageResults: emptySearchResultsGroup,
|
||||
searchTerm: 'foo bar',
|
||||
primarySendsSms: true,
|
||||
},
|
||||
})}
|
||||
/>
|
||||
|
@ -264,6 +280,7 @@ story.add('Search: no results when searching in a conversation', () => (
|
|||
messageResults: emptySearchResultsGroup,
|
||||
searchConversationName: 'Bing Bong',
|
||||
searchTerm: 'foo bar',
|
||||
primarySendsSms: false,
|
||||
},
|
||||
})}
|
||||
/>
|
||||
|
@ -278,6 +295,7 @@ story.add('Search: all results loading', () => (
|
|||
contactResults: { isLoading: true },
|
||||
messageResults: { isLoading: true },
|
||||
searchTerm: 'foo bar',
|
||||
primarySendsSms: false,
|
||||
},
|
||||
})}
|
||||
/>
|
||||
|
@ -295,6 +313,7 @@ story.add('Search: some results loading', () => (
|
|||
contactResults: { isLoading: true },
|
||||
messageResults: { isLoading: true },
|
||||
searchTerm: 'foo bar',
|
||||
primarySendsSms: false,
|
||||
},
|
||||
})}
|
||||
/>
|
||||
|
@ -312,6 +331,7 @@ story.add('Search: has conversations and contacts, but not messages', () => (
|
|||
contactResults: { isLoading: false, results: defaultConversations },
|
||||
messageResults: { isLoading: false, results: [] },
|
||||
searchTerm: 'foo bar',
|
||||
primarySendsSms: false,
|
||||
},
|
||||
})}
|
||||
/>
|
||||
|
@ -335,6 +355,7 @@ story.add('Search: all results', () => (
|
|||
],
|
||||
},
|
||||
searchTerm: 'foo bar',
|
||||
primarySendsSms: false,
|
||||
},
|
||||
})}
|
||||
/>
|
||||
|
|
|
@ -31,6 +31,7 @@ export type LeftPaneSearchPropsType = {
|
|||
conversationId: string;
|
||||
}>;
|
||||
searchConversationName?: string;
|
||||
primarySendsSms: boolean;
|
||||
searchTerm: string;
|
||||
};
|
||||
|
||||
|
@ -50,6 +51,8 @@ export class LeftPaneSearchHelper extends LeftPaneHelper<LeftPaneSearchPropsType
|
|||
|
||||
private readonly searchConversationName?: string;
|
||||
|
||||
private readonly primarySendsSms: boolean;
|
||||
|
||||
private readonly searchTerm: string;
|
||||
|
||||
constructor({
|
||||
|
@ -57,6 +60,7 @@ export class LeftPaneSearchHelper extends LeftPaneHelper<LeftPaneSearchPropsType
|
|||
contactResults,
|
||||
messageResults,
|
||||
searchConversationName,
|
||||
primarySendsSms,
|
||||
searchTerm,
|
||||
}: Readonly<LeftPaneSearchPropsType>) {
|
||||
super();
|
||||
|
@ -65,6 +69,7 @@ export class LeftPaneSearchHelper extends LeftPaneHelper<LeftPaneSearchPropsType
|
|||
this.contactResults = contactResults;
|
||||
this.messageResults = messageResults;
|
||||
this.searchConversationName = searchConversationName;
|
||||
this.primarySendsSms = primarySendsSms;
|
||||
this.searchTerm = searchTerm;
|
||||
}
|
||||
|
||||
|
@ -78,7 +83,34 @@ export class LeftPaneSearchHelper extends LeftPaneHelper<LeftPaneSearchPropsType
|
|||
return null;
|
||||
}
|
||||
|
||||
const { searchConversationName, searchTerm } = this;
|
||||
const { searchConversationName, primarySendsSms, searchTerm } = this;
|
||||
|
||||
let noResults: ReactChild;
|
||||
if (searchConversationName) {
|
||||
noResults = (
|
||||
<Intl
|
||||
id="noSearchResultsInConversation"
|
||||
i18n={i18n}
|
||||
components={{
|
||||
searchTerm,
|
||||
conversationName: (
|
||||
<Emojify key="item-1" text={searchConversationName} />
|
||||
),
|
||||
}}
|
||||
/>
|
||||
);
|
||||
} else {
|
||||
noResults = (
|
||||
<>
|
||||
<div>{i18n('noSearchResults', [searchTerm])}</div>
|
||||
{primarySendsSms && (
|
||||
<div className="module-left-pane__no-search-results__sms-only">
|
||||
{i18n('noSearchResults--sms-only')}
|
||||
</div>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
return !searchConversationName || searchTerm ? (
|
||||
<div
|
||||
|
@ -87,20 +119,7 @@ export class LeftPaneSearchHelper extends LeftPaneHelper<LeftPaneSearchPropsType
|
|||
className="module-left-pane__no-search-results"
|
||||
key={searchTerm}
|
||||
>
|
||||
{searchConversationName ? (
|
||||
<Intl
|
||||
id="noSearchResultsInConversation"
|
||||
i18n={i18n}
|
||||
components={{
|
||||
searchTerm,
|
||||
conversationName: (
|
||||
<Emojify key="item-1" text={searchConversationName} />
|
||||
),
|
||||
}}
|
||||
/>
|
||||
) : (
|
||||
i18n('noSearchResults', [searchTerm])
|
||||
)}
|
||||
{noResults}
|
||||
</div>
|
||||
) : null;
|
||||
}
|
||||
|
|
|
@ -177,6 +177,11 @@ export async function toAccountRecord(
|
|||
);
|
||||
accountRecord.linkPreviews = Boolean(window.storage.get('linkPreviews'));
|
||||
|
||||
const primarySendsSms = window.storage.get('primarySendsSms');
|
||||
if (primarySendsSms !== undefined) {
|
||||
accountRecord.primarySendsSms = Boolean(primarySendsSms);
|
||||
}
|
||||
|
||||
const PHONE_NUMBER_SHARING_MODE_ENUM =
|
||||
window.textsecure.protobuf.AccountRecord.PhoneNumberSharingMode;
|
||||
const phoneNumberSharingMode = parsePhoneNumberSharingMode(
|
||||
|
@ -805,6 +810,7 @@ export async function mergeAccountRecord(
|
|||
readReceipts,
|
||||
sealedSenderIndicators,
|
||||
typingIndicators,
|
||||
primarySendsSms,
|
||||
} = accountRecord;
|
||||
|
||||
window.storage.put('read-receipt-setting', readReceipts);
|
||||
|
@ -821,6 +827,10 @@ export async function mergeAccountRecord(
|
|||
window.storage.put('linkPreviews', linkPreviews);
|
||||
}
|
||||
|
||||
if (typeof primarySendsSms === 'boolean') {
|
||||
window.storage.put('primarySendsSms', primarySendsSms);
|
||||
}
|
||||
|
||||
const PHONE_NUMBER_SHARING_MODE_ENUM =
|
||||
window.textsecure.protobuf.AccountRecord.PhoneNumberSharingMode;
|
||||
let phoneNumberSharingModeToStore: PhoneNumberSharingMode;
|
||||
|
|
|
@ -72,7 +72,7 @@ export const getSearchResults = createSelector(
|
|||
(
|
||||
state: SearchStateType,
|
||||
conversationLookup: ConversationLookupType
|
||||
): LeftPaneSearchPropsType => {
|
||||
): Omit<LeftPaneSearchPropsType, 'primarySendsSms'> => {
|
||||
const {
|
||||
contactIds,
|
||||
conversationIds,
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
import React, { CSSProperties } from 'react';
|
||||
import { connect } from 'react-redux';
|
||||
import { get } from 'lodash';
|
||||
import { mapDispatchToProps } from '../actions';
|
||||
import {
|
||||
LeftPane,
|
||||
|
@ -88,8 +89,13 @@ const getModeSpecificProps = (
|
|||
};
|
||||
}
|
||||
if (isSearching(state)) {
|
||||
const primarySendsSms = Boolean(
|
||||
get(state.items, ['primarySendsSms'], false)
|
||||
);
|
||||
|
||||
return {
|
||||
mode: LeftPaneMode.Search,
|
||||
primarySendsSms,
|
||||
...getSearchResults(state),
|
||||
};
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@ describe('LeftPaneSearchHelper', () => {
|
|||
contactResults: { isLoading: false, results: [] },
|
||||
messageResults: { isLoading: false, results: [] },
|
||||
searchTerm: 'foo',
|
||||
primarySendsSms: false,
|
||||
});
|
||||
|
||||
assert.isUndefined(
|
||||
|
@ -42,6 +43,7 @@ describe('LeftPaneSearchHelper', () => {
|
|||
contactResults: { isLoading: true },
|
||||
messageResults: { isLoading: true },
|
||||
searchTerm: 'foo',
|
||||
primarySendsSms: false,
|
||||
}).getRowCount(),
|
||||
100
|
||||
);
|
||||
|
@ -54,6 +56,7 @@ describe('LeftPaneSearchHelper', () => {
|
|||
contactResults: { isLoading: true },
|
||||
messageResults: { isLoading: true },
|
||||
searchTerm: 'foo',
|
||||
primarySendsSms: false,
|
||||
}).getRowCount(),
|
||||
100
|
||||
);
|
||||
|
@ -63,6 +66,7 @@ describe('LeftPaneSearchHelper', () => {
|
|||
contactResults: { isLoading: true },
|
||||
messageResults: { isLoading: false, results: [fakeMessage()] },
|
||||
searchTerm: 'foo',
|
||||
primarySendsSms: false,
|
||||
}).getRowCount(),
|
||||
100
|
||||
);
|
||||
|
@ -74,6 +78,7 @@ describe('LeftPaneSearchHelper', () => {
|
|||
contactResults: { isLoading: false, results: [] },
|
||||
messageResults: { isLoading: false, results: [] },
|
||||
searchTerm: 'foo',
|
||||
primarySendsSms: false,
|
||||
});
|
||||
|
||||
assert.strictEqual(helper.getRowCount(), 0);
|
||||
|
@ -88,6 +93,7 @@ describe('LeftPaneSearchHelper', () => {
|
|||
contactResults: { isLoading: false, results: [] },
|
||||
messageResults: { isLoading: false, results: [fakeMessage()] },
|
||||
searchTerm: 'foo',
|
||||
primarySendsSms: false,
|
||||
});
|
||||
|
||||
assert.strictEqual(helper.getRowCount(), 5);
|
||||
|
@ -102,6 +108,7 @@ describe('LeftPaneSearchHelper', () => {
|
|||
contactResults: { isLoading: true },
|
||||
messageResults: { isLoading: true },
|
||||
searchTerm: 'foo',
|
||||
primarySendsSms: false,
|
||||
}),
|
||||
new LeftPaneSearchHelper({
|
||||
conversationResults: {
|
||||
|
@ -111,12 +118,14 @@ describe('LeftPaneSearchHelper', () => {
|
|||
contactResults: { isLoading: true },
|
||||
messageResults: { isLoading: true },
|
||||
searchTerm: 'foo',
|
||||
primarySendsSms: false,
|
||||
}),
|
||||
new LeftPaneSearchHelper({
|
||||
conversationResults: { isLoading: true },
|
||||
contactResults: { isLoading: true },
|
||||
messageResults: { isLoading: false, results: [fakeMessage()] },
|
||||
searchTerm: 'foo',
|
||||
primarySendsSms: false,
|
||||
}),
|
||||
];
|
||||
|
||||
|
@ -149,6 +158,7 @@ describe('LeftPaneSearchHelper', () => {
|
|||
contactResults: { isLoading: false, results: contacts },
|
||||
messageResults: { isLoading: false, results: messages },
|
||||
searchTerm: 'foo',
|
||||
primarySendsSms: false,
|
||||
});
|
||||
|
||||
assert.deepEqual(helper.getRow(0), {
|
||||
|
@ -197,6 +207,7 @@ describe('LeftPaneSearchHelper', () => {
|
|||
contactResults: { isLoading: false, results: contacts },
|
||||
messageResults: { isLoading: false, results: messages },
|
||||
searchTerm: 'foo',
|
||||
primarySendsSms: false,
|
||||
});
|
||||
|
||||
assert.deepEqual(helper.getRow(0), {
|
||||
|
@ -236,6 +247,7 @@ describe('LeftPaneSearchHelper', () => {
|
|||
contactResults: { isLoading: false, results: [] },
|
||||
messageResults: { isLoading: false, results: messages },
|
||||
searchTerm: 'foo',
|
||||
primarySendsSms: false,
|
||||
});
|
||||
|
||||
assert.deepEqual(helper.getRow(0), {
|
||||
|
@ -277,6 +289,7 @@ describe('LeftPaneSearchHelper', () => {
|
|||
contactResults: { isLoading: false, results: contacts },
|
||||
messageResults: { isLoading: false, results: [] },
|
||||
searchTerm: 'foo',
|
||||
primarySendsSms: false,
|
||||
});
|
||||
|
||||
assert.deepEqual(helper.getRow(0), {
|
||||
|
@ -310,6 +323,7 @@ describe('LeftPaneSearchHelper', () => {
|
|||
contactResults: { isLoading: true },
|
||||
messageResults: { isLoading: true },
|
||||
searchTerm: 'foo',
|
||||
primarySendsSms: false,
|
||||
}),
|
||||
new LeftPaneSearchHelper({
|
||||
conversationResults: {
|
||||
|
@ -319,12 +333,14 @@ describe('LeftPaneSearchHelper', () => {
|
|||
contactResults: { isLoading: true },
|
||||
messageResults: { isLoading: true },
|
||||
searchTerm: 'foo',
|
||||
primarySendsSms: false,
|
||||
}),
|
||||
new LeftPaneSearchHelper({
|
||||
conversationResults: { isLoading: true },
|
||||
contactResults: { isLoading: true },
|
||||
messageResults: { isLoading: false, results: [fakeMessage()] },
|
||||
searchTerm: 'foo',
|
||||
primarySendsSms: false,
|
||||
}),
|
||||
];
|
||||
|
||||
|
@ -345,6 +361,7 @@ describe('LeftPaneSearchHelper', () => {
|
|||
results: [fakeMessage(), fakeMessage(), fakeMessage()],
|
||||
},
|
||||
searchTerm: 'foo',
|
||||
primarySendsSms: false,
|
||||
});
|
||||
assert.isTrue(helper.isScrollable());
|
||||
});
|
||||
|
@ -363,6 +380,7 @@ describe('LeftPaneSearchHelper', () => {
|
|||
results: [fakeMessage(), fakeMessage(), fakeMessage()],
|
||||
},
|
||||
searchTerm: 'foo',
|
||||
primarySendsSms: false,
|
||||
});
|
||||
|
||||
assert.isFalse(
|
||||
|
@ -377,6 +395,7 @@ describe('LeftPaneSearchHelper', () => {
|
|||
results: [fakeMessage(), fakeMessage(), fakeMessage()],
|
||||
},
|
||||
searchTerm: 'bar',
|
||||
primarySendsSms: false,
|
||||
})
|
||||
);
|
||||
});
|
||||
|
@ -387,6 +406,7 @@ describe('LeftPaneSearchHelper', () => {
|
|||
contactResults: { isLoading: true },
|
||||
messageResults: { isLoading: true },
|
||||
searchTerm: 'foo',
|
||||
primarySendsSms: false,
|
||||
});
|
||||
|
||||
assert.isFalse(
|
||||
|
@ -398,6 +418,7 @@ describe('LeftPaneSearchHelper', () => {
|
|||
contactResults: { isLoading: true },
|
||||
messageResults: { isLoading: true },
|
||||
searchTerm: 'bar',
|
||||
primarySendsSms: false,
|
||||
})
|
||||
);
|
||||
});
|
||||
|
@ -408,6 +429,7 @@ describe('LeftPaneSearchHelper', () => {
|
|||
contactResults: { isLoading: true },
|
||||
messageResults: { isLoading: false, results: [fakeMessage()] },
|
||||
searchTerm: 'foo',
|
||||
primarySendsSms: false,
|
||||
});
|
||||
|
||||
assert.isTrue(
|
||||
|
@ -419,6 +441,7 @@ describe('LeftPaneSearchHelper', () => {
|
|||
contactResults: { isLoading: false, results: [] },
|
||||
messageResults: { isLoading: false, results: [fakeMessage()] },
|
||||
searchTerm: 'foo',
|
||||
primarySendsSms: false,
|
||||
})
|
||||
);
|
||||
});
|
||||
|
@ -432,6 +455,7 @@ describe('LeftPaneSearchHelper', () => {
|
|||
contactResults: { isLoading: false, results: [] },
|
||||
messageResults: { isLoading: false, results: [] },
|
||||
searchTerm: 'foo',
|
||||
primarySendsSms: false,
|
||||
});
|
||||
|
||||
assert.isTrue(
|
||||
|
@ -443,6 +467,7 @@ describe('LeftPaneSearchHelper', () => {
|
|||
contactResults: { isLoading: true },
|
||||
messageResults: { isLoading: true },
|
||||
searchTerm: 'bar',
|
||||
primarySendsSms: false,
|
||||
})
|
||||
);
|
||||
});
|
||||
|
|
1
ts/textsecure.d.ts
vendored
1
ts/textsecure.d.ts
vendored
|
@ -1060,6 +1060,7 @@ export declare class AccountRecordClass {
|
|||
notDiscoverableByPhoneNumber?: boolean;
|
||||
pinnedConversations?: PinnedConversationClass[];
|
||||
noteToSelfMarkedUnread?: boolean;
|
||||
primarySendsSms?: boolean;
|
||||
|
||||
__unknownFields?: ArrayBuffer;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue