Browse Source

Improve broken auto-reload

pull/40/head
discomrade 3 years ago
parent
commit
0fcd1d03f1
  1. 4
      js/ajax.js
  2. 18
      js/auto-reload.js

4
js/ajax.js

@ -80,7 +80,6 @@ $(window).ready(function() {
|| (!settings.get('always_noko_replies', true) && !post_response.noko)) {
document.location = post_response.redirect;
} else {
/*
$.ajax({
url: document.location,
success: function(data) {
@ -89,6 +88,8 @@ $(window).ready(function() {
if($('#' + id).length == 0) {
$(this).insertAfter($('div.post:last').next()).after('<br class="clear">');
$(document).trigger('new_post', this);
// auto-reload.js immediate update on own post
$(document).trigger('own_new_post', this);
// watch.js & auto-reload.js retrigger
setTimeout(function() { $(window).trigger("scroll"); }, 100);
}
@ -107,7 +108,6 @@ $(window).ready(function() {
contentType: false,
processData: false
}, 'html');
*/
}
$(form).find('input[type="submit"]').val(_('Posted...'));
$(document).trigger("ajax_after_post", post_response);

18
js/auto-reload.js

@ -75,7 +75,6 @@ $(document).ready(function(){
if (!("Notification" in window)) return;
var setting = $(this).parent().attr('id');
if ($(this).is(':checked')) {
Notification.requestPermission(function(permission){
if (permission === "granted") {
@ -166,7 +165,6 @@ $(document).ready(function(){
window_active = false;
});
$('#auto_update_status').click(function() {
if($("#auto_update_status").is(':checked')) {
auto_update(poll_interval_mindelay);
@ -177,7 +175,6 @@ $(document).ready(function(){
});
var decrement_timer = function() {
poll_current_time = poll_current_time - 1000;
$('#update_secs').text(poll_current_time/1000);
@ -230,6 +227,7 @@ $(document).ready(function(){
$('#update_secs').text(_("Updating..."));
$.ajax({
cache: !manualUpdate,
url: document.location,
success: function(data) {
var loaded_posts = 0; // the number of new posts loaded in this update
@ -262,7 +260,6 @@ $(document).ready(function(){
time_loaded = Date.now(); // interop with watch.js
if ($('#auto_update_status').is(':checked')) {
// If there are no new posts, double the delay. Otherwise set it to the min.
if(loaded_posts == 0) {
@ -315,13 +312,11 @@ $(document).ready(function(){
return false;
};
$(post).on('submit', function(e){
setTimeout(
function() {
poll(manualUpdate = true)
},
500
);
$(document).on('own_new_post', function(e){
//prevent automatic window scroll from double updating
epochold = epoch = (new Date).getTime();
poll(manualUpdate = true);
});
$(window).scrollStopped(function() {
@ -338,6 +333,7 @@ $(document).ready(function(){
recheck_activated(end_of_page);
});
$('#update_thread').on('click', function() { poll(manualUpdate = true); return false; });
if($("#auto_update_status").is(':checked')) {

Loading…
Cancel
Save