diff --git a/src/views/components/MessageReact.js b/src/views/components/MessageReact.js new file mode 100644 index 0000000..ffc8ba5 --- /dev/null +++ b/src/views/components/MessageReact.js @@ -0,0 +1,116 @@ +export default { + name: 'ReactMessage', + data() { + return { + type: 'user', + phone: '', + message_id: '', + emoji: '', + loading: false, + } + }, + computed: { + phone_id() { + return this.type === 'user' ? `${this.phone}@${window.TYPEUSER}` : `${this.phone}@${window.TYPEGROUP}` + } + }, + methods: { + messageModal() { + $('#modalMessageReaction').modal({ + onApprove: function () { + return false; + } + }).modal('show'); + }, + async messageProcess() { + try { + let response = await this.messageApi() + showSuccessInfo(response) + $('#modalMessageReaction').modal('hide'); + } catch (err) { + showErrorInfo(err) + } + }, + messageApi() { + return new Promise(async (resolve, reject) => { + try { + this.loading = true; + let payload = new FormData(); + payload.append("phone", this.phone_id) + payload.append("emoji", this.emoji) + let response = await http.post(`/message/${this.message_id}/reaction`, payload) + this.messageReset(); + resolve(response.data.message) + } catch (error) { + if (error.response) { + reject(error.response.data.message) + } else { + reject(error.message) + } + } finally { + this.loading = false; + } + }) + }, + messageReset() { + this.phone = ''; + this.message_id = ''; + this.emoji = ''; + this.type = 'user'; + }, + }, + template: ` +
+
+ Message +
React Message
+
+ any message in private or group chat +
+
+
+ + + + + ` +} \ No newline at end of file diff --git a/src/views/components/MessageRevoke.js b/src/views/components/MessageRevoke.js new file mode 100644 index 0000000..a0c9f68 --- /dev/null +++ b/src/views/components/MessageRevoke.js @@ -0,0 +1,107 @@ +export default { + name: 'Message', + data() { + return { + type: 'user', + phone: '', + message_id: '', + loading: false, + } + }, + computed: { + phone_id() { + return this.type === 'user' ? `${this.phone}@${window.TYPEUSER}` : `${this.phone}@${window.TYPEGROUP}` + } + }, + methods: { + messageModal() { + $('#modalMessageRevoke').modal({ + onApprove: function () { + return false; + } + }).modal('show'); + }, + async messageProcess() { + try { + let response = await this.messageApi() + showSuccessInfo(response) + $('#modalMessageRevoke').modal('hide'); + } catch (err) { + showErrorInfo(err) + } + }, + messageApi() { + return new Promise(async (resolve, reject) => { + try { + this.loading = true; + let payload = new FormData(); + payload.append("phone", this.phone_id) + let response = await http.post(`/message/${this.message_id}/revoke`, payload) + this.messageReset(); + resolve(response.data.message) + } catch (error) { + if (error.response) { + reject(error.response.data.message) + } else { + reject(error.message) + } + } finally { + this.loading = false; + } + }) + }, + messageReset() { + this.phone = ''; + this.message_id = ''; + this.type = 'user'; + }, + }, + template:` +
+
+ Message +
Revoke Message
+
+ any message in private or group chat +
+
+
+ + + + ` +} \ No newline at end of file diff --git a/src/views/components/MessageUpdate.js b/src/views/components/MessageUpdate.js index 6ca4644..4c8ca5e 100644 --- a/src/views/components/MessageUpdate.js +++ b/src/views/components/MessageUpdate.js @@ -1,48 +1,48 @@ export default { - name: 'Update Message', + name: 'UpdateMessage', data() { return { - update_type: 'user', - update_phone: '', - update_message_id: '', - update_new_message: '', - update_loading: false, + type: 'user', + phone: '', + message_id: '', + new_message: '', + loading: false, } }, computed: { - update_phone_id() { - return this.update_type === 'user' ? `${this.update_phone}@${window.TYPEUSER}` : `${this.update_phone}@${window.TYPEGROUP}` + phone_id() { + return this.type === 'user' ? `${this.phone}@${window.TYPEUSER}` : `${this.phone}@${window.TYPEGROUP}` } }, methods: { - messageEditModal() { - $('#modalMessageEdit').modal({ + messageModal() { + $('#modalMessageUpdate').modal({ onApprove: function () { return false; } }).modal('show'); }, - async messageEditProcess() { + async messageProcess() { try { - let response = await this.messageEditApi() + let response = await this.messageApi() showSuccessInfo(response) - $('#modalMessageEdit').modal('hide'); + $('#modalMessageUpdate').modal('hide'); } catch (err) { showErrorInfo(err) } }, - messageEditApi() { + messageApi() { return new Promise(async (resolve, reject) => { try { - this.update_loading = true; + this.loading = true; const payload = { - phone: this.update_phone_id, - message: this.update_new_message + phone: this.phone_id, + message: this.new_message } - let response = await http.post(`/message/${this.update_message_id}/update`, payload) - this.messageEditReset(); + let response = await http.post(`/message/${this.message_id}/update`, payload) + this.messageReset(); resolve(response.data.message) } catch (error) { if (error.response) { @@ -51,31 +51,31 @@ export default { reject(error.message) } } finally { - this.update_loading = false; + this.loading = false; } }) }, - messageEditReset() { - this.update_type = 'user'; - this.update_phone = ''; - this.update_message_id = ''; - this.update_new_message = ''; - this.update_loading = false; + messageReset() { + this.type = 'user'; + this.phone = ''; + this.message_id = ''; + this.new_message = ''; + this.loading = false; }, }, template: ` -
+
Message -
Edit Message
+
Update Message
Update your sent message
- -