-
-
Notifications
You must be signed in to change notification settings - Fork 172
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
Select background #1001
Select background #1001
Changes from all commits
68ef71e
e4dc4cc
2e63c39
23be258
a622c8f
19150aa
2c81b83
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -136,3 +136,4 @@ code { | |
image-rendering: -o-crisp-edges; | ||
image-rendering: pixelated; | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
|
||
// ChatView Background selector | ||
|
||
.background-preview { | ||
width: 100pt; | ||
height: 100pt; | ||
border-radius: 5pt; | ||
background-image: url(../images/background_light.svg); | ||
background-color: var(--chatViewBg); | ||
} | ||
|
||
.background-options { | ||
display: flex; | ||
flex-direction: column; | ||
padding-left: 8pt; | ||
justify-content: space-evenly; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
module.exports = { init } | ||
|
||
const { app, ipcMain } = require('electron') | ||
const { app, ipcMain, dialog } = require('electron') | ||
const rimraf = require('rimraf') | ||
const path = require('path') | ||
const fs = require('fs') | ||
|
@@ -173,11 +173,34 @@ function init (cwd, state, logHandler) { | |
e.returnValue = app.localeData | ||
}) | ||
|
||
ipcMain.on('updateDesktopSetting', (e, key, value) => { | ||
const updateDesktopSetting = (e, key, value) => { | ||
const { saved } = app.state | ||
saved[key] = value | ||
app.saveState({ saved }) | ||
render() | ||
} | ||
ipcMain.on('updateDesktopSetting', updateDesktopSetting) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe do ipcMain.on('updateDesktopSetting', (e, k, v) => updateDesktopSetting(k, v)) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. a new function... maybe more clearer, but us the definition is above it should be fine |
||
|
||
ipcMain.on('selectBackgroundImage', (e) => { | ||
dialog.showOpenDialog(undefined, { | ||
title: 'Select Background Image', | ||
filters: [ | ||
{ name: 'Images', extensions: ['jpg', 'png', 'gif'] }, | ||
{ name: 'All Files', extensions: ['*'] } | ||
], | ||
properties: ['openFile'] | ||
}, (filenames) => { | ||
if (!filenames) { return } | ||
log.info('BG-IMG Selected File:', filenames[0]) | ||
const newPath = path.join(getConfigPath(), 'background' + path.extname(filenames[0])) | ||
fs.copyFile(filenames[0], newPath, (err) => { | ||
if (err) { | ||
log.error('BG-IMG Copy Failed', err) | ||
return | ||
} | ||
updateDesktopSetting(null, 'chatViewBgImg', `url("${newPath}")`) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. .. and if so, remove |
||
}) | ||
}) | ||
}) | ||
|
||
ipcMain.on('updateCredentials', (e, credentials) => { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,7 @@ const MessageWrapper = require('./MessageWrapper') | |
const log = require('../../logger').getLogger('renderer/chatView') | ||
|
||
const { isDisplayableByRenderMedia } = require('./Attachment') | ||
const SettingsContext = require('../contexts/SettingsContext') | ||
|
||
const MutationObserver = window.MutationObserver | ||
|
||
|
@@ -23,7 +24,7 @@ const ChatViewWrapper = styled.div` | |
margin-top: 50px; | ||
background-image: ${props => props.theme.chatViewBgImgPath}; | ||
background-size: cover; | ||
background-color: ${props => props.theme.chatViewBg}; | ||
background-color: var(--chatViewBg); | ||
|
||
} | ||
` | ||
|
@@ -242,36 +243,44 @@ class ChatView extends React.Component { | |
render () { | ||
const { onDeadDropClick, chat } = this.props | ||
return ( | ||
<ChatViewWrapper | ||
style={{ gridTemplateRows: `auto ${this.state.composerSize}px` }} | ||
ref={this.ChatViewWrapperRef} onDrop={this.onDrop.bind({ props: { chat } })} onDragOver={this.onDragOver} > | ||
<ConversationWrapper> | ||
<div id='the-conversation' ref={this.conversationDiv}> | ||
<ul> | ||
{chat.messages.map(rawMessage => { | ||
const message = MessageWrapper.convert(rawMessage) | ||
message.onReply = () => log.debug('reply to', message) | ||
message.onForward = this.onForward.bind(this, message) | ||
return MessageWrapper.render({ | ||
message, | ||
chat, | ||
onClickContactRequest: () => onDeadDropClick(message), | ||
onClickSetupMessage: this.onClickSetupMessage.bind(this, message), | ||
onShowDetail: this.onShowDetail.bind(this, message), | ||
onClickAttachment: this.onClickAttachment.bind(this, message) | ||
}) | ||
})} | ||
</ul> | ||
</div> | ||
</ConversationWrapper> | ||
<Composer | ||
ref={this.refComposer} | ||
chatId={chat.id} | ||
draft={chat.draft} | ||
onSubmit={this.writeMessage} | ||
setComposerSize={this.setComposerSize.bind(this)} | ||
/> | ||
</ChatViewWrapper> | ||
<SettingsContext.Consumer> | ||
{(settings) => ( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is it possible to use hooks here? |
||
<ChatViewWrapper | ||
style={{ | ||
gridTemplateRows: `auto ${this.state.composerSize}px`, | ||
background: settings['chatViewBgImg'], | ||
backgroundSize: 'cover' | ||
}} | ||
ref={this.ChatViewWrapperRef} onDrop={this.onDrop.bind({ props: { chat } })} onDragOver={this.onDragOver} > | ||
<ConversationWrapper> | ||
<div id='the-conversation' ref={this.conversationDiv}> | ||
<ul> | ||
{chat.messages.map(rawMessage => { | ||
const message = MessageWrapper.convert(rawMessage) | ||
message.onReply = () => log.debug('reply to', message) | ||
message.onForward = this.onForward.bind(this, message) | ||
return MessageWrapper.render({ | ||
message, | ||
chat, | ||
onClickContactRequest: () => onDeadDropClick(message), | ||
onClickSetupMessage: this.onClickSetupMessage.bind(this, message), | ||
onShowDetail: this.onShowDetail.bind(this, message), | ||
onClickAttachment: this.onClickAttachment.bind(this, message) | ||
}) | ||
})} | ||
</ul> | ||
</div> | ||
</ConversationWrapper> | ||
<Composer | ||
ref={this.refComposer} | ||
chatId={chat.id} | ||
draft={chat.draft} | ||
onSubmit={this.writeMessage} | ||
setComposerSize={this.setComposerSize.bind(this)} | ||
/> | ||
</ChatViewWrapper> | ||
)} | ||
</SettingsContext.Consumer> | ||
) | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe remove
e
since we don't use it?