mirror of
https://github.com/twisterarmy/twister-html.git
synced 2025-03-12 05:21:18 +00:00
Direct Message's copy to self feature (requires twisterd 0.9.26)
This commit is contained in:
parent
f3b82534e4
commit
df66f54f2b
@ -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()
|
||||
this.setHideCloseRTsHourOpt();
|
||||
this.setHideCloseRTsOpt();
|
||||
this.setIsFollowingMeOpt();
|
||||
this.setDMCopySelfOpt();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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
10
options.html
@ -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…
x
Reference in New Issue
Block a user