Angular Chat - Editing Messages with Functions
You can set the editing.allowDeleting and allowUpdating options to a Boolean value to toggle editing functionality.
Alternatively, you can customize conditions for when users can edit messages. For example, the following code snippet prevents editing or deleting messages that are more than five minutes old:
app.component.html
app.component.ts
- <dx-chat>
- <dxo-chat-editing
- [allowUpdating]="restrictEditing"
- [allowDeleting]="restrictEditing"
- ></dxo-chat-editing>
- </dx-chat>
- export class AppComponent {
- // ...
- restrictEditing(e) {
- if (Date.now() - e.message.timestamp < 5 * 60 * 1000) {
- return true;
- } else {
- return false;
- }
- };
- };
NOTE
A Boolean value must be returned if allowDeleting or allowUpdating are used as functions.