Merge pull request #1292 from Bilb/fix-caption-attachments

pull/1296/head
Audric Ackermann 5 years ago committed by GitHub
commit ba624d5d2f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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": {

@ -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) {

@ -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) {

@ -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;

@ -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;

@ -72,7 +72,7 @@ export class SearchResults extends React.Component<Props> {
</div>
) : null}
{haveContacts
? this.renderContacts(i18n('friendsHeader'), contacts, true)
? this.renderContacts(i18n('contactsHeader'), contacts, true)
: null}
{haveMessages ? (

@ -2,6 +2,7 @@ import React from 'react';
import { RenderTextCallbackType } from '../../types/Util';
import classNames from 'classnames';
import { FindMember } from '../../util';
declare global {
interface Window {
@ -71,61 +72,17 @@ class Mention extends React.Component<MentionProps, MentionState> {
}
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) {
this.setState({ found });
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 {

@ -58,7 +58,7 @@ export class InviteContactsDialog extends React.Component<Props, State> {
}
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<Props, State> {
{hasContacts ? null : (
<>
<div className="spacer-lg" />
<p className="no-friends">{window.i18n('noFriendsToAdd')}</p>
<p className="no-friends">{window.i18n('noContactsToAdd')}</p>
<div className="spacer-lg" />
</>
)}

@ -157,7 +157,7 @@ export class AddModeratorsDialog extends React.Component<Props, State> {
/>
</div>
{hasContacts ? null : (
<p className="no-friends">{i18n('noFriendsToAdd')}</p>
<p className="no-friends">{i18n('noContactsToAdd')}</p>
)}
</div>
<div className="buttons">

@ -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`.

@ -75,6 +75,7 @@ export class AttachmentUtils {
size: attachment.size,
fileName: attachment.fileName,
flags: attachment.flags,
caption: attachment.caption,
};
let attachmentData: ArrayBuffer;

@ -250,6 +250,7 @@ export function getAlt(
export type Attachment = {
fileName?: string;
caption?: string;
flags?: SignalService.AttachmentPointer.Flags;
contentType?: MIME.MIMEType;
size?: number;

@ -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
);
}
}

@ -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';
export * from './blockedNumberController';
@ -16,4 +17,5 @@ export {
migrateColor,
missingCaseError,
UserUtil,
FindMember,
};

Loading…
Cancel
Save