Browse Source

fix: store the uncasefolded account name correctly

tags/v0.11.0-beta
Shivaram Lingamneni 6 years ago
parent
commit
878f9ca94c
2 changed files with 11 additions and 13 deletions
  1. 3
    11
      irc/accounts.go
  2. 8
    2
      irc/getters.go

+ 3
- 11
irc/accounts.go View File

@@ -578,18 +578,10 @@ type rawClientAccount struct {
578 578
 
579 579
 // LoginToAccount logs the client into the given account.
580 580
 func (client *Client) LoginToAccount(account string) {
581
-	casefoldedAccount, err := CasefoldName(account)
582
-	if err != nil {
583
-		return
584
-	}
585
-
586
-	if client.Account() == casefoldedAccount {
587
-		// already logged into this acct, no changing necessary
588
-		return
581
+	changed := client.SetAccountName(account)
582
+	if changed {
583
+		client.nickTimer.Touch()
589 584
 	}
590
-
591
-	client.SetAccountName(casefoldedAccount)
592
-	client.nickTimer.Touch()
593 585
 }
594 586
 
595 587
 // LogoutOfAccount logs the client out of their current account.

+ 8
- 2
irc/getters.go View File

@@ -125,15 +125,21 @@ func (client *Client) AccountName() string {
125 125
 	return client.accountName
126 126
 }
127 127
 
128
-func (client *Client) SetAccountName(account string) {
128
+func (client *Client) SetAccountName(account string) (changed bool) {
129 129
 	var casefoldedAccount string
130
+	var err error
130 131
 	if account != "" {
131
-		casefoldedAccount, _ = CasefoldName(account)
132
+		if casefoldedAccount, err = CasefoldName(account); err != nil {
133
+			return
134
+		}
132 135
 	}
136
+
133 137
 	client.stateMutex.Lock()
134 138
 	defer client.stateMutex.Unlock()
139
+	changed = client.account != casefoldedAccount
135 140
 	client.account = casefoldedAccount
136 141
 	client.accountName = account
142
+	return
137 143
 }
138 144
 
139 145
 func (client *Client) HasMode(mode modes.Mode) bool {

Loading…
Cancel
Save