Tied consent warning to session.

This commit is contained in:
DebaucheryLibrarian
2020-12-19 23:01:17 +01:00
parent be4d025505
commit bd77d4347d
10 changed files with 121 additions and 11 deletions

View File

@@ -6,7 +6,8 @@
<Warning
v-if="showWarning"
class="warning-container"
@enter="closeWarning"
@enter="setConsent(true)"
@leave="setConsent(false)"
/>
<transition name="slide">
@@ -41,9 +42,11 @@ function toggleSidebar(state) {
this.showSidebar = typeof state === 'boolean' ? state : !this.showSidebar;
}
function closeWarning() {
this.showWarning = false;
sessionStorage.setItem('warning', 'warned');
async function setConsent(consent) {
if (consent) {
this.showWarning = false;
await this.$store.dispatch('setConsent', true);
}
}
function mounted() {
@@ -61,7 +64,7 @@ export default {
data() {
return {
showSidebar: false,
showWarning: sessionStorage.getItem('warning') !== 'warned',
showWarning: !window.env.consent,
};
},
computed: {
@@ -72,7 +75,7 @@ export default {
mounted,
methods: {
toggleSidebar,
closeWarning,
setConsent,
},
};
</script>

View File

@@ -21,6 +21,7 @@
<a
href="https://www.google.com"
class="button leave"
@click="$emit('leave')"
>Leave</a>
<button