forked from GladysAssistant/Gladys
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve chat page UX (GladysAssistant#596)
Fix GladysAssistant#588 : Messages are re-ordered on receive
- Loading branch information
1 parent
5a05b22
commit 3c69a29
Showing
7 changed files
with
190 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,67 +1,101 @@ | ||
import { Text } from 'preact-i18n'; | ||
import { Text, Localizer } from 'preact-i18n'; | ||
import cx from 'classnames'; | ||
import { connect } from 'unistore/preact'; | ||
import actions from '../../actions/message'; | ||
import { RequestStatus } from '../../utils/consts'; | ||
import ChatItems from './ChatItems'; | ||
import EmptyChat from './EmptyChat'; | ||
|
||
const IntegrationPage = connect( | ||
'user,messages,currentMessageTextInput,gladysIsTyping', | ||
'user,messages,currentMessageTextInput,gladysIsTyping,MessageGetStatus', | ||
actions | ||
)(({ user, messages, currentMessageTextInput, updateMessageTextInput, onKeyPress, sendMessage, gladysIsTyping }) => ( | ||
<div class="page"> | ||
<div class="page-main"> | ||
<div class="my-3 my-md-5"> | ||
<div class="container"> | ||
<div class="page-header" /> | ||
<div class="row"> | ||
<div class="col-lg-8"> | ||
<div class="card"> | ||
<ChatItems user={user} messages={messages} gladysIsTyping={gladysIsTyping} /> | ||
<div class="card-footer"> | ||
<div class="input-group"> | ||
<input | ||
type="text" | ||
class="form-control" | ||
placeholder="Message" | ||
value={currentMessageTextInput} | ||
onInput={updateMessageTextInput} | ||
onKeyPress={onKeyPress} | ||
/> | ||
<div class="input-group-append"> | ||
<button type="button" class="btn btn-secondary" onClick={sendMessage}> | ||
<i class="fe fe-send" /> | ||
</button> | ||
)( | ||
({ | ||
user, | ||
messages, | ||
MessageGetStatus, | ||
currentMessageTextInput, | ||
updateMessageTextInput, | ||
onKeyPress, | ||
sendMessage, | ||
gladysIsTyping | ||
}) => ( | ||
<div class="page"> | ||
<div class="page-main"> | ||
<div class="my-3 my-md-5"> | ||
<div class="container"> | ||
<div class="page-header" /> | ||
<div class="row"> | ||
<div class="col-lg-8"> | ||
<div class="card"> | ||
<div | ||
class={cx('dimmer', { | ||
active: MessageGetStatus === RequestStatus.Getting | ||
})} | ||
> | ||
<div class="loader" /> | ||
<div class="dimmer-content"> | ||
{messages && messages.length ? ( | ||
<ChatItems user={user} messages={messages} gladysIsTyping={gladysIsTyping} /> | ||
) : ( | ||
<EmptyChat /> | ||
)} | ||
<div class="card-footer"> | ||
<div class="input-group"> | ||
<Localizer> | ||
<input | ||
type="text" | ||
class="form-control" | ||
placeholder={<Text id="chat.messagePlaceholder" />} | ||
value={currentMessageTextInput} | ||
onInput={updateMessageTextInput} | ||
onKeyPress={onKeyPress} | ||
/> | ||
</Localizer> | ||
<div class="input-group-append"> | ||
<button | ||
type="button" | ||
class="btn btn-secondary" | ||
onClick={sendMessage} | ||
disabled={!currentMessageTextInput || currentMessageTextInput.length === 0} | ||
> | ||
<i class="fe fe-send" /> | ||
</button> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
<div class="col-lg-4"> | ||
<div class="card"> | ||
<div class="card-header"> | ||
<h3 class="card-title"> | ||
<Text id="chat.whatCanYouAsk" /> | ||
</h3> | ||
</div> | ||
<div class="card-body"> | ||
<ul> | ||
<li> | ||
"<Text id="chat.whatsTheWeatherLike" />" | ||
</li> | ||
<li> | ||
"<Text id="chat.showCameraImage" />" | ||
</li> | ||
<li> | ||
"<Text id="chat.whatsTheTemperatureKitchen" />" | ||
</li> | ||
</ul> | ||
<div class="col-lg-4"> | ||
<div class="card"> | ||
<div class="card-header"> | ||
<h3 class="card-title"> | ||
<Text id="chat.whatCanYouAsk" /> | ||
</h3> | ||
</div> | ||
<div class="card-body"> | ||
<ul> | ||
<li> | ||
"<Text id="chat.whatsTheWeatherLike" />" | ||
</li> | ||
<li> | ||
"<Text id="chat.showCameraImage" />" | ||
</li> | ||
<li> | ||
"<Text id="chat.whatsTheTemperatureKitchen" />" | ||
</li> | ||
</ul> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
)); | ||
) | ||
); | ||
|
||
export default IntegrationPage; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { Text } from 'preact-i18n'; | ||
|
||
const Messages = ({ children, ...props }) => ( | ||
<div | ||
style={{ | ||
width: '40%', | ||
maxWidth: '200px', | ||
marginLeft: 'auto', | ||
marginRight: 'auto', | ||
marginTop: '60px', | ||
marginBottom: '60px', | ||
textAlign: 'center' | ||
}} | ||
> | ||
<img | ||
src="/assets/images/undraw_typing.svg" | ||
style={{ | ||
marginLeft: 'auto', | ||
marginRight: 'auto', | ||
display: 'block' | ||
}} | ||
/> | ||
<p | ||
style={{ | ||
marginTop: '20px' | ||
}} | ||
> | ||
<Text id="chat.emptyStateMessage" /> | ||
</p> | ||
</div> | ||
); | ||
|
||
export default Messages; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters