Auto Watch on thread creation.

This commit is contained in:
Nicolas Stepien 2012-01-26 04:15:42 +01:00
parent 76cb2b4f9a
commit 8cd6598e00
2 changed files with 19 additions and 5 deletions

View File

@ -1724,7 +1724,10 @@
$.set('qr.persona', persona);
_ref = b.lastChild.textContent.match(/thread:(\d+),no:(\d+)/), _ = _ref[0], thread = _ref[1], postNumber = _ref[2];
if (thread === '0') {
window.open("/" + g.BOARD + "/res/" + postNumber, '_self');
if (conf['Thread Watcher'] && conf['Auto Watch']) {
$.set('autoWatch', postNumber);
}
location.pathname = "/" + g.BOARD + "/res/" + postNumber;
} else {
qr.cooldown.auto = qr.replies.length > 1;
qr.cooldown.set(/sage/i.test(reply.email) ? 60 : 30);
@ -2381,7 +2384,12 @@
$.on(favicon, 'click', watcher.cb.toggle);
$.before(input, favicon);
}
watcher.refresh();
if (g.THREAD_ID === $.get('autoWatch', 0)) {
watcher.watch(g.THREAD_ID);
$["delete"]('autoWatch');
} else {
watcher.refresh();
}
return $.on(window, 'storage', function(e) {
if (e.key === ("" + NAMESPACE + "watched")) return watcher.refresh();
});

View File

@ -1300,8 +1300,10 @@ qr =
[_, thread, postNumber] = b.lastChild.textContent.match /thread:(\d+),no:(\d+)/
if thread is '0' # new thread
if conf['Thread Watcher'] and conf['Auto Watch']
$.set 'autoWatch', postNumber
# auto-noko
window.open "/#{g.BOARD}/res/#{postNumber}", '_self'
location.pathname = "/#{g.BOARD}/res/#{postNumber}"
else
# Enable auto-posting if we have stuff to post, disable it otherwise.
qr.cooldown.auto = qr.replies.length > 1
@ -1862,8 +1864,12 @@ watcher =
$.on favicon, 'click', watcher.cb.toggle
$.before input, favicon
#populate watcher, display watch buttons
watcher.refresh()
if g.THREAD_ID is $.get 'autoWatch', 0
watcher.watch g.THREAD_ID
$.delete 'autoWatch'
else
#populate watcher, display watch buttons
watcher.refresh()
$.on window, 'storage', (e) -> watcher.refresh() if e.key is "#{NAMESPACE}watched"