Skip to main content
Glama
MessageDelete.js3.48 kB
import FormRecipient from "./generic/FormRecipient.js"; export default { name: 'DeleteMessage', components: { FormRecipient }, data() { return { type: window.TYPEUSER, phone: '', message_id: '', loading: false, } }, computed: { phone_id() { return this.phone + this.type; } }, methods: { openModal() { $('#modalMessageDelete').modal({ onApprove: function () { return false; } }).modal('show'); }, isValidForm() { if (this.type !== window.TYPESTATUS && !this.phone.trim()) { return false; } if (!this.message_id.trim()) { return false; } return true; }, async handleSubmit() { if (!this.isValidForm() || this.loading) { return; } try { let response = await this.submitApi() showSuccessInfo(response) $('#modalMessageDelete').modal('hide'); } catch (err) { showErrorInfo(err) } }, async submitApi() { this.loading = true; try { const payload = {phone: this.phone_id, message: this.new_message} let response = await window.http.post(`/message/${this.message_id}/delete`, payload) this.handleReset(); return response.data.message; } catch (error) { if (error.response) { throw new Error(error.response.data.message); } throw new Error(error.message); } finally { this.loading = false; } }, handleReset() { this.type = window.TYPEUSER; this.phone = ''; this.message_id = ''; this.new_message = ''; this.loading = false; }, }, template: ` <div class="red card" @click="openModal()" style="cursor: pointer"> <div class="content"> <a class="ui red right ribbon label">Message</a> <div class="header">Delete Message</div> <div class="description"> Delete your sent message </div> </div> </div> <!-- Modal MessageDelete --> <div class="ui small modal" id="modalMessageDelete"> <i class="close icon"></i> <div class="header"> Delete Message </div> <div class="content"> <form class="ui form"> <FormRecipient v-model:type="type" v-model:phone="phone"/> <div class="field"> <label>Message ID</label> <input v-model="message_id" type="text" placeholder="Please enter your message id" aria-label="message id"> </div> </form> </div> <div class="actions"> <button class="ui approve positive right labeled icon button" :class="{'loading': this.loading, 'disabled': !isValidForm() || loading}" @click.prevent="handleSubmit"> Delete <i class="send icon"></i> </button> </div> </div> ` }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/samihalawa/whatsapp-go-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server