Browse Source

fix problem switching projects where old link data remained

split_build_process
Trent Larson 2 weeks ago
parent
commit
1e66bc1126
  1. 94
      src/views/ProjectViewView.vue

94
src/views/ProjectViewView.vue

@ -657,29 +657,47 @@ export default class ProjectViewView extends Vue {
); );
} }
this.givesToThis = [];
this.loadGives(); this.loadGives();
this.givesProvidedByThis = [];
this.loadGivesProvidedBy(); this.loadGivesProvidedBy();
this.offersToThis = [];
this.loadOffers(); this.loadOffers();
this.fulfillersToThis = [];
this.loadPlanFulfillersTo(); this.loadPlanFulfillersTo();
const fulfilledByUrl = this.fulfilledByThis = null;
this.loadPlanFulfilledBy();
}
async loadGives() {
const givesUrl =
this.apiServer + this.apiServer +
"/api/v2/report/planFulfilledByPlan?planHandleId=" + "/api/v2/report/givesToPlans?planIds=" +
encodeURIComponent(projectId); encodeURIComponent(JSON.stringify([this.projectId]));
let postfix = "";
if (this.givesToThis.length > 0) {
postfix =
"&beforeId=" + this.givesToThis[this.givesToThis.length - 1].jwtId;
}
const givesInUrl = givesUrl + postfix;
const headers = await serverUtil.getHeaders(this.activeDid);
try { try {
const resp = await this.axios.get(fulfilledByUrl, { headers }); const resp = await this.axios.get(givesInUrl, { headers });
if (resp.status === 200) { if (resp.status === 200 && resp.data.data) {
this.fulfilledByThis = resp.data.data; this.givesToThis = this.givesToThis.concat(resp.data.data);
this.givesHitLimit = resp.data.hitLimit;
} else { } else {
this.$notify( this.$notify(
{ {
group: "alert", group: "alert",
type: "danger", type: "danger",
title: "Error", title: "Error",
text: "Failed to retrieve plans fulfilled by this project.", text: "Failed to retrieve more gives to this project.",
}, },
5000, 5000,
); );
@ -691,42 +709,45 @@ export default class ProjectViewView extends Vue {
group: "alert", group: "alert",
type: "danger", type: "danger",
title: "Error", title: "Error",
text: "Something went wrong retrieving plans fulfilled by this project.", text: "Something went wrong retrieving more gives to this project.",
}, },
5000, 5000,
); );
console.error( console.error(
"Error retrieving plans fulfilled by this project:", "Something went wrong retrieving more gives to this project:",
serverError.message, serverError.message,
); );
} }
} }
async loadGives() { async loadGivesProvidedBy() {
const givesUrl = const providedByUrl =
this.apiServer + this.apiServer +
"/api/v2/report/givesToPlans?planIds=" + "/api/v2/report/givesProvidedBy?providerId=" +
encodeURIComponent(JSON.stringify([this.projectId])); encodeURIComponent(this.projectId);
let postfix = ""; let postfix = "";
if (this.givesToThis.length > 0) { if (this.givesProvidedByThis.length > 0) {
postfix = postfix =
"&beforeId=" + this.givesToThis[this.givesToThis.length - 1].jwtId; "&beforeId=" +
this.givesProvidedByThis[this.givesProvidedByThis.length - 1].jwtId;
} }
const givesInUrl = givesUrl + postfix; const providedByFullUrl = providedByUrl + postfix;
const headers = await serverUtil.getHeaders(this.activeDid); const headers = await serverUtil.getHeaders(this.activeDid);
try { try {
const resp = await this.axios.get(givesInUrl, { headers }); const resp = await this.axios.get(providedByFullUrl, { headers });
if (resp.status === 200 && resp.data.data) { if (resp.status === 200) {
this.givesToThis = this.givesToThis.concat(resp.data.data); this.givesProvidedByThis = this.givesProvidedByThis.concat(
this.givesHitLimit = resp.data.hitLimit; resp.data.data,
);
this.givesProvidedByHitLimit = resp.data.hitLimit;
} else { } else {
this.$notify( this.$notify(
{ {
group: "alert", group: "alert",
type: "danger", type: "danger",
title: "Error", title: "Error",
text: "Failed to retrieve more gives to this project.", text: "Failed to retrieve gives that were provided by this project.",
}, },
5000, 5000,
); );
@ -738,12 +759,12 @@ export default class ProjectViewView extends Vue {
group: "alert", group: "alert",
type: "danger", type: "danger",
title: "Error", title: "Error",
text: "Something went wrong retrieving more gives to this project.", text: "Something went wrong retrieving gives that were provided by this project.",
}, },
5000, 5000,
); );
console.error( console.error(
"Something went wrong retrieving more gives to this project:", "Something went wrong retrieving gives that were provided by this project:",
serverError.message, serverError.message,
); );
} }
@ -844,34 +865,23 @@ export default class ProjectViewView extends Vue {
} }
} }
async loadGivesProvidedBy() { async loadPlanFulfilledBy() {
const providedByUrl = const fulfilledByUrl =
this.apiServer + this.apiServer +
"/api/v2/report/givesProvidedBy?providerId=" + "/api/v2/report/planFulfilledByPlan?planHandleId=" +
encodeURIComponent(this.projectId); encodeURIComponent(this.projectId);
let postfix = "";
if (this.givesProvidedByThis.length > 0) {
postfix =
"&beforeId=" +
this.givesProvidedByThis[this.givesProvidedByThis.length - 1].jwtId;
}
const providedByFullUrl = providedByUrl + postfix;
const headers = await serverUtil.getHeaders(this.activeDid); const headers = await serverUtil.getHeaders(this.activeDid);
try { try {
const resp = await this.axios.get(providedByFullUrl, { headers }); const resp = await this.axios.get(fulfilledByUrl, { headers });
if (resp.status === 200) { if (resp.status === 200) {
this.givesProvidedByThis = this.givesProvidedByThis.concat( this.fulfilledByThis = resp.data.data;
resp.data.data,
);
this.givesProvidedByHitLimit = resp.data.hitLimit;
} else { } else {
this.$notify( this.$notify(
{ {
group: "alert", group: "alert",
type: "danger", type: "danger",
title: "Error", title: "Error",
text: "Failed to retrieve gives that were provided by this project.", text: "Failed to retrieve plans fulfilled by this project.",
}, },
5000, 5000,
); );
@ -883,12 +893,12 @@ export default class ProjectViewView extends Vue {
group: "alert", group: "alert",
type: "danger", type: "danger",
title: "Error", title: "Error",
text: "Something went wrong retrieving gives that were provided by this project.", text: "Something went wrong retrieving plans fulfilled by this project.",
}, },
5000, 5000,
); );
console.error( console.error(
"Something went wrong retrieving gives that were provided by this project:", "Error retrieving plans fulfilled by this project:",
serverError.message, serverError.message,
); );
} }

Loading…
Cancel
Save