Replaced container key with route watchers to reduce flashing.

This commit is contained in:
ThePendulum 2020-05-09 01:42:10 +02:00
parent de5b729c0b
commit f31aef6f5d
9 changed files with 55 additions and 13 deletions

View File

@ -259,6 +259,10 @@ async function fetchActor() {
}); });
} }
async function route() {
await this.fetchActor();
}
function scrollPhotos(event) { function scrollPhotos(event) {
event.currentTarget.scrollLeft += event.deltaY; // eslint-disable-line no-param-reassign event.currentTarget.scrollLeft += event.deltaY; // eslint-disable-line no-param-reassign
} }
@ -287,6 +291,9 @@ export default {
expanded: false, expanded: false,
}; };
}, },
watch: {
$route: route,
},
mounted, mounted,
methods: { methods: {
fetchActor, fetchActor,

View File

@ -42,7 +42,6 @@
:to="{ name: 'actors', params: { gender, letter: letterX } }" :to="{ name: 'actors', params: { gender, letter: letterX } }"
:class="{ selected: letterX === letter }" :class="{ selected: letterX === letter }"
class="letter-link" class="letter-link"
@click="setLetter(letterX)"
>{{ letterX || 'All' }}</router-link> >{{ letterX || 'All' }}</router-link>
</li> </li>
</ul> </ul>
@ -63,18 +62,24 @@ import Actor from '../tile/actor.vue';
import Gender from './gender.vue'; import Gender from './gender.vue';
async function fetchActors() { async function fetchActors() {
const gender = this.gender.replace('trans', 'transsexual'); const curatedGender = this.gender.replace('trans', 'transsexual');
this.actors = await this.$store.dispatch('fetchActors', { this.actors = await this.$store.dispatch('fetchActors', {
limit: 1000, limit: 1000,
letter: this.letter.replace('all', ''), letter: this.letter.replace('all', ''),
genders: [gender === 'other' ? null : gender], genders: [curatedGender === 'other' ? null : curatedGender],
}); });
} }
async function setLetter(letter) { function letter() {
this.letter = letter; return this.$route.params.letter || 'all';
}
function gender() {
return this.$route.params.gender || 'female';
}
async function route() {
await this.fetchActors(); await this.fetchActors();
} }
@ -94,14 +99,18 @@ export default {
actors: [], actors: [],
pageTitle: null, pageTitle: null,
letters: ['all'].concat(Array.from({ length: 26 }, (value, index) => String.fromCharCode(index + 97).toUpperCase())), letters: ['all'].concat(Array.from({ length: 26 }, (value, index) => String.fromCharCode(index + 97).toUpperCase())),
letter: this.$route.params.letter || 'all',
gender: this.$route.params.gender || 'female',
}; };
}, },
computed: {
letter,
gender,
},
watch: {
$route: route,
},
mounted, mounted,
methods: { methods: {
fetchActors, fetchActors,
setLetter,
}, },
}; };
</script> </script>
@ -189,7 +198,7 @@ export default {
} }
&:hover { &:hover {
color: var(--text-light); color: var(--text);
cursor: pointer; cursor: pointer;
.icon { .icon {

View File

@ -12,7 +12,7 @@
<div class="content"> <div class="content">
<!-- key forces rerender when new and old path use same component --> <!-- key forces rerender when new and old path use same component -->
<router-view :key="$route.fullPath" /> <router-view />
</div> </div>
</div> </div>
</template> </template>

View File

@ -22,6 +22,10 @@ async function fetchReleases() {
}); });
} }
async function route() {
await this.fetchReleases();
}
async function mounted() { async function mounted() {
this.pageTitle = ''; this.pageTitle = '';
@ -44,6 +48,9 @@ export default {
beforeRouteEnter(to, from, next) { beforeRouteEnter(to, from, next) {
next(vm => vm.$set(vm, 'from', from)); next(vm => vm.$set(vm, 'from', from));
}, },
watch: {
$route: route,
},
mounted, mounted,
methods: { methods: {
fetchReleases, fetchReleases,

View File

@ -147,6 +147,10 @@ async function fetchNetwork() {
this.releases = this.network.releases; this.releases = this.network.releases;
} }
async function route() {
await this.fetchNetwork();
}
async function mounted() { async function mounted() {
await this.fetchNetwork(); await this.fetchNetwork();
this.pageTitle = this.network.name; this.pageTitle = this.network.name;
@ -170,6 +174,9 @@ export default {
expanded: false, expanded: false,
}; };
}, },
watch: {
$route: route,
},
mounted, mounted,
methods: { methods: {
fetchNetwork, fetchNetwork,

View File

@ -52,8 +52,6 @@ async function searchSites() {
query: this.query, query: this.query,
limit: 20, limit: 20,
}); });
console.log(this.searchResults);
} }
async function mounted() { async function mounted() {

View File

@ -38,7 +38,7 @@
import ReleaseTile from '../tile/release.vue'; import ReleaseTile from '../tile/release.vue';
function range() { function range() {
return this.$store.state.ui.range; return this.$route.params.range;
} }
function sfw() { function sfw() {

View File

@ -62,6 +62,10 @@ async function fetchSite() {
this.releases = this.site.releases; this.releases = this.site.releases;
} }
async function route() {
await this.fetchSite();
}
async function mounted() { async function mounted() {
await this.fetchSite(); await this.fetchSite();
@ -80,6 +84,9 @@ export default {
pageTitle: null, pageTitle: null,
}; };
}, },
watch: {
$route: route,
},
mounted, mounted,
methods: { methods: {
fetchSite, fetchSite,

View File

@ -71,6 +71,10 @@ async function fetchReleases() {
this.description = this.tag.description && converter.makeHtml(escapeHtml(this.tag.description)); this.description = this.tag.description && converter.makeHtml(escapeHtml(this.tag.description));
} }
async function route() {
await this.fetchReleases();
}
async function mounted() { async function mounted() {
await this.fetchReleases(); await this.fetchReleases();
this.pageTitle = this.tag.name; this.pageTitle = this.tag.name;
@ -91,6 +95,9 @@ export default {
hasMedia: false, hasMedia: false,
}; };
}, },
watch: {
$route: route,
},
mounted, mounted,
methods: { methods: {
fetchReleases, fetchReleases,