Skip to content

Commit

Permalink
Set the first account as active if removing and there are no active a…
Browse files Browse the repository at this point in the history
…ccounts
  • Loading branch information
jnunemaker committed Jul 26, 2008
1 parent dbc9e57 commit 8cfec0f
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 1 deletion.
2 changes: 2 additions & 0 deletions History.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
0.3.2 - July 26, 2008
* added the CLI gems as dependencies for now until I separate out the CLI from the API wrapper
* cleaner CLI errors for no active account or no accounts at all
* remove sets a new active account if there are none


0.3.1 - July 23, 2008
Expand Down
1 change: 0 additions & 1 deletion TODO.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
* if removing the current account, set a new one
* import from .twitter
* add timeout so it doesn't hang forever like it does now if twitter is down
* add progress indicator for timeline and replies as posting has for more visual indication that work is happening
1 change: 1 addition & 0 deletions lib/twitter/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ def run
account = account_id ? Account.find(account_id) : account
account_name = account.username
account.destroy
Account.set_current(Account.first) if Account.new_active_needed?
say "#{account_name} has been removed.\n"
rescue ActiveRecord::RecordNotFound
say "ERROR: Account could not be found. Try again. \n"
Expand Down
4 changes: 4 additions & 0 deletions lib/twitter/cli/models/account.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ def self.set_current(account_or_id)
account
end

def self.new_active_needed?
self.current.count == 0 && self.count > 0
end

def to_s
"#{current? ? '*' : ' '} #{username}"
end
Expand Down

0 comments on commit 8cfec0f

Please sign in to comment.