Browse Source

Refactor and simplify the message edition logic

pull/933/head
Timothée Jaussoin 6 years ago
parent
commit
d829cd4ca6
  1. 3
      app/Info.php
  2. 15
      app/widgets/Chat/Chat.php
  3. 8
      app/widgets/Chat/chat.js
  4. 2
      lib/moxl/src/Moxl/Xec/Payload/Presence.php

3
app/Info.php

@ -18,6 +18,9 @@ class Info extends Model
public function save(array $options = [])
{
// Empty features, we're not saving anything
if (empty($this->attributes['features'])) return;
try {
unset($this->identities);
parent::save($options);

15
app/widgets/Chat/Chat.php

@ -425,16 +425,11 @@ class Chat extends \Movim\Widget\Base
* @param string $message
* @return void
*/
public function ajaxHttpDaemonCorrect($to, $message, $mid = false)
public function ajaxHttpDaemonCorrect($to, $message, $mid)
{
$replace = $mid
? $this->user->messages()
->where('mid', $mid)
->first()
: $this->user->messages()
->where('jidto', $to)
->orderBy('published', 'desc')
->first();
$replace = $this->user->messages()
->where('mid', $mid)
->first();
if ($replace) {
$this->ajaxHttpDaemonSendMessage($to, $message, false, false, $replace);
@ -554,7 +549,7 @@ class Chat extends \Movim\Widget\Base
if (!isset($m->sticker)
&& !isset($m->file)) {
$this->rpc('Chat.setTextarea', htmlspecialchars_decode($m->body));
$this->rpc('Chat.setTextarea', htmlspecialchars_decode($m->body), $m->mid);
}
}
/**

8
app/widgets/Chat/chat.js

@ -132,12 +132,8 @@ var Chat = {
if (Chat.edit) {
Chat.edit = false;
if (textarea.dataset.mid) {
xhr = Chat_ajaxHttpDaemonCorrect(jid, text, textarea.dataset.mid);
delete textarea.dataset.mid;
} else {
xhr = Chat_ajaxHttpDaemonCorrect(jid, text);
}
xhr = Chat_ajaxHttpDaemonCorrect(jid, text, textarea.dataset.mid);
delete textarea.dataset.mid;
} else {
xhr = Chat_ajaxHttpDaemonSendMessage(jid, text, muc);
}

2
lib/moxl/src/Moxl/Xec/Payload/Presence.php

@ -71,8 +71,8 @@ class Presence extends Payload
$this->pack($presence->roster);
if ($presence->value == 5 /*|| $p->value == 6*/) {
PresenceBuffer::getInstance()->remove($presence);
$presence->delete();
PresenceBuffer::getInstance()->remove($presence);
}
}

Loading…
Cancel
Save