Refactor loading variable + more showError
parent
9ca34b6edf
commit
c70d46b45c
|
@ -1,5 +1,5 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="container" ref="container" :class="{ 'icon-loading': loading }">
|
<div class="container" ref="container" :class="{ 'icon-loading': loading > 0 }">
|
||||||
<!-- Main recycler view for rows -->
|
<!-- Main recycler view for rows -->
|
||||||
<RecycleScroller
|
<RecycleScroller
|
||||||
ref="recycler"
|
ref="recycler"
|
||||||
|
@ -110,6 +110,7 @@
|
||||||
import { Component, Watch, Mixins } from 'vue-property-decorator';
|
import { Component, Watch, Mixins } from 'vue-property-decorator';
|
||||||
import { IDay, IHeadRow, IPhoto, IRow, IRowType, ITick } from "../types";
|
import { IDay, IHeadRow, IPhoto, IRow, IRowType, ITick } from "../types";
|
||||||
import { generateUrl } from '@nextcloud/router'
|
import { generateUrl } from '@nextcloud/router'
|
||||||
|
import { showError } from '@nextcloud/dialogs'
|
||||||
import GlobalMixin from '../mixins/GlobalMixin';
|
import GlobalMixin from '../mixins/GlobalMixin';
|
||||||
import NcActions from '@nextcloud/vue/dist/Components/NcActions';
|
import NcActions from '@nextcloud/vue/dist/Components/NcActions';
|
||||||
import NcActionButton from '@nextcloud/vue/dist/Components/NcActionButton';
|
import NcActionButton from '@nextcloud/vue/dist/Components/NcActionButton';
|
||||||
|
@ -148,7 +149,7 @@ for (const [key, value] of Object.entries(API_ROUTES)) {
|
||||||
})
|
})
|
||||||
export default class Timeline extends Mixins(GlobalMixin) {
|
export default class Timeline extends Mixins(GlobalMixin) {
|
||||||
/** Loading days response */
|
/** Loading days response */
|
||||||
private loading = true;
|
private loading = 0;
|
||||||
/** Main list of rows */
|
/** Main list of rows */
|
||||||
private list: IRow[] = [];
|
private list: IRow[] = [];
|
||||||
/** Counter of rows */
|
/** Counter of rows */
|
||||||
|
@ -239,7 +240,7 @@ export default class Timeline extends Mixins(GlobalMixin) {
|
||||||
/** Reset all state */
|
/** Reset all state */
|
||||||
async resetState() {
|
async resetState() {
|
||||||
this.clearSelection();
|
this.clearSelection();
|
||||||
this.loading = true;
|
this.loading = 0;
|
||||||
this.list = [];
|
this.list = [];
|
||||||
this.numRows = 0;
|
this.numRows = 0;
|
||||||
this.heads = {};
|
this.heads = {};
|
||||||
|
@ -443,11 +444,16 @@ export default class Timeline extends Mixins(GlobalMixin) {
|
||||||
params.folderId = this.$route.params.id || 0;
|
params.folderId = this.$route.params.id || 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
const startState = this.state;
|
try {
|
||||||
const res = await axios.get<IDay[]>(generateUrl(this.appendQuery(url), params));
|
this.loading++;
|
||||||
const data = res.data;
|
const startState = this.state;
|
||||||
if (this.state !== startState) return;
|
const res = await axios.get<IDay[]>(generateUrl(this.appendQuery(url), params));
|
||||||
await this.processDays(data);
|
const data = res.data;
|
||||||
|
if (this.state !== startState) return;
|
||||||
|
await this.processDays(data);
|
||||||
|
} finally {
|
||||||
|
this.loading--;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Process the data for days call including folders */
|
/** Process the data for days call including folders */
|
||||||
|
@ -522,10 +528,13 @@ export default class Timeline extends Mixins(GlobalMixin) {
|
||||||
this.processDay(preload.day);
|
this.processDay(preload.day);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.loading = false;
|
|
||||||
|
|
||||||
// Fix view height variable
|
// Fix view height variable
|
||||||
await this.reflowTimeline();
|
await this.reflowTimeline();
|
||||||
|
|
||||||
|
// Check if we didn't find anything
|
||||||
|
if (this.list.length === 0) {
|
||||||
|
showError(this.t('memories', 'No photos to show here'));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Fetch image data for one dayId */
|
/** Fetch image data for one dayId */
|
||||||
|
@ -552,6 +561,7 @@ export default class Timeline extends Mixins(GlobalMixin) {
|
||||||
day.count = data.length;
|
day.count = data.length;
|
||||||
this.processDay(day);
|
this.processDay(day);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
showError(this.t('memories', 'Failed to load some photos'));
|
||||||
console.error(e);
|
console.error(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -932,14 +942,17 @@ export default class Timeline extends Mixins(GlobalMixin) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.loading = true;
|
try {
|
||||||
const list = [...this.selection];
|
const list = [...this.selection];
|
||||||
for await (const delIds of dav.deleteFilesByIds(list.map(p => p.fileid))) {
|
this.loading++;
|
||||||
const delIdsSet = new Set(delIds.filter(i => i));
|
for await (const delIds of dav.deleteFilesByIds(list.map(p => p.fileid))) {
|
||||||
const updatedDays = new Set(list.filter(f => delIdsSet.has(f.fileid)).map(f => f.d));
|
const delIdsSet = new Set(delIds.filter(i => i));
|
||||||
await this.deleteFromViewWithAnimation(delIdsSet, updatedDays);
|
const updatedDays = new Set(list.filter(f => delIdsSet.has(f.fileid)).map(f => f.d));
|
||||||
|
await this.deleteFromViewWithAnimation(delIdsSet, updatedDays);
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
this.loading--;
|
||||||
}
|
}
|
||||||
this.loading = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue