Removed default values for status and profile picture and added updateUser call
This commit is contained in:
@@ -43,14 +43,6 @@ export const useUserStore = defineStore('userStore', {
|
|||||||
await this.loadPtpUsersById(id).then((response : responseModel) => {
|
await this.loadPtpUsersById(id).then((response : responseModel) => {
|
||||||
this.user = response.response;
|
this.user = response.response;
|
||||||
this.userLoaded = true;
|
this.userLoaded = true;
|
||||||
|
|
||||||
if(this.user!.profilePictureUrl == null) {
|
|
||||||
this.user!.profilePictureUrl = "https://th.bing.com/th/id/R.487fe8708797950ab745a3800c31b7a4?rik=qW3zkDdZfweqmQ&pid=ImgRaw&r=0";
|
|
||||||
}
|
|
||||||
|
|
||||||
if(this.user!.status == null) {
|
|
||||||
this.user!.status = "Hey there, I am using ptpChat!";
|
|
||||||
}
|
|
||||||
}).catch(error => {
|
}).catch(error => {
|
||||||
console.error("Ein Netzwerkfehler ist aufgetreten");
|
console.error("Ein Netzwerkfehler ist aufgetreten");
|
||||||
});
|
});
|
||||||
@@ -61,7 +53,6 @@ export const useUserStore = defineStore('userStore', {
|
|||||||
async loadProfilePictures() {
|
async loadProfilePictures() {
|
||||||
(await api.get("/users/profilePictures")).data.forEach((element: string) => {
|
(await api.get("/users/profilePictures")).data.forEach((element: string) => {
|
||||||
this.profilePictures.push({ shortName: element.split(" ")[0].replace(":", ""), url: element.split(" ")[1]});
|
this.profilePictures.push({ shortName: element.split(" ")[0].replace(":", ""), url: element.split(" ")[1]});
|
||||||
console.log("Hallo ich mache hier was");
|
|
||||||
});
|
});
|
||||||
this.profilePicturesLoaded = true;
|
this.profilePicturesLoaded = true;
|
||||||
},
|
},
|
||||||
@@ -69,23 +60,28 @@ export const useUserStore = defineStore('userStore', {
|
|||||||
getAllPtpUsers() {
|
getAllPtpUsers() {
|
||||||
this.loadAllPtpUsers().then((response : ptpUser[]) => {
|
this.loadAllPtpUsers().then((response : ptpUser[]) => {
|
||||||
this.users = response;
|
this.users = response;
|
||||||
|
|
||||||
this.users.forEach((user : ptpUser) => {
|
|
||||||
if(user.profilePictureUrl == null) {
|
|
||||||
user.profilePictureUrl = "https://th.bing.com/th/id/R.487fe8708797950ab745a3800c31b7a4?rik=qW3zkDdZfweqmQ&pid=ImgRaw&r=0";
|
|
||||||
}
|
|
||||||
|
|
||||||
if(user.status == null) {
|
|
||||||
user.status = "Hey there, I am using ptpChat!";
|
|
||||||
}
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
|
|
||||||
this.usersLoaded = true;
|
this.usersLoaded = true;
|
||||||
},
|
},
|
||||||
|
|
||||||
async loadAllPtpUsers() {
|
async loadAllPtpUsers() {
|
||||||
return (await api.get("/users/user")).data;
|
return (await api.get("/users")).data;
|
||||||
|
},
|
||||||
|
|
||||||
|
async updateUser() {
|
||||||
|
// Find corerspoding short name for link
|
||||||
|
|
||||||
|
const updatedUser : ptpUser = {...this.user!};
|
||||||
|
|
||||||
|
this.profilePictures.forEach((element: profilePicture) => {
|
||||||
|
if(element.url === this.user!.profilepicture){
|
||||||
|
updatedUser.profilepicture = element.shortName;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
await api.post("/users/update", updatedUser);
|
||||||
},
|
},
|
||||||
|
|
||||||
async initKeycloak() : Promise<Keycloak>{
|
async initKeycloak() : Promise<Keycloak>{
|
||||||
|
|||||||
Reference in New Issue
Block a user