Sort by inbox position to match phone after link
This commit is contained in:
parent
1f5cb9e8af
commit
4830213a12
25 changed files with 707 additions and 1029 deletions
|
@ -27,6 +27,7 @@ export type ConversationType = {
|
|||
isArchived: boolean;
|
||||
activeAt?: number;
|
||||
timestamp: number;
|
||||
inboxPosition: number;
|
||||
lastMessage?: {
|
||||
status: 'error' | 'sending' | 'sent' | 'delivered' | 'read';
|
||||
text: string;
|
||||
|
@ -56,7 +57,13 @@ export type MessageType = {
|
|||
id: string;
|
||||
conversationId: string;
|
||||
source: string;
|
||||
type: 'incoming' | 'outgoing' | 'group' | 'keychange' | 'verified-change';
|
||||
type:
|
||||
| 'incoming'
|
||||
| 'outgoing'
|
||||
| 'group'
|
||||
| 'keychange'
|
||||
| 'verified-change'
|
||||
| 'message-history-unsynced';
|
||||
quote?: { author: string };
|
||||
received_at: number;
|
||||
hasSignalAccount?: boolean;
|
||||
|
|
|
@ -117,6 +117,21 @@ export const _getConversationComparator = (
|
|||
return rightTimestamp - leftTimestamp;
|
||||
}
|
||||
|
||||
if (
|
||||
typeof left.inboxPosition === 'number' &&
|
||||
typeof right.inboxPosition === 'number'
|
||||
) {
|
||||
return right.inboxPosition > left.inboxPosition ? -1 : 1;
|
||||
}
|
||||
|
||||
if (typeof left.inboxPosition === 'number' && right.inboxPosition == null) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (typeof right.inboxPosition === 'number' && left.inboxPosition == null) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
const leftTitle = getConversationTitle(left, {
|
||||
i18n,
|
||||
ourRegionCode,
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import memoizee from 'memoizee';
|
||||
import { createSelector } from 'reselect';
|
||||
import { getSearchResultsProps } from '../../shims/Whisper';
|
||||
import { instance } from '../../util/libphonenumberInstance';
|
||||
|
||||
import { StateType } from '../reducer';
|
||||
|
||||
|
@ -20,7 +21,7 @@ import {
|
|||
} from '../../components/SearchResults';
|
||||
import { PropsDataType as MessageSearchResultPropsDataType } from '../../components/MessageSearchResult';
|
||||
|
||||
import { getRegionCode, getUserNumber } from './user';
|
||||
import { getRegionCode, getUserAgent, getUserNumber } from './user';
|
||||
import {
|
||||
GetConversationByIdType,
|
||||
getConversationLookup,
|
||||
|
@ -72,6 +73,7 @@ export const getSearchResults = createSelector(
|
|||
[
|
||||
getSearch,
|
||||
getRegionCode,
|
||||
getUserAgent,
|
||||
getConversationLookup,
|
||||
getSelectedConversation,
|
||||
getSelectedMessage,
|
||||
|
@ -79,6 +81,7 @@ export const getSearchResults = createSelector(
|
|||
(
|
||||
state: SearchStateType,
|
||||
regionCode: string,
|
||||
userAgent: string,
|
||||
lookup: ConversationLookupType,
|
||||
selectedConversationId?: string,
|
||||
selectedMessageId?: string
|
||||
|
@ -114,6 +117,17 @@ export const getSearchResults = createSelector(
|
|||
type: 'start-new-conversation',
|
||||
data: undefined,
|
||||
});
|
||||
|
||||
const isIOS = userAgent === 'OWI';
|
||||
const parsedNumber = instance.parse(state.query, regionCode);
|
||||
const isValidNumber = instance.isValidNumber(parsedNumber);
|
||||
|
||||
if (!isIOS && isValidNumber) {
|
||||
items.push({
|
||||
type: 'sms-mms-not-supported-text',
|
||||
data: undefined,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (haveConversations) {
|
||||
|
|
|
@ -4,9 +4,12 @@ import { LocalizerType } from '../../types/Util';
|
|||
|
||||
import { StateType } from '../reducer';
|
||||
import { UserStateType } from '../ducks/user';
|
||||
import { ItemsStateType } from '../ducks/items';
|
||||
|
||||
export const getUser = (state: StateType): UserStateType => state.user;
|
||||
|
||||
export const getItems = (state: StateType): ItemsStateType => state.items;
|
||||
|
||||
export const getUserNumber = createSelector(
|
||||
getUser,
|
||||
(state: UserStateType): string => state.ourNumber
|
||||
|
@ -27,6 +30,11 @@ export const getUserUuid = createSelector(
|
|||
(state: UserStateType): string => state.ourUuid
|
||||
);
|
||||
|
||||
export const getUserAgent = createSelector(
|
||||
getItems,
|
||||
(state: ItemsStateType): string => state.userAgent
|
||||
);
|
||||
|
||||
export const getIntl = createSelector(
|
||||
getUser,
|
||||
(state: UserStateType): LocalizerType => state.i18n
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue