Skip to content

Commit

Permalink
#1298 shrink chat input after send, enable right click save image
Browse files Browse the repository at this point in the history
  • Loading branch information
Tenari committed Apr 4, 2023
1 parent 45e26d3 commit 71a7c9f
Show file tree
Hide file tree
Showing 6 changed files with 95 additions and 12 deletions.
1 change: 1 addition & 0 deletions app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
"cross-fetch": "^3.1.5",
"crypto-js": "^4.1.1",
"electron-debug": "^3.2.0",
"electron-dl": "^3.5.0",
"electron-log": "^4.4.6",
"electron-store": "^8.0.1",
"electron-updater": "^4.6.5",
Expand Down
8 changes: 8 additions & 0 deletions app/src/main/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { app, ipcMain, BrowserWindow, shell, session } from 'electron';
import isDev from 'electron-is-dev';
import fs from 'fs';
import fetch from 'cross-fetch';
import { download } from 'electron-dl';
import { ElectronBlocker } from '@cliqz/adblocker-electron';
import { MenuBuilder } from './menu';
import { resolveHtmlPath } from './util';
Expand Down Expand Up @@ -233,6 +234,13 @@ app.on('before-quit', (event) => {
});
ipcMain.on('realm.app.quit', app.quit);

ipcMain.on('download-url-as-file', async (_event, { url }) => {
const win = BrowserWindow.getFocusedWindow();
if (win) {
await download(win, url);
}
});

app
.whenReady()
.then(() => {
Expand Down
3 changes: 3 additions & 0 deletions app/src/os/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,9 @@ export class Realm extends EventEmitter {
showOpenDialog: async () => {
return await ipcRenderer.invoke('realm.show-open-dialog');
},
downloadUrlAsFile: async (url: string) =>
await ipcRenderer.send('download-url-as-file', { url }),

onSetTheme: (callback: any) =>
ipcRenderer.on('realm.change-theme', callback),
onLog: (callback: any) => ipcRenderer.on('realm.on-log', callback),
Expand Down
27 changes: 17 additions & 10 deletions app/src/renderer/apps/Courier/components/ChatMessage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { useContextMenu } from 'renderer/components';
import { useChatStore } from '../store';
import { ChatMessageType } from '../models';
import { toJS } from 'mobx';
import { OSActions } from 'renderer/logic/actions/os';

type ChatMessageProps = {
containerWidth: number;
Expand Down Expand Up @@ -88,16 +89,22 @@ export const ChatMessagePresenter = ({
});
}
if (hasImage) {
// menu.push({
// id: `${messageRowId}-save-image`,
// icon: 'CloudDownload',
// label: 'Save image',
// disabled: false,
// onClick: (evt: React.MouseEvent<HTMLButtonElement>) => {
// evt.stopPropagation();
// // selectedChat.saveImage(message.id);
// },
// });
menu.push({
id: `${messageRowId}-save-image`,
icon: 'CloudDownload',
label: 'Save image',
disabled: false,
onClick: (evt: React.MouseEvent<HTMLButtonElement>) => {
evt.stopPropagation();
const images =
msgModel &&
msgModel.contents.filter((c) =>
Object.keys(c)[0].includes('image')
);
if (images)
images.forEach((i) => OSActions.downloadUrlAsFile(i.image));
},
});
// TODO if trove is installed
// save to trove
}
Expand Down
1 change: 1 addition & 0 deletions lib/design-system/src/blocks/ChatInput/ChatInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ export const ChatInput = ({
onEditConfirm(parsedFragments);
} else {
onSend(parsedFragments);
setRows(1);
}
};

Expand Down
67 changes: 65 additions & 2 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -8384,6 +8384,15 @@ electron-debug@^3.2.0:
electron-is-dev "^1.1.0"
electron-localshortcut "^3.1.0"

electron-dl@^3.5.0:
version "3.5.0"
resolved "https://registry.yarnpkg.com/electron-dl/-/electron-dl-3.5.0.tgz#7a80bf13f168f7e5204774eee89dbc7c86de957b"
integrity sha512-Oj+VSuScVx8hEKM2HEvTQswTX6G3MLh7UoAz/oZuvKyNDfudNi1zY6PK/UnFoK1nCl9DF6k+3PFwElKbtZlDig==
dependencies:
ext-name "^5.0.0"
pupa "^2.0.1"
unused-filename "^2.1.0"

electron-is-accelerator@^0.1.0:
version "0.1.2"
resolved "https://registry.yarnpkg.com/electron-is-accelerator/-/electron-is-accelerator-0.1.2.tgz#509e510c26a56b55e17f863a4b04e111846ab27b"
Expand Down Expand Up @@ -8810,6 +8819,11 @@ escalade@^3.1.1:
resolved "https://registry.yarnpkg.com/escalade/-/escalade-3.1.1.tgz#d8cfdc7000965c5a0174b4a82eaa5c0552742e40"
integrity sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw==

escape-goat@^2.0.0:
version "2.1.1"
resolved "https://registry.yarnpkg.com/escape-goat/-/escape-goat-2.1.1.tgz#1b2dc77003676c457ec760b2dc68edb648188675"
integrity sha512-8/uIhbG12Csjy2JEW7D9pHbreaVaS/OpN3ycnyvElTdwM5n6GY6W6e2IPemfvGZeUMqZ9A/3GqIZMgKnBhAw/Q==

escape-html@~1.0.3:
version "1.0.3"
resolved "https://registry.yarnpkg.com/escape-html/-/escape-html-1.0.3.tgz#0258eae4d3d0c0974de1c169188ef0051d1d1988"
Expand Down Expand Up @@ -9330,6 +9344,21 @@ express@^4.17.1, express@^4.17.3:
utils-merge "1.0.1"
vary "~1.1.2"

ext-list@^2.0.0:
version "2.2.2"
resolved "https://registry.yarnpkg.com/ext-list/-/ext-list-2.2.2.tgz#0b98e64ed82f5acf0f2931babf69212ef52ddd37"
integrity sha512-u+SQgsubraE6zItfVA0tBuCBhfU9ogSRnsvygI7wht9TS510oLkBRXBsqopeUG/GBOIQyKZO9wjTqIu/sf5zFA==
dependencies:
mime-db "^1.28.0"

ext-name@^5.0.0:
version "5.0.0"
resolved "https://registry.yarnpkg.com/ext-name/-/ext-name-5.0.0.tgz#70781981d183ee15d13993c8822045c506c8f0a6"
integrity sha512-yblEwXAbGv1VQDmow7s38W77hzAgJAO50ztBLMcUyUBfxv1HC+LGwtiEN+Co6LtlqT/5uwVOxsD4TNIilWhwdQ==
dependencies:
ext-list "^2.0.0"
sort-keys-length "^1.0.0"

ext@^1.1.2:
version "1.7.0"
resolved "https://registry.yarnpkg.com/ext/-/ext-1.7.0.tgz#0ea4383c0103d60e70be99e9a7f11027a33c4f5f"
Expand Down Expand Up @@ -11098,7 +11127,7 @@ is-path-inside@^3.0.3:
resolved "https://registry.yarnpkg.com/is-path-inside/-/is-path-inside-3.0.3.tgz#d231362e53a07ff2b0e0ea7fed049161ffd16283"
integrity sha512-Fd4gABb+ycGAmKou8eMftCupSir5lRxqf4aD/vd0cD2qc4HL07OjCeuHMr8Ro4CoMaeCKDB0/ECBOVWjTwUvPQ==

is-plain-obj@^1.1.0:
is-plain-obj@^1.0.0, is-plain-obj@^1.1.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/is-plain-obj/-/is-plain-obj-1.1.0.tgz#71a50c8429dfca773c92a390a4a03b39fcd51d3e"
integrity sha512-yvkRyxmFKEOQ4pNXCmJG5AEQNlXJS5LaONXo5/cLdTZdWvsZ1ioJEonLGAosKlMWE8lwUy/bJzMjcw8az73+Fg==
Expand Down Expand Up @@ -12549,7 +12578,7 @@ miller-rabin@^4.0.0:
bn.js "^4.0.0"
brorand "^1.0.1"

mime-db@1.52.0, "mime-db@>= 1.43.0 < 2":
mime-db@1.52.0, "mime-db@>= 1.43.0 < 2", mime-db@^1.28.0:
version "1.52.0"
resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.52.0.tgz#bbabcdc02859f4987301c856e3387ce5ec43bf70"
integrity sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==
Expand Down Expand Up @@ -12791,6 +12820,11 @@ mobx@^6.5.0:
resolved "https://registry.yarnpkg.com/mobx/-/mobx-6.7.0.tgz#2d805610fee1801fd015c54fd5400d2601aa3768"
integrity sha512-1kBLBdSNG2bA522HQdbsTvwAwYf9hq9FWxmlhX7wTsJUAI54907J+ozfGW+LoYUo06vjit748g6QH1AAGLNebw==

modify-filename@^1.1.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/modify-filename/-/modify-filename-1.1.0.tgz#9a2dec83806fbb2d975f22beec859ca26b393aa1"
integrity sha512-EickqnKq3kVVaZisYuCxhtKbZjInCuwgwZWyAmRIp1NTMhri7r3380/uqwrUHfaDiPzLVTuoNy4whX66bxPVog==

moment@^2.29.4:
version "2.29.4"
resolved "https://registry.yarnpkg.com/moment/-/moment-2.29.4.tgz#3dbe052889fe7c1b2ed966fcb3a77328964ef108"
Expand Down Expand Up @@ -14441,6 +14475,13 @@ punycode@^2.1.0:
resolved "https://registry.yarnpkg.com/punycode/-/punycode-2.3.0.tgz#f67fa67c94da8f4d0cfff981aee4118064199b8f"
integrity sha512-rRV+zQD8tVFys26lAGR9WUuS4iUAngJScM+ZRSKtvl5tKeZ2t5bvdNFdNHBW9FWR4guGHlgmsZ1G7BSm2wTbuA==

pupa@^2.0.1:
version "2.1.1"
resolved "https://registry.yarnpkg.com/pupa/-/pupa-2.1.1.tgz#f5e8fd4afc2c5d97828faa523549ed8744a20d62"
integrity sha512-l1jNAspIBSFqbT+y+5FosojNpVpF94nlI+wDUpqP9enwOTfHx9f0gh5nB96vl+6yTpsJsypeNrwfzPrKuHB41A==
dependencies:
escape-goat "^2.0.0"

qrcode.react@^3.1.0:
version "3.1.0"
resolved "https://registry.yarnpkg.com/qrcode.react/-/qrcode.react-3.1.0.tgz#5c91ddc0340f768316fbdb8fff2765134c2aecd8"
Expand Down Expand Up @@ -15724,6 +15765,20 @@ socks@^2.6.2:
ip "^2.0.0"
smart-buffer "^4.2.0"

sort-keys-length@^1.0.0:
version "1.0.1"
resolved "https://registry.yarnpkg.com/sort-keys-length/-/sort-keys-length-1.0.1.tgz#9cb6f4f4e9e48155a6aa0671edd336ff1479a188"
integrity sha512-GRbEOUqCxemTAk/b32F2xa8wDTs+Z1QHOkbhJDQTvv/6G3ZkbJ+frYWsTcc7cBB3Fu4wy4XlLCuNtJuMn7Gsvw==
dependencies:
sort-keys "^1.0.0"

sort-keys@^1.0.0:
version "1.1.2"
resolved "https://registry.yarnpkg.com/sort-keys/-/sort-keys-1.1.2.tgz#441b6d4d346798f1b4e49e8920adfba0e543f9ad"
integrity sha512-vzn8aSqKgytVik0iwdBEi+zevbTYZogewTUM6dtpmGwEcdzbub/TX4bCzRhebDCRC3QzXgJsLRKB2V/Oof7HXg==
dependencies:
is-plain-obj "^1.0.0"

source-list-map@^2.0.0:
version "2.0.1"
resolved "https://registry.yarnpkg.com/source-list-map/-/source-list-map-2.0.1.tgz#3993bd873bfc48479cca9ea3a547835c7c154b34"
Expand Down Expand Up @@ -17015,6 +17070,14 @@ untildify@^2.0.0:
dependencies:
os-homedir "^1.0.0"

unused-filename@^2.1.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/unused-filename/-/unused-filename-2.1.0.tgz#33719c4e8d9644f32d2dec1bc8525c6aaeb4ba51"
integrity sha512-BMiNwJbuWmqCpAM1FqxCTD7lXF97AvfQC8Kr/DIeA6VtvhJaMDupZ82+inbjl5yVP44PcxOuCSxye1QMS0wZyg==
dependencies:
modify-filename "^1.1.0"
path-exists "^4.0.0"

upath@^1.1.1:
version "1.2.0"
resolved "https://registry.yarnpkg.com/upath/-/upath-1.2.0.tgz#8f66dbcd55a883acdae4408af8b035a5044c1894"
Expand Down

0 comments on commit 71a7c9f

Please sign in to comment.