Skip to content

Commit 1fc646f

Browse files
committed
stop fetching months once you've reached the end
1 parent 291b73e commit 1fc646f

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

www/secmail/views/index.js.rb

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,18 +39,20 @@ def render
3939
end
4040
end
4141

42-
_input.btn.btn_primary type: 'submit', value: 'fetch previous month',
43-
onClick: self.fetch_month
42+
if @nextmbox
43+
_input.btn.btn_primary type: 'submit', value: 'fetch previous month',
44+
onClick: self.fetch_month
45+
end
4446

4547
unless @undoStack.empty?
4648
_input.btn.btn_info type: 'submit', value: 'undo delete',
4749
onClick: self.undo
4850
end
4951
end
5052

51-
# initialize latest mailbox (year+month)
53+
# initialize next mailbox (year+month)
5254
def componentWillMount()
53-
@latest = @@mbox
55+
@nextmbox = @@mbox
5456
end
5557

5658
# on initial load, fetch latest mailbox and subscribe to keyboard events
@@ -77,9 +79,9 @@ def componentDidUpdate()
7779

7880
# fetch a month's worth of messages
7981
def fetch_month()
80-
HTTP.post('', mbox: @latest) do |response|
82+
HTTP.post('', mbox: @nextmbox) do |response|
8183
# update latest mbox
82-
@latest = response.mbox if response.mbox
84+
@nextmbox = response.mbox
8385

8486
# add messages to list
8587
@messages = @messages.concat(*response.messages)

www/secmail/views/index.json.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525

2626
# return mailbox name and messages
2727
{
28-
mbox: File.basename(mbox, '.yml'),
28+
mbox: (File.basename(mbox, '.yml') if index > 0),
2929
messages: headers.sort_by {|message| message[:time]}.reverse
3030
}
3131
end

0 commit comments

Comments
 (0)