Skip to content
This repository has been archived by the owner on Mar 26, 2022. It is now read-only.

Commit

Permalink
Fixed a bug with the settings UI
Browse files Browse the repository at this point in the history
  • Loading branch information
Migarve55 committed Mar 9, 2019
1 parent 835e885 commit 6c472e3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
4 changes: 2 additions & 2 deletions src/app/settings/settings.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ <h2 i18n="@@addFriendTitle">Add a friend</h2>
</p>
<div class="group">
<input class="textInput"
[(ngModel)]="webId" (keydown)="handleSubmit($event)"
[(ngModel)]="webIdaddFriend" (keydown)="handleSubmit($event)"
placeholder="Enter your friend's WebID"/>
<button i18n="@@addFriend" class="button" (click)=addFriend()>Add friend</button>
</div>
Expand All @@ -18,7 +18,7 @@ <h2 i18n="@@removeFriendTitle">Remove a friend</h2>
</p>
<div class="group">
<input class="textInput"
[(ngModel)]="webId" (keydown)="handleSubmit($event)"
[(ngModel)]="webIdRemoveFriend" (keydown)="handleSubmit($event)"
placeholder="Enter your friend's WebID"/>
<button i18n="@@removeFriend" class="button" (click)=removeFriend()>Remove friend</button>
</div>
Expand Down
19 changes: 10 additions & 9 deletions src/app/settings/settings.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,32 +9,33 @@ import { ToastrService } from 'ngx-toastr';
})
export class SettingsComponent implements OnInit {

webId : string;
webIdAddFriend : string;
webIdRemoveFriend : string;

constructor(private chat : ChatService, private toastr : ToastrService) { }

ngOnInit() {
}

addFriend() {
if (!this.webId) {
if (!this.webIdAddFriend) {
this.toastr.error("Please add a webId", "Wrong input");
} else if (this.webId.trim() === "") {
} else if (this.webIdAddFriend.trim() === "") {
this.toastr.error("Please add a webId", "Wrong input");
} else {
this.chat.addFriend(this.webId.trim());
this.webId = "";
this.chat.addFriend(this.webIdAddFriend.trim());
this.webIdAddFriend = "";
}
}

removeFriend() {
if (!this.webId) {
if (!this.webIdRemoveFriend) {
this.toastr.error("Please add a webId", "Wrong input");
} else if (this.webId.trim() === "") {
} else if (this.webIdRemoveFriend.trim() === "") {
this.toastr.error("Please add a webId", "Wrong input");
} else {
this.chat.removeFriend(this.webId.trim());
this.webId = "";
this.chat.removeFriend(this.webIdRemoveFriend.trim());
this.webIdRemoveFriend = "";
}
}

Expand Down

0 comments on commit 6c472e3

Please sign in to comment.