2020-09-10 07:33:00 +02:00
|
|
|
import { __ } from '../i18n';
|
2021-04-14 22:56:59 +02:00
|
|
|
import { directive, html } from "lit";
|
2020-05-15 14:33:31 +02:00
|
|
|
|
|
|
|
|
|
|
|
const i18n_retract_message = __('Retract this message');
|
2023-02-15 14:19:48 +01:00
|
|
|
const tplRetract = (o) => html`
|
2020-05-15 14:33:31 +02:00
|
|
|
<button class="chat-msg__action chat-msg__action-retract" title="${i18n_retract_message}" @click=${o.onMessageRetractButtonClicked}>
|
2020-07-01 15:51:21 +02:00
|
|
|
<converse-icon
|
|
|
|
class="fas fa-trash-alt"
|
|
|
|
color="var(--text-color-lighten-15-percent)"
|
|
|
|
size="1em"
|
|
|
|
></converse-icon>
|
2020-05-15 14:33:31 +02:00
|
|
|
</button>
|
|
|
|
`;
|
|
|
|
|
|
|
|
|
|
|
|
export const renderRetractionLink = directive(o => async part => {
|
|
|
|
const may_be_moderated = o.model.get('type') === 'groupchat' && await o.model.mayBeModerated();
|
|
|
|
const retractable = !o.is_retracted && (o.model.mayBeRetracted() || may_be_moderated);
|
|
|
|
|
|
|
|
if (retractable) {
|
2023-02-15 14:19:48 +01:00
|
|
|
part.setValue(tplRetract(o));
|
2020-05-15 14:33:31 +02:00
|
|
|
} else {
|
|
|
|
part.setValue('');
|
|
|
|
}
|
|
|
|
part.commit();
|
|
|
|
});
|