Skip to content

Commit

Permalink
set loading bool to true for async History operations
Browse files Browse the repository at this point in the history
set `itemsLoaded=[]` for errored `fetchHistoryItems`
  • Loading branch information
ahmedhamidawan committed Oct 18, 2023
1 parent 7076278 commit 205cf51
Showing 1 changed file with 23 additions and 17 deletions.
40 changes: 23 additions & 17 deletions client/src/components/History/CurrentHistory/HistoryPanel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -337,29 +337,31 @@ export default {
this.loading = true;
try {
await this.fetchHistoryItems(this.historyId, this.filterText, this.offset);
this.itemsLoaded = this.getHistoryItems(this.historyId, this.filterText);
if (this.invisible) {
this.itemsLoaded.forEach((item) => {
if (this.invisible[item.hid]) {
Vue.set(this.invisible, item.hid, false);
}
});
}
this.searchError = null;
this.loading = false;
} catch (error) {
if (error.response && error.response.data && error.response.data.err_msg) {
console.debug("HistoryPanel - Load items error:", error.response.data.err_msg);
this.searchError = error.response.data;
} else {
console.debug("HistoryPanel - Load items error.", error);
}
} finally {
this.itemsLoaded = this.getHistoryItems(this.historyId, this.filterText);
if (this.invisible) {
this.itemsLoaded.forEach((item) => {
if (this.invisible[item.hid]) {
Vue.set(this.invisible, item.hid, false);
}
});
}
this.loading = false;
}
},
onDelete(item) {
async onDelete(item) {
this.setInvisible(item);
deleteContent(item);
this.loading = true;
await deleteContent(item);
this.loading = false;
},
onHideSelection(selectedItems) {
selectedItems.forEach((item) => {
Expand All @@ -369,13 +371,17 @@ export default {
onScroll(offset) {
this.offset = offset;
},
onUndelete(item) {
async onUndelete(item) {
this.setInvisible(item);
updateContentFields(item, { deleted: false });
this.loading = true;
await updateContentFields(item, { deleted: false });
this.loading = false;
},
onUnhide(item) {
async onUnhide(item) {
this.setInvisible(item);
updateContentFields(item, { visible: true });
this.loading = true;
await updateContentFields(item, { visible: true });
this.loading = false;
},
reloadContents() {
rewatchHistory();
Expand All @@ -399,7 +405,7 @@ export default {
this.showDropZone = false;
}
},
onDrop(evt) {
async onDrop(evt) {
this.showDropZone = false;
let data;
try {
Expand All @@ -410,7 +416,7 @@ export default {
if (data) {
const dataSource = data.history_content_type === "dataset" ? "hda" : "hdca";
if (data.history_id != this.historyId) {
copyDataset(data.id, this.historyId, data.history_content_type, dataSource)
await copyDataset(data.id, this.historyId, data.history_content_type, dataSource)
.then(() => {
if (data.history_content_type === "dataset") {
Toast.info("Dataset copied to history");
Expand Down

0 comments on commit 205cf51

Please sign in to comment.