Display tor bridge enable button if all tracker connection fails

This commit is contained in:
shortcutme 2018-04-28 22:05:38 +02:00
parent 435210b73c
commit 26cb600ae3
No known key found for this signature in database
GPG key ID: 5B63BAE6CB9613AE
2 changed files with 19 additions and 2 deletions

View file

@ -3,7 +3,6 @@ class Loading
if window.show_loadingscreen then @showScreen()
@timer_hide = null
setProgress: (percent) ->
if @timer_hide
clearInterval @timer_hide
@ -28,13 +27,28 @@ class Loading
line = @printLine("Site size: <b>#{parseInt(site_info.settings.size/1024/1024)}MB</b> is larger than default allowed #{parseInt(site_info.size_limit)}MB", "warning")
button = $("<a href='#Set+limit' class='button button-setlimit'>" + "Open site and set size limit to #{site_info.next_size_limit}MB" + "</a>")
button.on "click", =>
button.addClass("loading")
return @wrapper.setSizeLimit(site_info.next_size_limit)
line.after(button)
setTimeout (=>
@printLine('Ready.')
), 100
showTrackerTorBridge: (server_info) ->
if $(".console .button-settrackerbridge").length == 0 and not server_info.tor_use_meek_bridges
line = @printLine("Tracker connection error detected.", "error")
button = $("<a href='#Enable+Tor+bridges' class='button button-settrackerbridge'>" + "Use Tor meek bridges for tracker connections" + "</a>")
button.on "click", =>
button.addClass("loading")
@wrapper.ws.cmd "configSet", ["tor_use_bridges", ""]
@wrapper.ws.cmd "configSet", ["trackers_proxy", "tor"]
@wrapper.ws.cmd "siteUpdate", @wrapper.site_info.address
@wrapper.reloadIframe()
return false
line.after(button)
if not server_info.tor_has_meek_bridges
button.addClass("disabled")
@printLine("No meek bridge support in your client, please <a href='https://github.com/HelloZeroNet/ZeroNet#how-to-join'>download the latest bundle</a>.", "warning")
# We dont need loadingscreen anymore
hideScreen: ->

View file

@ -548,6 +548,9 @@ class Wrapper
else
@announcer_line = @loading.printLine(status_line)
if status_db.error?.length == (key for key of announcer_info.stats).length
@loading.showTrackerTorBridge(@server_info)
updateProgress: (site_info) ->
if site_info.tasks > 0 and site_info.started_task_num > 0
@loading.setProgress 1-(Math.max(site_info.tasks, site_info.bad_files) / site_info.started_task_num)