Skip to content

Commit

Permalink
fix(aliases): Making aliases API endpoints do one job each
Browse files Browse the repository at this point in the history
  • Loading branch information
castaway committed Jan 17, 2024
1 parent 3772c89 commit 419f00c
Showing 1 changed file with 27 additions and 20 deletions.
47 changes: 27 additions & 20 deletions src/app/rmm/alias.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,29 +30,36 @@ export class Alias {
) {
}
load(): Observable<any> {
this.app.ua.http.get('/rest/v1/aliases/limits').subscribe(
res => {
this.aliases_counter = {
total: res['result'].total,
current: res['result'].current,
};
},
error => {
return this.app.show_error('Could not load alias limits', 'Dismiss');
}
);

const req = this.app.ua.http.get('/rest/v1/aliases', {}).pipe(timeout(60000), share());
req.subscribe(
data => {
const reply = data;
if ( reply['status'] === 'error' ) {
this.app.show_error( reply['error'].join( '' ), 'Dismiss' );
return;
}
this.aliases = reply['result'].aliases;
const _unique = {};
for ( const value of this.aliases ) {
_unique[ value.localpart + '@' + value.domain ] = 1;
reply => {
if ( reply['status'] === 'error' ) {
this.app.show_error( reply['error'].join( '' ), 'Dismiss' );
return;
}
this.aliases = reply['result'].aliases;
const _unique = {};
for ( const value of this.aliases ) {
_unique[ value.localpart + '@' + value.domain ] = 1;
}
this.aliases_unique = Object.keys(_unique);
return;
},
error => {
return this.app.show_error('Could not load aliases.', 'Dismiss');
}
this.aliases_unique = Object.keys(_unique);
this.aliases_counter = {
total: reply['result'].counter.total,
current: reply['result'].counter.current,
};
return;
},
error => {
return this.app.show_error('Could not load aliases.', 'Dismiss');
}
);
return req;
}
Expand Down

0 comments on commit 419f00c

Please sign in to comment.