diff --git a/_locales/en/messages.json b/_locales/en/messages.json index e47117dd9..cbc2489a9 100644 --- a/_locales/en/messages.json +++ b/_locales/en/messages.json @@ -674,10 +674,6 @@ "message": "Conversations", "description": "Shown to separate the types of search results" }, - "friendsHeader": { - "message": "Friends", - "description": "Shown to separate the types of search results" - }, "contactsHeader": { "message": "Contacts", "description": "Shown to separate the types of search results" @@ -991,18 +987,6 @@ "message": " Type your message", "description": "Placeholder text in the message entry field" }, - "sendMessageDisabledSecondary": { - "message": "This pubkey belongs to a secondary device. You should never see this message", - "description": "Placeholder text in the message entry field when it is disabled because a secondary device conversation is visible" - }, - "sendMessageDisabled": { - "message": "Waiting for friend request approval", - "description": "Placeholder text in the message entry field when it is disabled while we are waiting for a friend request approval" - }, - "sendMessageFriendRequest": { - "message": "Send your first message", - "description": "Placeholder text in the message entry field when it is the first message sent to that contact" - }, "sendMessageLeftGroup": { "message": "You left this group" }, @@ -1860,50 +1844,6 @@ } } }, - "friendRequestPending": { - "message": "Friend request", - "description": "Shown in the conversation history when the user sends or recieves a friend request" - }, - "friendRequestAccepted": { - "message": "Friend request accepted", - "description": "Shown in the conversation history when the user accepts a friend request" - }, - "friendRequestDeclined": { - "message": "Session request declined", - "description": "Shown in the conversation history when the user declines a friend request" - }, - "friendRequestExpired": { - "message": "Friend request expired", - "description": "Shown in the conversation history when the users friend request expires" - }, - "friendRequestNotificationTitle": { - "message": "Friend request", - "description": "Shown in a notification title when receiving a friend request" - }, - "friendRequestNotificationMessage": { - "message": "$name$ sent you a friend request", - "description": "Shown in a notification body when receiving a friend request", - "placeholders": { - "name": { - "content": "$1", - "example": "Bob" - } - } - }, - "friendRequestAcceptedNotificationTitle": { - "message": "Friend request accepted", - "description": "Shown in a notification title when friend request was accepted by the other user" - }, - "friendRequestAcceptedNotificationMessage": { - "message": "$name$ accepted your friend request", - "description": "Shown in a notification body when friend request was accepted by the other user", - "placeholders": { - "name": { - "content": "$1", - "example": "Bob" - } - } - }, "blockUser": { "message": "Block User" }, @@ -2270,18 +2210,6 @@ "message": "Conversations", "description": "conversation tab title" }, - "friendsTab": { - "message": "Friends", - "description": "friend tab title" - }, - "pendingAcceptance": { - "message": "Pending Acceptance", - "description": "Indicates that a friend request is pending" - }, - "notFriends": { - "message": "Not Friends", - "description": "Indicates that a conversation is not friends with us" - }, "emptyGroupNameError": { "message": "Group Name cannot be empty", "description": "Error message displayed on empty group name" @@ -2326,11 +2254,11 @@ "groupInvitation": { "message": "Group Invitation" }, - "addingFriends": { - "message": "Adding friends to" + "addingContacts": { + "message": "Adding contacts to" }, - "noFriendsToAdd": { - "message": "No friends to add" + "noContactsToAdd": { + "message": "No contacts to add" }, "noMembersInThisGroup": { "message": "No other members in this group" @@ -2534,9 +2462,6 @@ "displayNameEmpty": { "message": "Display Name Is Mandatory" }, - "youHaveFriendRequestFrom": { - "message": "You have friend requests from..." - }, "members": { "message": "$count$ members", "placeholders": { diff --git a/js/models/conversations.js b/js/models/conversations.js index c2cca00a8..6ecf74d29 100644 --- a/js/models/conversations.js +++ b/js/models/conversations.js @@ -1341,10 +1341,7 @@ if (this.isMe()) { return message.sendSyncMessageOnly(chatMessage); } - const options = {}; - options.messageType = message.get('type'); - options.isPublic = this.isPublic(); if (this.isPublic()) { const openGroup = this.toOpenGroup(); @@ -1365,7 +1362,6 @@ return null; } - options.sessionRestoration = sessionRestoration; const destinationPubkey = new libsession.Types.PubKey(destination); // Handle Group Invitation Message if (groupInvitation) { diff --git a/js/models/messages.js b/js/models/messages.js index 15abc5ca2..777825217 100644 --- a/js/models/messages.js +++ b/js/models/messages.js @@ -264,8 +264,20 @@ /* eslint-enable no-bitwise */ }, getNotificationText() { - const description = this.getDescription(); + let description = this.getDescription(); if (description) { + // regex with a 'g' to ignore part groups + const regex = new RegExp( + `@${window.libsession.Types.PubKey.regexForPubkeys}`, + 'g' + ); + const pubkeysInDesc = description.match(regex); + (pubkeysInDesc || []).forEach(pubkey => { + const displayName = this.getLokiNameForNumber(pubkey.slice(1)); + if (displayName && displayName.length) { + description = description.replace(pubkey, `@${displayName}`); + } + }); return description; } if (this.get('attachments').length > 0) { diff --git a/js/views/conversation_view.js b/js/views/conversation_view.js index 2a7fa5e2b..8982e52cd 100644 --- a/js/views/conversation_view.js +++ b/js/views/conversation_view.js @@ -529,12 +529,6 @@ } let placeholder; switch (type) { - case 'disabled': - placeholder = i18n('sendMessageDisabled'); - break; - case 'secondary': - placeholder = i18n('sendMessageDisabledSecondary'); - break; case 'left-group': placeholder = i18n('sendMessageLeftGroup'); break; diff --git a/stylesheets/_mentions.scss b/stylesheets/_mentions.scss index eded63c8b..c32a70d55 100644 --- a/stylesheets/_mentions.scss +++ b/stylesheets/_mentions.scss @@ -184,11 +184,11 @@ } .module-conversation-list-item--mentioned-us { - border-left: 4px solid #ffb000 !important; + border-left: 4px solid $session-color-green !important; } .at-symbol { - background-color: #ffb000; + background-color: $session-color-green; color: $color-black; text-align: center; @@ -198,8 +198,9 @@ padding-right: 3px; position: absolute; - right: -6px; - top: 12px; + left: 50%; + margin-left: 30px; + top: 2px; font-weight: 300; font-size: 11px; diff --git a/ts/components/SearchResults.tsx b/ts/components/SearchResults.tsx index 3c9bb1a35..8f7f39c09 100644 --- a/ts/components/SearchResults.tsx +++ b/ts/components/SearchResults.tsx @@ -72,7 +72,7 @@ export class SearchResults extends React.Component { ) : null} {haveContacts - ? this.renderContacts(i18n('friendsHeader'), contacts, true) + ? this.renderContacts(i18n('contactsHeader'), contacts, true) : null} {haveMessages ? ( diff --git a/ts/components/conversation/AddMentions.tsx b/ts/components/conversation/AddMentions.tsx index 26c079ee1..23c82833d 100644 --- a/ts/components/conversation/AddMentions.tsx +++ b/ts/components/conversation/AddMentions.tsx @@ -3,6 +3,7 @@ import React from 'react'; import { RenderTextCallbackType } from '../../types/Util'; import classNames from 'classnames'; import { MultiDeviceProtocol } from '../../session/protocols'; +import { FindMember } from '../../util'; declare global { interface Window { @@ -72,7 +73,12 @@ class Mention extends React.Component { } private async tryRenameMention() { - const found = await this.findMember(this.props.text.slice(1)); + const bound = this.clearOurInterval.bind(this); + const found = await FindMember.findMember( + this.props.text.slice(1), + this.props.convoId, + bound + ); if (found) { const us = await MultiDeviceProtocol.isOurDevice(found.authorPhoneNumber); @@ -80,55 +86,6 @@ class Mention extends React.Component { this.clearOurInterval(); } } - - private async findMember(pubkey: String) { - let groupMembers; - - const groupConvos = window.getConversations().models.filter((d: any) => { - return !d.isPrivate(); - }); - const thisConvo = groupConvos.find((d: any) => { - return d.id === this.props.convoId; - }); - - if (!thisConvo) { - // If this gets triggered, is is likely because we deleted the conversation - this.clearOurInterval(); - - return; - } - - if (thisConvo.isPublic()) { - groupMembers = await window.lokiPublicChatAPI.getListOfMembers(); - groupMembers = groupMembers.filter((m: any) => !!m); - } else { - const privateConvos = window - .getConversations() - .models.filter((d: any) => d.isPrivate()); - const members = thisConvo.attributes.members; - if (!members) { - return null; - } - const memberConversations = members - .map((m: any) => privateConvos.find((c: any) => c.id === m)) - .filter((c: any) => !!c); - groupMembers = memberConversations.map((m: any) => { - const name = m.getLokiProfile() - ? m.getLokiProfile().displayName - : m.attributes.displayName; - - return { - id: m.id, - authorPhoneNumber: m.id, - authorProfileName: name, - }; - }); - } - - return groupMembers.find( - ({ authorPhoneNumber: pn }: any) => pn && pn === pubkey - ); - } } interface Props { diff --git a/ts/components/conversation/InviteContactsDialog.tsx b/ts/components/conversation/InviteContactsDialog.tsx index 1741978fd..721fd4be5 100644 --- a/ts/components/conversation/InviteContactsDialog.tsx +++ b/ts/components/conversation/InviteContactsDialog.tsx @@ -58,7 +58,7 @@ export class InviteContactsDialog extends React.Component { } public render() { - const titleText = `${window.i18n('addingFriends')} ${this.props.chatName}`; + const titleText = `${window.i18n('addingContacts')} ${this.props.chatName}`; const cancelText = window.i18n('cancel'); const okText = window.i18n('ok'); @@ -76,7 +76,7 @@ export class InviteContactsDialog extends React.Component { {hasContacts ? null : ( <>
-

{window.i18n('noFriendsToAdd')}

+

{window.i18n('noContactsToAdd')}

)} diff --git a/ts/components/conversation/ModeratorsAddDialog.tsx b/ts/components/conversation/ModeratorsAddDialog.tsx index 61c603fcf..6a9e19129 100644 --- a/ts/components/conversation/ModeratorsAddDialog.tsx +++ b/ts/components/conversation/ModeratorsAddDialog.tsx @@ -157,7 +157,7 @@ export class AddModeratorsDialog extends React.Component { />
{hasContacts ? null : ( -

{i18n('noFriendsToAdd')}

+

{i18n('noContactsToAdd')}

)}
diff --git a/ts/session/types/PubKey.ts b/ts/session/types/PubKey.ts index 06d07e94d..d3fbb7c0c 100644 --- a/ts/session/types/PubKey.ts +++ b/ts/session/types/PubKey.ts @@ -4,14 +4,16 @@ export class PubKey { // They have a different regex to match // FIXME move this to a new class which validates group ids and use it in all places where we have group ids (message sending included) public static readonly MOBILE_GROUP_PUBKEY_LEN = 32; + public static readonly regexForPubkeys = `((05)?[0-9a-fA-F]{${PubKey.PUBKEY_LEN - + 2}})`; private static readonly regexForMobileGroupID = `__textsecure_group__![0-9a-fA-F]{${PubKey.MOBILE_GROUP_PUBKEY_LEN}}`; // prettier-ignore - private static readonly regexForPubkeys = `((05)?[0-9a-fA-F]{${PubKey.PUBKEY_LEN - 2}})`; private static readonly regex: RegExp = new RegExp( `^${PubKey.regexForPubkeys}|${PubKey.regexForMobileGroupID}$` ); public readonly key: string; + /** * A PubKey object. * If `pubKeyString` is not valid then this will throw an `Error`. diff --git a/ts/session/utils/Attachments.ts b/ts/session/utils/Attachments.ts index 870c92dce..bcb22e458 100644 --- a/ts/session/utils/Attachments.ts +++ b/ts/session/utils/Attachments.ts @@ -75,6 +75,7 @@ export class AttachmentUtils { size: attachment.size, fileName: attachment.fileName, flags: attachment.flags, + caption: attachment.caption, }; let attachmentData: ArrayBuffer; diff --git a/ts/types/Attachment.ts b/ts/types/Attachment.ts index cc4a3752d..43dfcd4ba 100644 --- a/ts/types/Attachment.ts +++ b/ts/types/Attachment.ts @@ -250,6 +250,7 @@ export function getAlt( export type Attachment = { fileName?: string; + caption?: string; flags?: SignalService.AttachmentPointer.Flags; contentType?: MIME.MIMEType; size?: number; diff --git a/ts/util/findMember.ts b/ts/util/findMember.ts new file mode 100644 index 000000000..dbd7a6941 --- /dev/null +++ b/ts/util/findMember.ts @@ -0,0 +1,57 @@ +// tslint:disable: no-unnecessary-class +export class FindMember { + public static async findMember( + pubkey: String, + convoId: string, + clearOurInterval?: any + ) { + let groupMembers; + + const groupConvos = window.getConversations().models.filter((d: any) => { + return !d.isPrivate(); + }); + const thisConvo = groupConvos.find((d: any) => { + return d.id === convoId; + }); + + if (!thisConvo) { + // If this gets triggered, is is likely because we deleted the conversation + if (clearOurInterval) { + clearOurInterval(); + } + + return; + } + + if (thisConvo.isPublic()) { + groupMembers = await window.lokiPublicChatAPI.getListOfMembers(); + groupMembers = groupMembers.filter((m: any) => !!m); + } else { + const privateConvos = window + .getConversations() + .models.filter((d: any) => d.isPrivate()); + const members = thisConvo.attributes.members; + if (!members) { + return null; + } + const memberConversations = members + .map((m: any) => privateConvos.find((c: any) => c.id === m)) + .filter((c: any) => !!c); + groupMembers = memberConversations.map((m: any) => { + const name = m.getLokiProfile() + ? m.getLokiProfile().displayName + : m.attributes.displayName; + + return { + id: m.id, + authorPhoneNumber: m.id, + authorProfileName: name, + }; + }); + } + + return groupMembers.find( + ({ authorPhoneNumber: pn }: any) => pn && pn === pubkey + ); + } +} diff --git a/ts/util/index.ts b/ts/util/index.ts index 699b5fcb8..b9b849e94 100644 --- a/ts/util/index.ts +++ b/ts/util/index.ts @@ -4,6 +4,7 @@ import { isFileDangerous } from './isFileDangerous'; import { missingCaseError } from './missingCaseError'; import { migrateColor } from './migrateColor'; import { makeLookup } from './makeLookup'; +import { FindMember } from './findMember'; import * as UserUtil from './user'; import * as PasswordUtil from './passwordUtils'; @@ -18,4 +19,5 @@ export { missingCaseError, UserUtil, PasswordUtil, + FindMember, };