Skip to content

Commit

Permalink
BİSMİLLAHİRRAHMANİRRAHİM
Browse files Browse the repository at this point in the history
read feature add, tests arent done yet
  • Loading branch information
Yusuf-YENICERI committed Feb 16, 2024
1 parent 91bed90 commit d610e95
Show file tree
Hide file tree
Showing 14 changed files with 1,381 additions and 1,025 deletions.
34 changes: 30 additions & 4 deletions src/backend/APIs/firebase_api/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class FirebaseAPI{

hatimSiraBelirle = (no) => {
let hatimSira = 1;
switch(true){
switch (true) {
case no < 11:
break;
case no < 21:
Expand All @@ -62,8 +62,11 @@ class FirebaseAPI{
hatimSira = 3;
break;
}

return hatimSira;

return {
sira: hatimSira,
subSira: no - ((hatimSira - 1) * 10 + 1),
};
}

extractKey = () => {
Expand Down Expand Up @@ -367,7 +370,6 @@ class FirebaseAPI{

cuzAl = async (isim, no, subKey, alindi = true, makeNewHatim = false, writeTotalReadParts = false) => {
let hatimKey = this.extractKey().replace('/','');
let sira = this.hatimSiraBelirle(no);

let ownerId = LocDb.ref(`Hatim/hatimKeys/${hatimKey}/${subKey}/ownerId`).get()

Expand Down Expand Up @@ -664,6 +666,30 @@ class FirebaseAPI{

}

partRead = async ({subKey, partNo}) => {
try {
const {sira, subSira} = this.hatimSiraBelirle (partNo);

await this.db.ref(`hatim/${this.extractKey()}/${subKey}/${sira}/cevaplar/${subSira}/isRead`).set(true);

return {data: "Alhamdulillah", error: undefined}
} catch (error) {
return {data: undefined, error: error};
}
}

partNotRead = async ({subKey, partNo}) => {
try {
const {sira, subSira} = this.hatimSiraBelirle (partNo);

await this.db.ref(`hatim/${this.extractKey()}/${subKey}/${sira}/cevaplar/${subSira}/isRead`).set(false);

return {data: "Alhamdulillah", error: undefined}
} catch (error) {
return {data: undefined, error: error};
}
}



}
Expand Down
8 changes: 8 additions & 0 deletions src/backend/database.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,14 @@ export class Database {
getTitleAndDescription = async ({subKey}) => {
return await this.api.getTitleAndDescription ({subKey});
};

partRead = async ({subKey, partNo}) => {
return await this.api.partRead ({subKey, partNo});
};

partNotRead = async ({subKey, partNo}) => {
return await this.api.partNotRead ({subKey, partNo});
};
}

export default Database;
Loading

0 comments on commit d610e95

Please sign in to comment.