Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: message function update, fix: image quality #47

Merged
merged 9 commits into from
Feb 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 28 additions & 13 deletions controller/Active.js
Original file line number Diff line number Diff line change
Expand Up @@ -344,9 +344,9 @@ async function getAllActive() {

async function getGenreActive(genre) {
const db = getFirestore(app);
const activesRef = query(collection(db, 'actives'));
const activesRef = query(collection(db, 'actives'), where('genre', '==', genre));
const GenreArray = [];
const querySnapshot = await getDocs(activesRef, where('genre', '==', genre));
const querySnapshot = await getDocs(activesRef);

querySnapshot.forEach((doc1) => {
GenreArray.push({
Expand Down Expand Up @@ -568,33 +568,36 @@ async function getEventActive() {

async function deleteOneActive(deleteDocId) {
const db = getFirestore(app);
const activesRef = query(collection(db, 'actives'));
const deletedDoc = await getDocs(activesRef, deleteDocId);
if (deletedDoc.data().imageUri1 !== defaultLinks[values.indexOf(deletedDoc.data().genre)].link) {
if (deletedDoc.data().imageUri1) {
deleteObject(deletedDoc.data().imageUri1).then(() => {
const activesRef = query(doc(db, 'actives', deleteDocId));
const dltDoc = await getDoc(activesRef);
if (dltDoc.data().imageUri1 !== defaultLinks[values.indexOf(dltDoc.data().genre)].link) {
if (dltDoc.data().imageUri1) {
const uriRef1 = ref(storage, `actives/${dltDoc.data().imageUri1.substr(-94, 41)}`);
deleteObject(uriRef1).then(() => {
console.log('Image 1 has been deleted!');
}).catch((err) => {
console.log(err);
});
}
}
if (deletedDoc.data().imageUri2) {
deleteObject(deletedDoc.data().imageUri2).then(() => {
if (dltDoc.data().imageUri2) {
const uriRef2 = ref(storage, `actives/${dltDoc.data().imageUri2.substr(-94, 41)}`);
deleteObject(uriRef2).then(() => {
console.log('Image 2 has been deleted!');
}).catch((err) => {
console.log(err);
});
}
if (deletedDoc.data().imageUri3) {
deleteObject(deletedDoc.data().imageUri3).then(() => {
if (dltDoc.data().imageUri3) {
const uriRef3 = ref(storage, `actives/${dltDoc.data().imageUri3.substr(-94, 41)}`);
deleteObject(uriRef3).then(() => {
console.log('Image 3 has been deleted!');
}).catch((err) => {
console.log(err);
});
}

await deleteDoc(doc(db, 'actives', deleteDoc));
await deleteDoc(doc(db, 'actives', deleteDocId));
console.log('deleteOneActive Successful');
}

Expand Down Expand Up @@ -659,7 +662,7 @@ async function deleteEverySingleAttendee(docID) {
async function removeAttendee(docID, studentUid) { // remove attendee
const db = getFirestore(app);
const activesRef = query(collection(db, `attendees/${studentUid}/attendedEvent`));
activesRef.doc(docID).delete();
await deleteDoc(doc(db, 'attendees', studentUid, 'attendedEvent', docID));
// console.log(docID, studentID);
console.log('delete successfully!');
const result = await getDocs(activesRef);
Expand Down Expand Up @@ -809,6 +812,17 @@ async function getAttendedOrNot(docID) {
return false;
}

async function getHostinAdd() {
const Uid = UserController.getUid();
const db = getFirestore(app);
const infoRef = query(doc(db, `attendees/${Uid}`));
const querySnapshot = await getDoc(infoRef);

console.log(querySnapshot.data());

return querySnapshot.data();
}

export default {
firebaseConfig,
toDateString,
Expand All @@ -833,4 +847,5 @@ export default {
getTotalOfAttendees,
removeAttendee,
getAttendedOrNot,
getHostinAdd,
};
Loading