Skip to content
Open
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
53 changes: 45 additions & 8 deletions src/store/modules/request.store.js
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,10 @@ const actions = {
commit("setLoading", false);

const sizeSnap = await db.collection("data-size").get();

if(sizeSnap.empty){
commit("setLoading", false);
return;
}
const document = sizeSnap.docs[0];
const general = document.data()["question-requests"].general;
const subSize = document.data()["question-requests"].users[user.id] || 0;
Expand Down Expand Up @@ -465,7 +468,11 @@ const actions = {
.collection("question-requests")
.where("name", "==", request.name)
.get();

if (snapshot.empty) {
commit("setLoading", false);
return;
}

if (mode === "sttUpdate") {
await snapshot.docs[0].ref.update({
status: payload.status,
Expand Down Expand Up @@ -532,7 +539,10 @@ const actions = {
.orderBy("name")
.where("userId", "==", userInfo.id);
}

if (!state.lastRequestDocument) {
commit("setLoading", false);
return;
}
if (type === "next") {
request = ref
.startAfter(state.lastRequestDocument[1])
Expand Down Expand Up @@ -586,6 +596,10 @@ const actions = {
});
} else {
const pageContent = state.requests["p" + page];
if (!pageContent || !pageContent.length) {
commit("setLoading", false);
return;
}
const first = pageContent[0].name;
const last = pageContent[pageContent.length - 1].name;

Expand All @@ -611,10 +625,14 @@ const actions = {
const { claims, page, itemsPerPage, mode, userInfo } = payload;
const data = [];
const pages = Object.keys(state.requests);

const requestAmount = this.getters.getDataSize["question-requests"].users[
userInfo.id
];
const dataSize = this.getters.getDataSize;
const requestAmount =
dataSize &&
dataSize["question-requests"] &&
dataSize["question-requests"].users &&
dataSize["question-requests"].users[userInfo.id]
? dataSize["question-requests"].users[userInfo.id]
: 0;
const amount = requestAmount % 8;

if (!pages.includes("p" + page)) {
Expand Down Expand Up @@ -720,6 +738,11 @@ const actions = {
req
.get()
.then(async snapshot => {
if(snapshot.empty){
commit("setFilteredRequests", []);
commit("setLoading", false);
return;
}
const promises = snapshot.docs.map(async doc => {
const userData = await dispatch("getUserById", {
id: doc.data().userId
Expand Down Expand Up @@ -797,6 +820,10 @@ const actions = {
.where("name", "==", name)
.get()
.then(async snapshot => {
if(snapshot.empty){
commit("setLoading", false);
return;
}
const doc = snapshot.docs[0];

const toDelete = {
Expand Down Expand Up @@ -859,6 +886,10 @@ const actions = {
.where("name", "==", name)
.get()
.then(async snapshot => {
if(snapshot.empty){
commit("setLoading", false);
return;
}
const doc = snapshot.docs[0];
const data = doc.data();
docData = data;
Expand Down Expand Up @@ -991,6 +1022,10 @@ const actions = {
.where("name", "==", name)
.get()
.then(async snapshot => {
if(snapshot.empty){
commit("setLoading", false);
return;
}
const doc = snapshot.docs[0];
const toDelete = {
status: false
Expand Down Expand Up @@ -1070,6 +1105,7 @@ const actions = {
db.collection("data-size")
.get()
.then(snap => {
if(snap.empty) return;
const document = snap.docs[0];
const general = document.data()["question-requests"].general;

Expand Down Expand Up @@ -1128,6 +1164,7 @@ const actions = {
db.collection("data-size")
.get()
.then(snap => {
if(snap.empty) return;
const document = snap.docs[0];
const general = document.data()["question-requests"].general;
const userId = userInfo.id;
Expand Down Expand Up @@ -1363,4 +1400,4 @@ export default {
mutations,
actions,
getters
};
};