-
Notifications
You must be signed in to change notification settings - Fork 230
[NEW] Message character limit feature #443
Changes from 4 commits
017a97d
bafb085
4c39979
becce00
12657f5
9b07d09
1c84f20
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 |
---|---|---|
|
@@ -182,6 +182,7 @@ export class App extends Component { | |
expanded, | ||
alerts, | ||
modal, | ||
config, | ||
}, { initialized }) => { | ||
if (!initialized) { | ||
return null; | ||
|
@@ -204,6 +205,7 @@ export class App extends Component { | |
onOpenWindow: this.handleOpenWindow, | ||
onDismissAlert: this.handleDismissAlert, | ||
dismissNotification: this.dismissNotification, | ||
limitTextLength: config.settings.limitTextLength, | ||
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. You don't need this here, the And then pass it through the components. |
||
}; | ||
|
||
return ( | ||
|
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -43,3 +43,13 @@ export const FooterOptions = ({ children }) => ( | |||||||||||||||||||||
{children} | ||||||||||||||||||||||
</PopoverMenu> | ||||||||||||||||||||||
); | ||||||||||||||||||||||
|
||||||||||||||||||||||
|
||||||||||||||||||||||
export const ReminderCharacters = ({ className, style = {}, textLenght, limitTextLength }) => ( | ||||||||||||||||||||||
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.
Suggested change
|
||||||||||||||||||||||
<span | ||||||||||||||||||||||
className={createClassName(styles, `footer__remainder${ textLenght === limitTextLength ? '-alert' : '' }`, {}, [className])} | ||||||||||||||||||||||
style={style} | ||||||||||||||||||||||
> | ||||||||||||||||||||||
{textLenght} / {limitTextLength} | ||||||||||||||||||||||
</span> | ||||||||||||||||||||||
); |
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -41,6 +41,16 @@ | |||||||||||||||||||||||
|
||||||||||||||||||||||||
@include pressable-button(2px); | ||||||||||||||||||||||||
} | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
&__remainder, &__remainder-alert { | ||||||||||||||||||||||||
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.
Suggested change
|
||||||||||||||||||||||||
margin-left: 10px; | ||||||||||||||||||||||||
min-width: 100px; | ||||||||||||||||||||||||
} | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
&__remainder-alert { | ||||||||||||||||||||||||
color: $color-red; | ||||||||||||||||||||||||
transition: color .2s; | ||||||||||||||||||||||||
} | ||||||||||||||||||||||||
} | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
.powered-by { | ||||||||||||||||||||||||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -2,7 +2,7 @@ import { Component } from 'preact'; | |||||
|
||||||
import { Composer, ComposerAction, ComposerActions } from '../../components/Composer'; | ||||||
import { FilesDropTarget } from '../../components/FilesDropTarget'; | ||||||
import { FooterOptions } from '../../components/Footer'; | ||||||
import { FooterOptions, ReminderCharacters } from '../../components/Footer'; | ||||||
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.
Suggested change
|
||||||
import { Menu } from '../../components/Menu'; | ||||||
import { MessageList } from '../../components/Messages'; | ||||||
import { Screen } from '../../components/Screen'; | ||||||
|
@@ -64,9 +64,13 @@ export default class Chat extends Component { | |||||
} | ||||||
|
||||||
handleChangeText = (text) => { | ||||||
this.setState({ text }); | ||||||
const { onChangeText } = this.props; | ||||||
onChangeText && onChangeText(text); | ||||||
let value = text; | ||||||
const { onChangeText, limitTextLength } = this.props; | ||||||
if (limitTextLength && limitTextLength < text.length) { | ||||||
value = value.substring(0, limitTextLength); | ||||||
} | ||||||
this.setState({ text: value }); | ||||||
onChangeText && onChangeText(value); | ||||||
} | ||||||
|
||||||
render = ({ | ||||||
|
@@ -89,6 +93,7 @@ export default class Chat extends Component { | |||||
onRemoveUserData, | ||||||
lastReadMessageId, | ||||||
queueInfo, | ||||||
limitTextLength, | ||||||
...props | ||||||
}, { | ||||||
atBottom = true, | ||||||
|
@@ -143,6 +148,11 @@ export default class Chat extends Component { | |||||
</Menu.Group> | ||||||
</FooterOptions> | ||||||
) : null} | ||||||
limit={limitTextLength | ||||||
? <ReminderCharacters | ||||||
limitTextLength={limitTextLength} | ||||||
textLenght={text.length} | ||||||
/> : null} | ||||||
> | ||||||
<Composer onUpload={onUpload} | ||||||
onSubmit={this.handleSubmit} | ||||||
|
@@ -162,14 +172,15 @@ export default class Chat extends Component { | |||||
<ComposerAction onClick={this.handleUploadClick}> | ||||||
<PlusIcon width={20} /> | ||||||
</ComposerAction> | ||||||
)} | ||||||
)}1 | ||||||
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. ?? 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. @oguhpereira what's the reason to add the |
||||||
{text.length > 0 && ( | ||||||
<ComposerAction onClick={this.handleSendClick}> | ||||||
<SendIcon width={20} /> | ||||||
</ComposerAction> | ||||||
)} | ||||||
</ComposerActions> | ||||||
)} | ||||||
limitTextLength={limitTextLength} | ||||||
/> | ||||||
</Screen.Footer> | ||||||
</FilesDropTarget> | ||||||
|
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.
You don't need this here, the
StoreConsumer
is propagating theconfig
prop to the App components.