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()
}); });
}; };
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.InitOptions = function() {
this.soundNotifOptions(); this.soundNotifOptions();
this.volumeControl(); this.volumeControl();
@ -343,6 +355,7 @@ var TwisterOptions = function()
this.setHideCloseRTsHourOpt(); this.setHideCloseRTsHourOpt();
this.setHideCloseRTsOpt(); this.setHideCloseRTsOpt();
this.setIsFollowingMeOpt(); this.setIsFollowingMeOpt();
this.setDMCopySelfOpt();
} }
} }

27
js/twister_directmsg.js

@ -113,11 +113,28 @@ function directMsgSubmit(e)
function newDirectMsg(msg, dm_screenname) { function newDirectMsg(msg, dm_screenname) {
if( lastPostId != undefined ) { if( lastPostId != undefined ) {
var params = [defaultScreenName, lastPostId + 1, dm_screenname, msg] var paramsOrig = [defaultScreenName, lastPostId + 1, dm_screenname, msg]
twisterRpc("newdirectmsg", params, var paramsOpt = paramsOrig
function(arg, ret) { incLastPostId(); }, null, var copySelf = ($.Options.getDMCopySelfOpt() === 'enable')
function(arg, ret) { var msg = ("message" in ret) ? ret.message : ret; if( copySelf ) {
alert("Ajax error: " + msg); }, null); 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 { } else {
alert(polyglot.t("Internal error: lastPostId unknown (following yourself may fix!)")); alert(polyglot.t("Internal error: lastPostId unknown (following yourself may fix!)"));
} }

10
options.html

@ -263,6 +263,16 @@
</form> </form>
</div> </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> </div>
</div> </div>

Loading…
Cancel
Save