Skip to content

Commit 1b2f453

Browse files
authored
don't refetch on user creation (#274)
1 parent b2499c9 commit 1b2f453

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

config/config.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ func NewConfigHandler(options Options) *ConfigHandler {
111111
if !shouldRefetch(evt.New, evt.Old) {
112112
return
113113
}
114+
slog.Debug("User change detected that requires config refetch")
114115
if err := ch.fetchConfig(); err != nil {
115116
slog.Error("Failed to fetch config", "error", err)
116117
}
@@ -121,9 +122,8 @@ func NewConfigHandler(options Options) *ConfigHandler {
121122

122123
// shouldRefetch determines whether a config refetch is needed based on user ID and account type changes.
123124
func shouldRefetch(new, old common.UserInfo) bool {
124-
return new != old &&
125-
(new == nil || old == nil || // sanity check
126-
new.LegacyToken() != old.LegacyToken() || // user ID changed
125+
return new != nil && old != nil && old.LegacyID() != 0 &&
126+
(new.LegacyToken() != old.LegacyToken() || // user ID changed
127127
new.AccountType() != old.AccountType()) // changed between free and pro
128128
}
129129

@@ -170,7 +170,6 @@ func (ch *ConfigHandler) fetchConfig() error {
170170
if ch.isClosed() {
171171
return fmt.Errorf("config handler is closed")
172172
}
173-
slog.Debug("Fetching config")
174173
var preferred C.ServerLocation
175174
oldConfig, err := ch.GetConfig()
176175
if err != nil {

0 commit comments

Comments
 (0)