Skip to content

Commit bc520c3

Browse files
committed
Fix loading nicknames from existing config
1 parent 6380bdc commit bc520c3

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

lib/Synergy/User.pm

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,8 @@ has _nicknames => (
136136
is => 'ro',
137137
isa => 'ArrayRef[Str]',
138138
default => sub { [] },
139+
predicate => 'has_nicknames',
140+
init_arg => 'nicknames',
139141
);
140142

141143
sub nicknames ($self) {

lib/Synergy/UserDirectory.pm

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -341,9 +341,13 @@ sub load_preferences_from_user ($self, $username) {
341341
$self->set_user_preference($user, 'realname', $existing_real);
342342
}
343343

344-
unless ($self->user_has_preference($user, 'nicknames')) {
345-
my @nicks = $user->nicknames;
346-
$self->set_user_preference($user, 'nicknames', \@nicks);
344+
# If we have nicknames already, and those nicknames are from user config,
345+
# and we don't have a pref already...load them.
346+
my @existing_nicks = $user->has_nicknames ? $user->_nicknames->@* : undef;
347+
my $pref_nicks = $self->get_user_preference($user, 'nicknames') // [];
348+
349+
if (@existing_nicks && ! @$pref_nicks) {
350+
$self->set_user_preference($user, 'nicknames', \@existing_nicks);
347351
}
348352
}
349353

0 commit comments

Comments
 (0)