mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2025-02-03 12:29:46 +08:00
changed the name of the returned status
This commit is contained in:
parent
f9c605ebb3
commit
475100b15e
2 changed files with 14 additions and 14 deletions
|
@ -327,25 +327,25 @@ exports.addTag = functions.https.onCall((request,response) => {
|
|||
try{
|
||||
|
||||
if(!isTagValid(request.name)){
|
||||
return {status:-1};
|
||||
return {resultCode:-1};
|
||||
}else{
|
||||
return admin.firestore().collection(`users/${request.uid}/tags`).add({
|
||||
name: request.name
|
||||
}).then(e => {
|
||||
console.log(`user ${request.uid} created a tag: ${request.name}`);
|
||||
return {
|
||||
status:1,
|
||||
resultCode:1,
|
||||
id: e.id
|
||||
};
|
||||
}).catch(e => {
|
||||
console.error(`error while creating tag for user ${request.uid}: ${e.message}`);
|
||||
return {status:-999};
|
||||
return {resultCode:-999};
|
||||
})
|
||||
}
|
||||
|
||||
}catch(e){
|
||||
console.error(`error adding tag for ${request.uid} - ${e}`);
|
||||
return {status:-999};
|
||||
return {resultCode:-999};
|
||||
}
|
||||
})
|
||||
|
||||
|
@ -353,24 +353,24 @@ exports.editTag = functions.https.onCall((request,response) => {
|
|||
try{
|
||||
|
||||
if(!isTagValid(request.name)){
|
||||
return {status:-1};
|
||||
return {resultCode:-1};
|
||||
}else{
|
||||
return admin.firestore().collection(`users/${request.uid}/tags`).doc(request.tagid).update({
|
||||
name: request.name
|
||||
}).then(e => {
|
||||
console.log(`user ${request.uid} updated a tag: ${request.name}`);
|
||||
return {
|
||||
status:1
|
||||
resultCode:1
|
||||
};
|
||||
}).catch(e => {
|
||||
console.error(`error while updating tag for user ${request.uid}: ${e.message}`);
|
||||
return {status:-999};
|
||||
return {resultCode:-999};
|
||||
})
|
||||
}
|
||||
|
||||
}catch(e){
|
||||
console.error(`error updating tag for ${request.uid} - ${e}`);
|
||||
return {status:-999};
|
||||
return {resultCode:-999};
|
||||
}
|
||||
})
|
||||
|
||||
|
@ -380,15 +380,15 @@ exports.removeTag = functions.https.onCall((request,response) => {
|
|||
return admin.firestore().collection(`users/${request.uid}/tags`).doc(request.tagid).delete().then(e => {
|
||||
console.log(`user ${request.uid} deleted a tag`);
|
||||
return {
|
||||
status:1
|
||||
resultCode:1
|
||||
};
|
||||
}).catch(e => {
|
||||
console.error(`error deleting tag for user ${request.uid}: ${e.message}`);
|
||||
return {status:-999};
|
||||
return {resultCode:-999};
|
||||
})
|
||||
|
||||
}catch(e){
|
||||
console.error(`error deleting tag for ${request.uid} - ${e}`);
|
||||
return {status:-999};
|
||||
return {resultCode:-999};
|
||||
}
|
||||
})
|
|
@ -1328,7 +1328,7 @@ $("#tagsWrapper #tagsEdit .button").click(e => {
|
|||
hideEditTags();
|
||||
if(action === "add"){
|
||||
addTag({uid:firebase.auth().currentUser.uid,name:inputVal}).then(e => {
|
||||
let status = e.data.status;
|
||||
let status = e.data.resultCode;
|
||||
if(status === 1){
|
||||
showNotification('Tag added',2000);
|
||||
dbSnapshot.tags.push({
|
||||
|
@ -1345,7 +1345,7 @@ $("#tagsWrapper #tagsEdit .button").click(e => {
|
|||
})
|
||||
}else if(action === "edit"){
|
||||
editTag({uid:firebase.auth().currentUser.uid,name:inputVal,tagid:tagid}).then(e => {
|
||||
let status = e.data.status;
|
||||
let status = e.data.resultCode;
|
||||
if(status === 1){
|
||||
showNotification('Tag updated',2000);
|
||||
dbSnapshot.tags.forEach(tag => {
|
||||
|
@ -1363,7 +1363,7 @@ $("#tagsWrapper #tagsEdit .button").click(e => {
|
|||
})
|
||||
}else if(action === "remove"){
|
||||
removeTag({uid:firebase.auth().currentUser.uid,tagid:tagid}).then(e => {
|
||||
let status = e.data.status;
|
||||
let status = e.data.resultCode;
|
||||
if(status === 1){
|
||||
showNotification('Tag removed',2000);
|
||||
dbSnapshot.tags.forEach((tag,index) => {
|
||||
|
|
Loading…
Reference in a new issue