Browse Source

Direct Message's copy to self feature (requires twisterd 0.9.26)

master
Miguel Freitas 10 years ago
parent
commit
df66f54f2b
  1. 13
      js/options.js
  2. 27
      js/twister_directmsg.js
  3. 10
      options.html

13
js/options.js

@ -323,6 +323,18 @@ var TwisterOptions = function() @@ -323,6 +323,18 @@ var TwisterOptions = function()
});
};
this.getDMCopySelfOpt = function() {
return $.Options.getOption('dmCopySelf',"enable");
}
this.setDMCopySelfOpt = function () {
$('#dmCopySelfOpt select')[0].value = this.getDMCopySelfOpt();
$('#dmCopySelfOpt select').on('change', function(){
$.Options.setOption(this.id, this.value);
});
}
this.InitOptions = function() {
this.soundNotifOptions();
this.volumeControl();
@ -343,6 +355,7 @@ var TwisterOptions = function() @@ -343,6 +355,7 @@ var TwisterOptions = function()
this.setHideCloseRTsHourOpt();
this.setHideCloseRTsOpt();
this.setIsFollowingMeOpt();
this.setDMCopySelfOpt();
}
}

27
js/twister_directmsg.js

@ -113,11 +113,28 @@ function directMsgSubmit(e) @@ -113,11 +113,28 @@ function directMsgSubmit(e)
function newDirectMsg(msg, dm_screenname) {
if( lastPostId != undefined ) {
var params = [defaultScreenName, lastPostId + 1, dm_screenname, msg]
twisterRpc("newdirectmsg", params,
function(arg, ret) { incLastPostId(); }, null,
function(arg, ret) { var msg = ("message" in ret) ? ret.message : ret;
alert("Ajax error: " + msg); }, null);
var paramsOrig = [defaultScreenName, lastPostId + 1, dm_screenname, msg]
var paramsOpt = paramsOrig
var copySelf = ($.Options.getDMCopySelfOpt() === 'enable')
if( copySelf ) {
paramsOpt = paramsOrig.concat(true)
}
twisterRpc("newdirectmsg", paramsOpt,
function(arg, ret) {
incLastPostId();
if( arg.copySelf ) incLastPostId();
}, {copySelf:copySelf},
function(arg, ret) {
// fallback for older twisterd (error: no copy_self parameter)
twisterRpc("newdirectmsg", arg.paramsOrig,
function(arg, ret) { incLastPostId(); }, null,
function(arg, ret) {
var msg = ("message" in ret) ? ret.message : ret;
alert("Ajax error: " + msg);
}, null);
}, {paramsOrig:paramsOrig}
);
} else {
alert(polyglot.t("Internal error: lastPostId unknown (following yourself may fix!)"));
}

10
options.html

@ -263,6 +263,16 @@ @@ -263,6 +263,16 @@
</form>
</div>
<div>
<form action="" id="dmCopySelfOpt">
<p class="label">Direct Message's copy to self</p>
<select name="" id="dmCopySelf">
<option value="disable">Disable</option>
<option value="enable">Enable</option>
</select>
</form>
</div>
</div>
</div>
</div>

Loading…
Cancel
Save