Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Session 1.7.1 #1908

Merged
merged 3 commits into from
Sep 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 0 additions & 13 deletions libtextsecure/errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,18 +75,6 @@
appendStack(this, error);
}

function SeedNodeError(message) {
this.name = 'SeedNodeError';
this.message = message;
Error.call(this, message);

// Maintains proper stack trace, where our error was thrown (only available on V8)
// via https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error
if (Error.captureStackTrace) {
Error.captureStackTrace(this);
}
}

function HTTPError(message, response) {
this.name = 'HTTPError';
this.message = `${response.status} Error: ${message}`;
Expand Down Expand Up @@ -114,7 +102,6 @@
window.textsecure.SendMessageNetworkError = SendMessageNetworkError;
window.textsecure.ReplayableError = ReplayableError;
window.textsecure.EmptySwarmError = EmptySwarmError;
window.textsecure.SeedNodeError = SeedNodeError;
window.textsecure.HTTPError = HTTPError;
window.textsecure.NotFoundError = NotFoundError;
window.textsecure.TimestampError = TimestampError;
Expand Down
1 change: 0 additions & 1 deletion libtextsecure/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ export interface LibTextsecure {
SendMessageNetworkError: any;
ReplayableError: any;
EmptySwarmError: any;
SeedNodeError: any;
HTTPError: any;
NotFoundError: any;
TimestampError: any;
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "session-desktop",
"productName": "Session",
"description": "Private messaging from your desktop",
"version": "1.7.0",
"version": "1.7.1",
"license": "GPL-3.0",
"author": {
"name": "Loki Project",
Expand Down Expand Up @@ -35,7 +35,7 @@
"build-protobuf": "yarn build-module-protobuf",
"clean-protobuf": "yarn clean-module-protobuf",
"test": "yarn test-node",
"test-node": "mocha --recursive --exit --timeout 10000 test/app test/modules \"./ts/test/**/*_test.js\" ",
"test-node": "mocha --recursive --exit --timeout 10000 \"./ts/test/**/*_test.js\" ",
"eslint-full": "eslint .",
"lint-full": "yarn format-full && yarn lint-files-full",
"lint-files-full": "yarn eslint-full && yarn tslint",
Expand Down
15 changes: 7 additions & 8 deletions stylesheets/_modules.scss
Original file line number Diff line number Diff line change
Expand Up @@ -174,18 +174,12 @@

.module-message__link-preview {
cursor: pointer;
margin-inline-start: -12px;
margin-inline-end: -12px;
margin-top: -10px;
margin-bottom: 5px;
border-top-left-radius: $session_message-container-border-radius;
border-top-right-radius: $session_message-container-border-radius;
}

.module-message__link-preview__content {
padding: 8px;
border-top-left-radius: $session_message-container-border-radius;
border-top-right-radius: $session_message-container-border-radius;
background-color: $color-white;
display: flex;
flex-direction: row;
Expand Down Expand Up @@ -1027,8 +1021,12 @@
}

.module-image__image {
object-fit: cover;
object-fit: contain;
cursor: pointer;

&-cover {
object-fit: cover;
}
}

.module-image__bottom-overlay {
Expand Down Expand Up @@ -1489,9 +1487,10 @@

.module-staged-link-preview--is-loading {
align-items: center;
justify-content: center;
}
.module-staged-link-preview__loading {
color: var(--color-sent-message-text);
color: var(--color-text);

font-size: 14px;
text-align: center;
Expand Down
4 changes: 4 additions & 0 deletions stylesheets/_session.scss
Original file line number Diff line number Diff line change
Expand Up @@ -1281,6 +1281,10 @@ input {
}
}

.module-message__text {
white-space: pre-wrap;
}

.session-info-box {
display: flex;
flex-direction: column;
Expand Down
9 changes: 0 additions & 9 deletions stylesheets/_theme_dark.scss
Original file line number Diff line number Diff line change
Expand Up @@ -424,15 +424,6 @@

// Module: Staged Link Preview

.module-staged-link-preview__loading {
color: $color-gray-25;
}
.module-staged-link-preview__title {
color: $color-gray-05;
}
.module-staged-link-preview__location {
color: $color-gray-25;
}
.module-staged-link-preview__close-button {
@include color-svg('../images/x-16.svg', $color-gray-25);
}
Expand Down
23 changes: 18 additions & 5 deletions ts/components/conversation/Image.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ type Props = {
darkOverlay?: boolean;
playIconOverlay?: boolean;
softCorners?: boolean;
forceSquare?: boolean;

onClick?: (attachment: AttachmentTypeWithPath | AttachmentType) => void;
onClickClose?: (attachment: AttachmentTypeWithPath | AttachmentType) => void;
Expand All @@ -42,6 +43,7 @@ export const Image = (props: Props) => {
overlayText,
playIconOverlay,
softCorners,
forceSquare,
url,
width,
} = props;
Expand Down Expand Up @@ -84,13 +86,17 @@ export const Image = (props: Props) => {
canClick ? 'module-image__with-click-handler' : null,
softCorners ? 'module-image--soft-corners' : null
)}
style={{
maxHeight: `${height}px`,
maxWidth: `${width}px`,
}}
>
{pending || loading ? (
<div
className="module-image__loading-placeholder"
style={{
height: `${height}px`,
width: `${width}px`,
maxHeight: `${height}px`,
maxWidth: `${width}px`,
lineHeight: `${height}px`,
textAlign: 'center',
}}
Expand All @@ -100,10 +106,17 @@ export const Image = (props: Props) => {
) : (
<img
onError={onErrorUrlFilterering}
className="module-image__image"
className={classNames(
'module-image__image',
forceSquare ? 'module-image__image-cover' : ''
)}
alt={alt}
height={height}
width={width}
style={{
maxHeight: `${height}px`,
maxWidth: `${width}px`,
width: forceSquare ? `${width}px` : '',
height: forceSquare ? `${height}px` : '',
}}
src={srcData}
onDragStart={onDragStart}
/>
Expand Down
1 change: 1 addition & 0 deletions ts/components/conversation/StagedAttachmentList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ export const StagedAttachmentList = (props: Props) => {
playIconOverlay={isVideoAttachment(attachment)}
height={IMAGE_HEIGHT}
width={IMAGE_WIDTH}
forceSquare={true}
url={getUrl(attachment)}
closeButton={true}
onClick={clickCallback}
Expand Down
9 changes: 5 additions & 4 deletions ts/components/conversation/StagedLinkPreview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import classNames from 'classnames';
import { Image } from './Image';

import { AttachmentType, isImageAttachment } from '../../types/Attachment';
import { SessionSpinner } from '../session/SessionSpinner';

type Props = {
isLoaded: boolean;
Expand All @@ -24,16 +25,16 @@ export const StagedLinkPreview = (props: Props) => {
return <></>;
}

const isLoading = !isLoaded;

return (
<div
className={classNames(
'module-staged-link-preview',
!isLoaded ? 'module-staged-link-preview--is-loading' : null
isLoading ? 'module-staged-link-preview--is-loading' : null
)}
>
{!isLoaded ? (
<div className="module-staged-link-preview__loading">{window.i18n('loading')}</div>
) : null}
{isLoading ? <SessionSpinner loading={isLoading} /> : null}
{isLoaded && image && isImage ? (
<div className="module-staged-link-preview__icon-container">
<Image
Expand Down
28 changes: 27 additions & 1 deletion ts/components/conversation/message/ClickToTrustSender.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,14 @@ export const ClickToTrustSender = (props: { messageId: string }) => {
await Promise.all(
messagesInConvo.map(async message => {
const msgAttachments = message.get('attachments');
const messagePreviews = message.get('preview');
if (message.get('direction') !== 'incoming') {
return;
}
if (!msgAttachments || msgAttachments.length === 0) {
if (
(!msgAttachments || msgAttachments.length === 0) &&
(!messagePreviews || messagePreviews.length === 0)
) {
return;
}

Expand All @@ -72,6 +76,28 @@ export const ClickToTrustSender = (props: { messageId: string }) => {
})
);

const preview = await Promise.all(
(messagePreviews || []).map(async (item: any, index: any) => {
if (!item.image) {
return item;
}

const image = message.isTrustedForAttachmentDownload()
? await AttachmentDownloads.addJob(item.image, {
messageId: message.id,
type: 'preview',
index,
isOpenGroupV2: false,
openGroupV2Details: undefined,
})
: null;

return { ...item, image };
})
);

message.set({ preview });

message.set({ attachments: downloadedAttachments });
await message.commit();
})
Expand Down
8 changes: 5 additions & 3 deletions ts/components/conversation/message/MessageContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -177,10 +177,12 @@ export const MessageContent = (props: Props) => {
handleImageError={handleImageError}
/>
{hasContentAfterAttachmentAndQuote ? (
<Flex padding="7px" container={true} flexDirection="column">
<>
<MessagePreview messageId={props.messageId} handleImageError={handleImageError} />
<MessageText messageId={props.messageId} />
</Flex>
<Flex padding="7px" container={true} flexDirection="column">
<MessageText messageId={props.messageId} />
</Flex>
</>
) : null}
</IsMessageVisibleContext.Provider>
</InView>
Expand Down
20 changes: 12 additions & 8 deletions ts/components/session/ActionsPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,19 @@ import {
removeConversation,
removeOneOpenGroupV1Message,
} from '../../data/data';
import { OnionPaths } from '../../session/onions';
import { getMessageQueue } from '../../session/sending';
import { useDispatch, useSelector } from 'react-redux';
// tslint:disable: no-submodule-imports
import useInterval from 'react-use/lib/useInterval';
import useTimeoutFn from 'react-use/lib/useTimeoutFn';

import { getOurNumber } from '../../state/selectors/user';
import {
getOurPrimaryConversation,
getUnreadMessageCount,
} from '../../state/selectors/conversations';
import { applyTheme } from '../../state/ducks/theme';
import { getFocusedSection } from '../../state/selectors/section';
import { useInterval } from '../../hooks/useInterval';
import { clearSearch } from '../../state/ducks/search';
import { SectionType, showLeftPaneSection } from '../../state/ducks/section';

Expand Down Expand Up @@ -204,11 +206,6 @@ const triggerAvatarReUploadIfNeeded = async () => {
* This function is called only once: on app startup with a logged in user
*/
const doAppStartUp = () => {
if (window.lokiFeatureFlags.useOnionRequests || window.lokiFeatureFlags.useFileOnionRequests) {
// Initialize paths for onion requests
void OnionPaths.buildNewOnionPathsOneAtATime();
}

// init the messageQueue. In the constructor, we add all not send messages
// this call does nothing except calling the constructor, which will continue sending message in the pipeline
void getMessageQueue().processAllPending();
Expand Down Expand Up @@ -271,8 +268,15 @@ export const ActionsPanel = () => {
}, DURATION.DAYS * 2);

useInterval(() => {
// trigger an updates from the snodes every hour

void forceRefreshRandomSnodePool();
}, DURATION.DAYS * 1);
}, DURATION.HOURS * 1);

useTimeoutFn(() => {
// trigger an updates from the snodes after 5 minutes, once
void forceRefreshRandomSnodePool();
}, DURATION.MINUTES * 5);

useInterval(() => {
// this won't be run every days, but if the app stays open for more than 10 days
Expand Down
6 changes: 3 additions & 3 deletions ts/opengroup/opengroupV2/JoinOpenGroupV2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ async function joinOpenGroupV2(room: OpenGroupV2Room, fromConfigMessage: boolean
await forceSyncConfigurationNowIfNeeded();
}
} catch (e) {
window?.log?.error('Could not join open group v2', e);
throw new Error(e);
window?.log?.error('Could not join open group v2', e.message);
throw e;
}
}

Expand Down Expand Up @@ -157,7 +157,7 @@ export async function joinOpenGroupV2WithUIEvents(
}
}
} catch (error) {
window?.log?.warn('got error while joining open group:', error);
window?.log?.warn('got error while joining open group:', error.message);
if (showToasts) {
ToastUtils.pushToastError('connectToServerFail', window.i18n('connectToServerFail'));
}
Expand Down
2 changes: 1 addition & 1 deletion ts/opengroup/opengroupV2/OpenGroupManagerV2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ export class OpenGroupManagerV2 {

return conversation;
} catch (e) {
window?.log?.warn('Failed to join open group v2', e);
window?.log?.warn('Failed to join open group v2', e.message);
await removeV2OpenGroupRoom(conversationId);
// throw new Error(window.i18n('connectToServerFail'));
return undefined;
Expand Down
2 changes: 1 addition & 1 deletion ts/opengroup/opengroupV2/OpenGroupServerPoller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ export class OpenGroupServerPoller {
// ==> At this point all those results need to trigger conversation updates, so update what we have to update
await handleCompactPollResults(this.serverUrl, compactFetchResults);
} catch (e) {
window?.log?.warn('Got error while compact fetch:', e);
window?.log?.warn('Got error while compact fetch:', e.message);
} finally {
this.isPolling = false;
}
Expand Down
Loading