Skip to content

Commit

Permalink
Merge pull request #323 from S--Minecraft/issue/299
Browse files Browse the repository at this point in the history
Update: ブックマーク更新の高速化とリファクタリング close #299
  • Loading branch information
S--Minecraft authored Jun 1, 2017
2 parents 8d06776 + e872734 commit 657fda9
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 27 deletions.
1 change: 0 additions & 1 deletion src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,6 @@ namespace app {
["image_replace_dat", "^https?:\\/\\/(?:www\\.youtube\\.com\\/watch\\?(?:.+&)?v=|youtu\\.be\\/)([\\w\\-]+).*\thttps://img.youtube.com/vi/$1/default.jpg\nhttp:\\/\\/(?:www\\.)?nicovideon?\\.jp\\/(?:(?:watch|thumb)(?:_naisho)?(?:\\?v=|\\/)|\\?p=)(?!am|fz)[a-z]{2}(\\d+)\thttp://tn-skr.smilevideo.jp/smile?i=$1\n\\.(png|jpe?g|gif|bmp|webp)([\\?#:].*)?$\t.$1$2"],
["replace_str_txt_obj", "[]"],
["replace_str_txt", ""],
["max_connection", "4"],
["last_information", "0"],
["information_count", "0"]
]);
Expand Down
31 changes: 11 additions & 20 deletions src/view/bookmark.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -53,23 +53,20 @@ app.boot "/view/bookmark.html", ->

count =
all: board_list.size
loading: 0
success: 0
error: 0

loadingServer = {}
loadingServer = new Set()

fn = (res) ->
if res?
delete loadingServer[app.URL.getDomain(@prev)]
count.loading--
loadingServer.delete(app.URL.getDomain(@prev))
status = if res.status is "success" then "success" else "error"
count[status]++
if status is "error"
for board in board_thread_table.get(@prev)
app.message.send("bookmark_updated", {type: "errored", bookmark: {type: "thread", url: board}, entry: {type: "thread"}})

maxCon = app.config.get("max_connection")
if count.all is count.success + count.error
#更新完了
#ソート後にブックマークが更新されてしまう場合に備えて、少し待つ
Expand All @@ -89,26 +86,20 @@ app.boot "/view/bookmark.html", ->
, 1000 * 10)
return
, 500)
# 合計最大同時接続数: 2
# 同一サーバーへの最大接続数: 1
else if count.loading < maxCon
keys = board_list.values()
while !(board = keys.next()).done
current = board.value
server = app.URL.getDomain(current)
continue if loadingServer[server]
loadingServer[server] = true
board_list.delete(current)
count.loading++
app.board.get(current, fn.bind(prev: current))
fn()
break
for board from board_list.values()
server = app.URL.getDomain(board)
continue if loadingServer.has(server)
loadingServer.add(server)
board_list.delete(board)
app.board.get(board, fn.bind(prev: board))
fn()
break

#ステータス表示更新
$loading_overlay.find(".success").text(count.success)
$loading_overlay.find(".error").text(count.error)
$loading_overlay.find(".loading").text(count.loading)
$loading_overlay.find(".pending").text(count.all - count.success - count.error - count.loading)
$loading_overlay.find(".pending").text(count.all - count.success - count.error)
return

fn()
Expand Down
6 changes: 0 additions & 6 deletions src/view/bookmark.scss
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,6 @@ td {
content: "待機中: ";
}
}
> .loading {
color: $color-loading;
&::before {
content: "更新中: ";
}
}
> .success {
color: $color-success;
&::before {
Expand Down

0 comments on commit 657fda9

Please sign in to comment.