From 500a88dbab8a7ec2c9cb6f502d4f2641e7e3cfb1 Mon Sep 17 00:00:00 2001 From: Mikunj Date: Thu, 5 Sep 2019 08:57:29 +1000 Subject: [PATCH 1/9] Removed identicon.js Updated profile image helper. --- app/profile_images.js | 27 +++-------------- js/models/conversations.js | 10 +++++-- package.json | 3 +- yarn.lock | 61 ++++++++++++++++++++++++++++++++++---- 4 files changed, 68 insertions(+), 33 deletions(-) diff --git a/app/profile_images.js b/app/profile_images.js index ee39ee3a9..7cbc9b4c5 100644 --- a/app/profile_images.js +++ b/app/profile_images.js @@ -1,7 +1,6 @@ const fs = require('fs'); const mkdirp = require('mkdirp'); const path = require('path'); -const Identicon = require('identicon.js'); const sha224 = require('js-sha512').sha512_224; const { app } = require('electron').remote; @@ -13,14 +12,6 @@ mkdirp.sync(PATH); const hasImage = pubKey => fs.existsSync(getImagePath(pubKey)); const getImagePath = pubKey => `${PATH}/${pubKey}.png`; -const getOrCreateImagePath = pubKey => { - // If the image doesn't exist then create it - if (!hasImage(pubKey)) { - return generateImage(pubKey); - } - - return getImagePath(pubKey); -}; const removeImage = pubKey => { if (hasImage(pubKey)) { @@ -41,24 +32,14 @@ const removeImagesNotInArray = pubKeyArray => { .forEach(i => removeImage(i)); }; -const generateImage = pubKey => { +const writePNGImage = (base64String, pubKey) => { const imagePath = getImagePath(pubKey); - - /* - We hash the pubKey and then pass that into Identicon. - This is to avoid getting the same image - if 2 public keys start with the same 15 characters. - */ - const png = new Identicon(sha224(pubKey), { - margin: 0.2, - background: [0, 0, 0, 0], - }).toString(); - fs.writeFileSync(imagePath, png, 'base64'); + fs.writeFileSync(imagePath, base64String, 'base64'); return imagePath; -}; +} module.exports = { - generateImage, + writePNGImage, getOrCreateImagePath, getImagePath, hasImage, diff --git a/js/models/conversations.js b/js/models/conversations.js index dff8043fa..2a75f8949 100644 --- a/js/models/conversations.js +++ b/js/models/conversations.js @@ -309,11 +309,15 @@ }, async updateProfileAvatar() { - if (this.isRss()) { + if (this.isRss() || this.isPublic()) { return; } - const path = profileImages.getOrCreateImagePath(this.id); - await this.setProfileAvatar(path); + + // Remove old identicons + if (profileImages.hasImage(this.id)) { + profileImages.removeImage(this.id); + await this.setProfileAvatar(null); + } }, async updateAndMerge(message) { diff --git a/package.json b/package.json index b055f5039..f3a349e66 100644 --- a/package.json +++ b/package.json @@ -60,6 +60,7 @@ "buffer-crc32": "0.2.13", "bunyan": "1.8.12", "classnames": "2.2.5", + "color": "^3.1.2", "config": "1.28.1", "electron-context-menu": "^0.15.0", "electron-editor-context-menu": "1.1.1", @@ -76,7 +77,6 @@ "google-libphonenumber": "3.2.2", "got": "8.2.0", "he": "1.2.0", - "identicon.js": "2.3.3", "intl-tel-input": "12.1.15", "jquery": "3.3.1", "js-sha512": "0.8.0", @@ -122,6 +122,7 @@ "devDependencies": { "@types/chai": "4.1.2", "@types/classnames": "2.2.3", + "@types/color": "^3.0.0", "@types/config": "0.0.34", "@types/filesize": "3.6.0", "@types/fs-extra": "5.0.5", diff --git a/yarn.lock b/yarn.lock index 20f42cec8..72d1e6646 100644 --- a/yarn.lock +++ b/yarn.lock @@ -89,6 +89,25 @@ resolved "https://registry.yarnpkg.com/@types/classnames/-/classnames-2.2.3.tgz#3f0ff6873da793870e20a260cada55982f38a9e5" integrity sha512-x15/Io+JdzrkM9gnX6SWUs/EmqQzd65TD9tcZIAQ1VIdb93XErNuYmB7Yho8JUCE189ipUSESsWvGvYXRRIvYA== +"@types/color-convert@*": + version "1.9.0" + resolved "https://registry.yarnpkg.com/@types/color-convert/-/color-convert-1.9.0.tgz#bfa8203e41e7c65471e9841d7e306a7cd8b5172d" + integrity sha512-OKGEfULrvSL2VRbkl/gnjjgbbF7ycIlpSsX7Nkab4MOWi5XxmgBYvuiQ7lcCFY5cPDz7MUNaKgxte2VRmtr4Fg== + dependencies: + "@types/color-name" "*" + +"@types/color-name@*": + version "1.1.1" + resolved "https://registry.yarnpkg.com/@types/color-name/-/color-name-1.1.1.tgz#1c1261bbeaa10a8055bbc5d8ab84b7b2afc846a0" + integrity sha512-rr+OQyAjxze7GgWrSaJwydHStIhHq2lvY3BOC2Mj7KnzI7XK0Uw1TOOdI9lDoajEbSWLiYgoo4f1R51erQfhPQ== + +"@types/color@^3.0.0": + version "3.0.0" + resolved "https://registry.yarnpkg.com/@types/color/-/color-3.0.0.tgz#40f8a6bf2fd86e969876b339a837d8ff1b0a6e30" + integrity sha512-5qqtNia+m2I0/85+pd2YzAXaTyKO8j+svirO5aN+XaQJ5+eZ8nx0jPtEWZLxCi50xwYsX10xUHetFzfb1WEs4Q== + dependencies: + "@types/color-convert" "*" + "@types/config@0.0.34": version "0.0.34" resolved "https://registry.yarnpkg.com/@types/config/-/config-0.0.34.tgz#123f91bdb5afdd702294b9de9ca04d9ea11137b0" @@ -1733,11 +1752,18 @@ color-convert@^1.9.0: dependencies: color-name "^1.1.1" +color-convert@^1.9.1: + version "1.9.3" + resolved "https://registry.yarnpkg.com/color-convert/-/color-convert-1.9.3.tgz#bb71850690e1f136567de629d2d5471deda4c1e8" + integrity sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg== + dependencies: + color-name "1.1.3" + color-convert@~0.5.0: version "0.5.3" resolved "https://registry.yarnpkg.com/color-convert/-/color-convert-0.5.3.tgz#bdb6c69ce660fadffe0b0007cc447e1b9f7282bd" -color-name@^1.0.0, color-name@^1.1.1: +color-name@1.1.3, color-name@^1.0.0, color-name@^1.1.1: version "1.1.3" resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.3.tgz#a7d0558bd89c42f795dd42328f740831ca53bc25" @@ -1748,6 +1774,14 @@ color-string@^0.3.0: dependencies: color-name "^1.0.0" +color-string@^1.5.2: + version "1.5.3" + resolved "https://registry.yarnpkg.com/color-string/-/color-string-1.5.3.tgz#c9bbc5f01b58b5492f3d6857459cb6590ce204cc" + integrity sha512-dC2C5qeWoYkxki5UAXapdjqO672AM4vZuPGRQfO8b5HKuKGBbKWpITyDYN7TOFKvRW7kOgAn3746clDBMDJyQw== + dependencies: + color-name "^1.0.0" + simple-swizzle "^0.2.2" + color@^0.11.0: version "0.11.4" resolved "https://registry.yarnpkg.com/color/-/color-0.11.4.tgz#6d7b5c74fb65e841cd48792ad1ed5e07b904d764" @@ -1757,6 +1791,14 @@ color@^0.11.0: color-convert "^1.3.0" color-string "^0.3.0" +color@^3.1.2: + version "3.1.2" + resolved "https://registry.yarnpkg.com/color/-/color-3.1.2.tgz#68148e7f85d41ad7649c5fa8c8106f098d229e10" + integrity sha512-vXTJhHebByxZn3lDvDJYw4lR5+uB3vuoHsuYA5AKuxRVn5wzzIfQKGLBmgdVRHKTJYeK5rvJcHnrd0Li49CFpg== + dependencies: + color-convert "^1.9.1" + color-string "^1.5.2" + colormin@^1.0.5: version "1.1.2" resolved "https://registry.yarnpkg.com/colormin/-/colormin-1.1.2.tgz#ea2f7420a72b96881a38aae59ec124a6f7298133" @@ -4480,11 +4522,6 @@ icss-utils@^2.1.0: dependencies: postcss "^6.0.1" -identicon.js@2.3.3: - version "2.3.3" - resolved "https://registry.yarnpkg.com/identicon.js/-/identicon.js-2.3.3.tgz#c505b8d60ecc6ea13bbd991a33964c44c1ad60a1" - integrity sha512-/qgOkXKZ7YbeCYbawJ9uQQ3XJ3uBg9VDpvHjabCAPp6aRMhjLaFAxG90+1TxzrhKaj6AYpVGrx6UXQfQA41UEA== - ieee754@^1.1.4: version "1.1.8" resolved "https://registry.yarnpkg.com/ieee754/-/ieee754-1.1.8.tgz#be33d40ac10ef1926701f6f08a2d86fbfd1ad3e4" @@ -4669,6 +4706,11 @@ is-arrayish@^0.2.1: version "0.2.1" resolved "https://registry.yarnpkg.com/is-arrayish/-/is-arrayish-0.2.1.tgz#77c99840527aa8ecb1a8ba697b80645a7a926a9d" +is-arrayish@^0.3.1: + version "0.3.2" + resolved "https://registry.yarnpkg.com/is-arrayish/-/is-arrayish-0.3.2.tgz#4574a2ae56f7ab206896fb431eaeed066fdf8f03" + integrity sha512-eVRqCvVlZbuw3GrM63ovNSNAeA1K16kaR/LRY/92w0zxQ5/1YzwblUX652i4Xs9RwAGjW9d9y6X88t8OaAJfWQ== + is-binary-path@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/is-binary-path/-/is-binary-path-1.0.1.tgz#75f16642b480f187a711c814161fd3a4a7655898" @@ -8640,6 +8682,13 @@ signal-exit@^3.0.0, signal-exit@^3.0.1, signal-exit@^3.0.2: version "3.0.2" resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.2.tgz#b5fdc08f1287ea1178628e415e25132b73646c6d" +simple-swizzle@^0.2.2: + version "0.2.2" + resolved "https://registry.yarnpkg.com/simple-swizzle/-/simple-swizzle-0.2.2.tgz#a4da6b635ffcccca33f70d17cb92592de95e557a" + integrity sha1-pNprY1/8zMoz9w0Xy5JZLeleVXo= + dependencies: + is-arrayish "^0.3.1" + single-line-log@^1.1.2: version "1.1.2" resolved "https://registry.yarnpkg.com/single-line-log/-/single-line-log-1.1.2.tgz#c2f83f273a3e1a16edb0995661da0ed5ef033364" From a9189979e1f46b272470748fc9c1e28e59306dbb Mon Sep 17 00:00:00 2001 From: Mikunj Date: Thu, 5 Sep 2019 09:24:24 +1000 Subject: [PATCH 2/9] Added JazzIcon --- app/profile_images.js | 4 +- ts/components/Avatar.tsx | 44 +++++++- ts/components/JazzIcon/JazzIcon.tsx | 165 ++++++++++++++++++++++++++++ ts/components/JazzIcon/Paper.tsx | 25 +++++ ts/components/JazzIcon/RNG.tsx | 21 ++++ ts/components/JazzIcon/index.tsx | 2 + 6 files changed, 254 insertions(+), 7 deletions(-) create mode 100644 ts/components/JazzIcon/JazzIcon.tsx create mode 100644 ts/components/JazzIcon/Paper.tsx create mode 100644 ts/components/JazzIcon/RNG.tsx create mode 100644 ts/components/JazzIcon/index.tsx diff --git a/app/profile_images.js b/app/profile_images.js index 7cbc9b4c5..f8c8a26f0 100644 --- a/app/profile_images.js +++ b/app/profile_images.js @@ -1,7 +1,6 @@ const fs = require('fs'); const mkdirp = require('mkdirp'); const path = require('path'); -const sha224 = require('js-sha512').sha512_224; const { app } = require('electron').remote; @@ -36,11 +35,10 @@ const writePNGImage = (base64String, pubKey) => { const imagePath = getImagePath(pubKey); fs.writeFileSync(imagePath, base64String, 'base64'); return imagePath; -} +}; module.exports = { writePNGImage, - getOrCreateImagePath, getImagePath, hasImage, removeImage, diff --git a/ts/components/Avatar.tsx b/ts/components/Avatar.tsx index 7a4fe36a7..a400af605 100644 --- a/ts/components/Avatar.tsx +++ b/ts/components/Avatar.tsx @@ -1,6 +1,7 @@ import React from 'react'; import classNames from 'classnames'; +import { JazzIcon } from './JazzIcon'; import { getInitials } from '../util/getInitials'; import { LocalizerType } from '../types/Util'; @@ -22,7 +23,7 @@ interface State { imageBroken: boolean; } -export class Avatar extends React.Component { +export class Avatar extends React.PureComponent { public handleImageErrorBound: () => void; public constructor(props: Props) { @@ -43,6 +44,22 @@ export class Avatar extends React.Component { }); } + public renderIdenticon() { + const { phoneNumber, borderColor, borderWidth, size } = this.props; + + if (!phoneNumber) { + return this.renderNoImage(); + } + + const borderStyle = this.getBorderStyle(borderColor, borderWidth); + + // Generate the seed + const hash = phoneNumber.substring(0, 12); + const seed = parseInt(hash, 16) || 1234; + + return ; + } + public renderImage() { const { avatarPath, @@ -129,10 +146,18 @@ export class Avatar extends React.Component { } public render() { - const { avatarPath, color, size, noteToSelf } = this.props; + const { + avatarPath, + color, + size, + noteToSelf, + conversationType, + } = this.props; const { imageBroken } = this.state; - const hasImage = !noteToSelf && avatarPath && !imageBroken; + // If it's a direct conversation then we must have an identicon + const hasAvatar = avatarPath || conversationType === 'direct'; + const hasImage = !noteToSelf && hasAvatar && !imageBroken; if (size !== 28 && size !== 36 && size !== 48 && size !== 80) { throw new Error(`Size ${size} is not supported!`); @@ -147,11 +172,22 @@ export class Avatar extends React.Component { !hasImage ? `module-avatar--${color}` : null )} > - {hasImage ? this.renderImage() : this.renderNoImage()} + {hasImage ? this.renderAvatarOrIdenticon() : this.renderNoImage()} ); } + private renderAvatarOrIdenticon() { + const { avatarPath, conversationType } = this.props; + + // If it's a direct conversation then we must have an identicon + const hasAvatar = avatarPath || conversationType === 'direct'; + + return hasAvatar && avatarPath + ? this.renderImage() + : this.renderIdenticon(); + } + private getBorderStyle(color?: string, width?: number) { const borderWidth = typeof width === 'number' ? width : 3; diff --git a/ts/components/JazzIcon/JazzIcon.tsx b/ts/components/JazzIcon/JazzIcon.tsx new file mode 100644 index 000000000..9773c9b5e --- /dev/null +++ b/ts/components/JazzIcon/JazzIcon.tsx @@ -0,0 +1,165 @@ +import React from 'react'; +import Color from 'color'; +import { Paper } from './Paper'; +import { RNG } from './RNG'; + +const defaultColors = [ + '#01888c', // teal + '#fc7500', // bright orange + '#034f5d', // dark teal + '#E784BA', // light pink + '#81C8B6', // bright green + '#c7144c', // raspberry + '#f3c100', // goldenrod + '#1598f2', // lightning blue + '#2465e1', // sail blue + '#f19e02', // gold +]; + +const isColor = (str: string) => /(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test(str); +const isColors = (arr: Array) => { + if (!Array.isArray(arr)) { + return false; + } + + if (arr.every(value => typeof value === 'string' && isColor(value))) { + return true; + } + + return false; +}; + +interface Props { + diameter: number; + seed: number; + paperStyles?: Object; + svgStyles?: Object; + shapeCount?: number; + wobble?: number; + colors?: Array; +} + +// tslint:disable-next-line no-http-string +const svgns = 'http://www.w3.org/2000/svg'; +const shapeCount = 4; +const wobble = 30; + +export class JazzIcon extends React.PureComponent { + public render() { + const { + colors: customColors, + diameter, + paperStyles, + seed, + svgStyles, + } = this.props; + + const generator = new RNG(seed); + + const colors = customColors || defaultColors; + + const newColours = this.hueShift( + this.colorsForIcon(colors).slice(), + generator + ); + const shapesArr = Array(shapeCount).fill(null); + const shuffledColours = this.shuffleArray(newColours, generator); + + return ( + + + {shapesArr.map((_, i) => + this.genShape( + shuffledColours[i + 1], + diameter, + i, + shapeCount - 1, + generator + ) + )} + + + ); + } + + private hueShift(colors: Array, generator: RNG) { + const amount = generator.random() * 30 - wobble / 2; + + return colors.map(hex => { + const color = Color(hex); + color.rotate(amount); + + return color.hex(); + }); + } + + private genShape( + colour: string, + diameter: number, + i: number, + total: number, + generator: RNG + ) { + const center = diameter / 2; + const firstRot = generator.random(); + const angle = Math.PI * 2 * firstRot; + const velocity = + diameter / total * generator.random() + i * diameter / total; + const tx = Math.cos(angle) * velocity; + const ty = Math.sin(angle) * velocity; + const translate = `translate(${tx} ${ty})`; + + // Third random is a shape rotation on top of all of that. + const secondRot = generator.random(); + const rot = firstRot * 360 + secondRot * 180; + const rotate = `rotate(${rot.toFixed(1)} ${center} ${center})`; + const transform = `${translate} ${rotate}`; + + return ( + + ); + } + + private colorsForIcon(arr: Array) { + if (isColors(arr)) { + return arr; + } + + return defaultColors; + } + + private shuffleArray(array: Array, generator: RNG) { + let currentIndex = array.length; + const newArray = [...array]; + + // While there remain elements to shuffle... + while (currentIndex > 0) { + // Pick a remaining element... + const randomIndex = generator.next() % currentIndex; + currentIndex -= 1; + // And swap it with the current element. + const temporaryValue = newArray[currentIndex]; + newArray[currentIndex] = newArray[randomIndex]; + newArray[randomIndex] = temporaryValue; + } + + return newArray; + } +} diff --git a/ts/components/JazzIcon/Paper.tsx b/ts/components/JazzIcon/Paper.tsx new file mode 100644 index 000000000..c6d38ab6b --- /dev/null +++ b/ts/components/JazzIcon/Paper.tsx @@ -0,0 +1,25 @@ +import React from 'react'; + +const styles = { + borderRadius: '50px', + display: 'inline-block', + margin: 0, + overflow: 'hidden', + padding: 0, +}; + +// @ts-ignore +export const Paper = ({ children, color, diameter, style: styleOverrides }) => ( +
+ {children} +
+); diff --git a/ts/components/JazzIcon/RNG.tsx b/ts/components/JazzIcon/RNG.tsx new file mode 100644 index 000000000..b6c18ac6b --- /dev/null +++ b/ts/components/JazzIcon/RNG.tsx @@ -0,0 +1,21 @@ +export class RNG { + private _seed: number; + constructor(seed: number) { + this._seed = seed % 2147483647; + if (this._seed <= 0) { + this._seed += 2147483646; + } + } + + public next() { + return (this._seed = (this._seed * 16807) % 2147483647); + } + + public nextFloat() { + return (this.next() - 1) / 2147483646; + } + + public random() { + return this.nextFloat(); + } +} diff --git a/ts/components/JazzIcon/index.tsx b/ts/components/JazzIcon/index.tsx new file mode 100644 index 000000000..204774dc6 --- /dev/null +++ b/ts/components/JazzIcon/index.tsx @@ -0,0 +1,2 @@ +import { JazzIcon } from './JazzIcon'; +export { JazzIcon }; From aa216d7a5ddc811d7439a2ac2324f76bed76f973 Mon Sep 17 00:00:00 2001 From: Mikunj Date: Thu, 5 Sep 2019 15:28:00 +1000 Subject: [PATCH 3/9] Added minor comment. --- ts/components/JazzIcon/JazzIcon.tsx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ts/components/JazzIcon/JazzIcon.tsx b/ts/components/JazzIcon/JazzIcon.tsx index 9773c9b5e..e6494dfa1 100644 --- a/ts/components/JazzIcon/JazzIcon.tsx +++ b/ts/components/JazzIcon/JazzIcon.tsx @@ -1,3 +1,5 @@ +// Modified from https://github.com/redlanta/react-jazzicon + import React from 'react'; import Color from 'color'; import { Paper } from './Paper'; From 5cf63af3a3cd8c9430806342740bbf82961ae9cc Mon Sep 17 00:00:00 2001 From: Maxim Shishmarev Date: Fri, 6 Sep 2019 12:48:33 +1000 Subject: [PATCH 4/9] Enable quotes in public chats --- js/modules/loki_message_api.js | 1 + js/modules/loki_public_chat_api.js | 12 +++++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/js/modules/loki_message_api.js b/js/modules/loki_message_api.js index 227541929..f9c3610d6 100644 --- a/js/modules/loki_message_api.js +++ b/js/modules/loki_message_api.js @@ -95,6 +95,7 @@ class LokiMessageAPI { } const res = await publicSendData.sendMessage( data.body, + data.quote, messageTimeStamp, displayName, this.ourKey diff --git a/js/modules/loki_public_chat_api.js b/js/modules/loki_public_chat_api.js index 07629bf18..2b598d2a9 100644 --- a/js/modules/loki_public_chat_api.js +++ b/js/modules/loki_public_chat_api.js @@ -521,6 +521,7 @@ class LokiPublicChannelAPI { let timestamp = new Date(adnMessage.created_at).getTime(); // pubKey lives in the username field let from = adnMessage.user.name; + let quote = null; if (adnMessage.is_deleted) { return; } @@ -529,7 +530,11 @@ class LokiPublicChannelAPI { adnMessage.annotations.length !== 0 ) { const noteValue = adnMessage.annotations[0].value; - ({ timestamp } = noteValue); + ({ timestamp, quote } = noteValue); + + if (quote) { + quote.attachments = []; + } // if user doesn't have a name set, fallback to annotation // pubkeys are already there in v1 (first release) @@ -571,7 +576,7 @@ class LokiPublicChannelAPI { timestamp, received_at: receivedAt, sent_at: timestamp, - quote: null, + quote, contact: [], preview: [], profile: { @@ -597,7 +602,7 @@ class LokiPublicChannelAPI { } // create a message in the channel - async sendMessage(text, messageTimeStamp, displayName, pubKey) { + async sendMessage(text, quote, messageTimeStamp, displayName, pubKey) { const payload = { text, annotations: [ @@ -609,6 +614,7 @@ class LokiPublicChannelAPI { from: displayName, // will deprecated source: pubKey, + quote, }, }, ], From 5dc52f0858af55abe41a4c30a7e602cf322b5f29 Mon Sep 17 00:00:00 2001 From: Mikunj Date: Fri, 6 Sep 2019 13:18:26 +1000 Subject: [PATCH 5/9] Fix incorrect hue shifting --- ts/components/JazzIcon/JazzIcon.tsx | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/ts/components/JazzIcon/JazzIcon.tsx b/ts/components/JazzIcon/JazzIcon.tsx index e6494dfa1..ac082c1af 100644 --- a/ts/components/JazzIcon/JazzIcon.tsx +++ b/ts/components/JazzIcon/JazzIcon.tsx @@ -94,12 +94,7 @@ export class JazzIcon extends React.PureComponent { private hueShift(colors: Array, generator: RNG) { const amount = generator.random() * 30 - wobble / 2; - return colors.map(hex => { - const color = Color(hex); - color.rotate(amount); - - return color.hex(); - }); + return colors.map(hex => Color(hex).rotate(amount).hex()); } private genShape( From 5a35f05f29ee4e5d8aaa2a64caf70c4972656047 Mon Sep 17 00:00:00 2001 From: Beaudan Brown Date: Mon, 9 Sep 2019 11:36:56 +1000 Subject: [PATCH 6/9] Fix start-prod(-multi) to actually use different identities than default messenger, also connect dev instances to the dev public chat and clean up the config files a lil --- config/default.json | 12 ++++++++++-- config/development-1.json | 10 ++++++++-- config/development.json | 9 ++++++++- config/local-devprod.json | 4 ++++ config/local-devprod1.json | 5 +++++ config/production.json | 17 +---------------- package.json | 4 ++-- 7 files changed, 38 insertions(+), 23 deletions(-) create mode 100644 config/local-devprod.json create mode 100644 config/local-devprod1.json diff --git a/config/default.json b/config/default.json index a1e9adf51..31462adf2 100644 --- a/config/default.json +++ b/config/default.json @@ -7,11 +7,19 @@ "defaultPoWDifficulty": "1", "seedNodeList": [ { - "ip": "storage.testnetseed1.loki.network", + "ip": "storage.seed1.loki.network", + "port": "22023" + }, + { + "ip": "storage.seed2.loki.network", + "port": "38157" + }, + { + "ip": "imaginary.stream", "port": "38157" } ], - "disableAutoUpdate": false, + "disableAutoUpdate": true, "updatesUrl": "https://updates2.signal.org/desktop", "updatesPublicKey": "fd7dd3de7149dc0a127909fee7de0f7620ddd0de061b37a2c303e37de802a401", diff --git a/config/development-1.json b/config/development-1.json index 57b4796c5..e5549aaf6 100644 --- a/config/development-1.json +++ b/config/development-1.json @@ -1,6 +1,12 @@ { "storageProfile": "development1", "localServerPort": "8082", - "disableAutoUpdate": true, - "openDevTools": true + "seedNodeList": [ + { + "ip": "storage.testnetseed1.loki.network", + "port": "38157" + } + ], + "openDevTools": true, + "defaultPublicChatServer": "https://chat-dev.lokinet.org/" } diff --git a/config/development.json b/config/development.json index 93568dde2..bec0ce84b 100644 --- a/config/development.json +++ b/config/development.json @@ -1,4 +1,11 @@ { "storageProfile": "development", - "openDevTools": true + "seedNodeList": [ + { + "ip": "storage.testnetseed1.loki.network", + "port": "38157" + } + ], + "openDevTools": true, + "defaultPublicChatServer": "https://chat-dev.lokinet.org/" } diff --git a/config/local-devprod.json b/config/local-devprod.json new file mode 100644 index 000000000..d4f765b43 --- /dev/null +++ b/config/local-devprod.json @@ -0,0 +1,4 @@ +{ + "storageProfile": "devprodProfile", + "openDevTools": true +} diff --git a/config/local-devprod1.json b/config/local-devprod1.json new file mode 100644 index 000000000..3c808479b --- /dev/null +++ b/config/local-devprod1.json @@ -0,0 +1,5 @@ +{ + "storageProfile": "devprod1Profile", + "localServerPort": "8082", + "openDevTools": true +} diff --git a/config/production.json b/config/production.json index 7114a9bba..0967ef424 100644 --- a/config/production.json +++ b/config/production.json @@ -1,16 +1 @@ -{ - "seedNodeList": [ - { - "ip": "storage.seed1.loki.network", - "port": "22023" - }, - { - "ip": "storage.seed2.loki.network", - "port": "38157" - }, - { - "ip": "imaginary.stream", - "port": "38157" - } - ] -} +{} diff --git a/package.json b/package.json index b055f5039..15b7fbc85 100644 --- a/package.json +++ b/package.json @@ -14,8 +14,8 @@ "postinstall": "electron-builder install-app-deps && rimraf node_modules/dtrace-provider", "start": "electron .", "start-multi": "NODE_APP_INSTANCE=1 electron .", - "start-prod": "NODE_ENV=production LOKI_DEV=1 electron .", - "start-prod-multi": "NODE_ENV=production LOKI_DEV=1 NODE_APP_INSTANCE=1 electron .", + "start-prod": "NODE_ENV=production NODE_APP_INSTANCE=devprod LOKI_DEV=1 electron .", + "start-prod-multi": "NODE_ENV=production NODE_APP_INSTANCE=devprod1 LOKI_DEV=1 electron .", "grunt": "grunt", "icon-gen": "electron-icon-maker --input=images/icon_1024.png --output=./build", "generate": "yarn icon-gen && yarn grunt", From e5eab74b1b0ea90e3165197537407e0f7d7a9915 Mon Sep 17 00:00:00 2001 From: sachaaaaa Date: Mon, 9 Sep 2019 11:56:35 +1000 Subject: [PATCH 7/9] Fix #355 Display timestamp for friend requests --- js/models/messages.js | 1 + ts/components/conversation/FriendRequest.md | 2 ++ ts/components/conversation/FriendRequest.tsx | 16 ++++++++++++++-- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/js/models/messages.js b/js/models/messages.js index 8f2283293..685d594f8 100644 --- a/js/models/messages.js +++ b/js/models/messages.js @@ -483,6 +483,7 @@ return { text: this.createNonBreakingLastSeparator(this.get('body')), + timestamp: this.get('sent_at'), status: this.getMessagePropStatus(), direction, friendStatus, diff --git a/ts/components/conversation/FriendRequest.md b/ts/components/conversation/FriendRequest.md index fccc5a6d1..f4042aa6a 100644 --- a/ts/components/conversation/FriendRequest.md +++ b/ts/components/conversation/FriendRequest.md @@ -5,6 +5,7 @@ | Name | Values | | -------------------- | -------------------------------------------- | | text | string | +| timstamp | number | | direction | 'outgoing' \| 'incoming | | status | 'sending' \| 'sent' \| 'read' \| 'delivered' | | friendStatus | 'pending' \| 'accepted' \| 'declined' | @@ -21,6 +22,7 @@
  • void; onDecline: () => void; onDeleteConversation: () => void; @@ -142,13 +144,23 @@ export class FriendRequest extends React.Component { // Renders 'sending', 'read' icons public renderStatusIndicator() { - const { direction, status } = this.props; - if (direction !== 'outgoing' || status === 'error') { + const { direction, status, i18n, text, timestamp } = this.props; + if (status === 'error') { return null; } + const withImageNoCaption = Boolean(!text); + return (
    +
    Date: Mon, 9 Sep 2019 13:00:56 +1000 Subject: [PATCH 8/9] Update ts/components/conversation/FriendRequest.md Co-Authored-By: Mikunj Varsani --- ts/components/conversation/FriendRequest.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ts/components/conversation/FriendRequest.md b/ts/components/conversation/FriendRequest.md index f4042aa6a..bef992b2e 100644 --- a/ts/components/conversation/FriendRequest.md +++ b/ts/components/conversation/FriendRequest.md @@ -5,7 +5,7 @@ | Name | Values | | -------------------- | -------------------------------------------- | | text | string | -| timstamp | number | +| timestamp | number | | direction | 'outgoing' \| 'incoming | | status | 'sending' \| 'sent' \| 'read' \| 'delivered' | | friendStatus | 'pending' \| 'accepted' \| 'declined' | From 3beb6004dba0019d48a21e27e6431efadbb85ba3 Mon Sep 17 00:00:00 2001 From: sachaaaaa Date: Tue, 10 Sep 2019 14:35:16 +1000 Subject: [PATCH 9/9] Fix last hash all being NULL in database --- js/modules/loki_snode_api.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/js/modules/loki_snode_api.js b/js/modules/loki_snode_api.js index 398a59602..6483727d7 100644 --- a/js/modules/loki_snode_api.js +++ b/js/modules/loki_snode_api.js @@ -136,8 +136,8 @@ class LokiSnodeAPI { await conversation.updateSwarmNodes(filteredNodes); } - async updateLastHash(nodeUrl, lastHash, expiresAt) { - await window.Signal.Data.updateLastHash({ nodeUrl, lastHash, expiresAt }); + async updateLastHash(snode, hash, expiresAt) { + await window.Signal.Data.updateLastHash({ snode, hash, expiresAt }); } getSwarmNodesForPubKey(pubKey) {