Skip to content

Commit

Permalink
Merge pull request #10771 from AllanOXDi/finalize_learner_notification
Browse files Browse the repository at this point in the history
Finalize learner storage notifications
  • Loading branch information
marcellamaki authored Jul 19, 2023
2 parents a1571b7 + 07027d1 commit a17b2ac
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 5 deletions.
4 changes: 3 additions & 1 deletion kolibri/core/assets/src/composables/useUserSyncStatus.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ export function pollUserSyncStatusTask() {
if (!store.state.core.session.user_id) {
return Promise.resolve();
}

return fetchUserSyncStatus({ user: store.state.core.session.user_id }).then(syncData => {
if (syncData && syncData[0]) {
queued.value = syncData[0].queued;
Expand All @@ -59,6 +58,9 @@ export default function useUserSyncStatus() {
onMounted(() => {
usageCount.value++;
if (usageCount.value === 1) {
if (store.state.core.session.user_id) {
pollUserSyncStatusTask();
}
resume();
}
});
Expand Down
27 changes: 23 additions & 4 deletions kolibri/core/assets/src/views/StorageNotification.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template>

<div v-if="showBanner" class="banner" :style="{ background: $themeTokens.surface }">
<div v-if="bannerOpened" class="banner" :style="{ background: $themeTokens.surface }">
<div class="banner-inner">
<h1 style="display: none">
{{ $tr('bannerHeading') }}
Expand Down Expand Up @@ -51,6 +51,8 @@
import useUser from 'kolibri.coreVue.composables.useUser';
import { useLocalStorage } from '@vueuse/core';
import { LearnerDeviceStatus } from 'kolibri.coreVue.vuex.constants';
import urls from 'kolibri.urls';
import redirectBrowser from 'kolibri.utils.redirectBrowser';
import useUserSyncStatus from '../composables/useUserSyncStatus';
export default {
Expand Down Expand Up @@ -95,7 +97,9 @@
};
},
data() {
return {};
return {
bannerOpened: false,
};
},
computed: {
...mapGetters(['isLearner', 'isAdmin', 'canManageContent']),
Expand All @@ -121,6 +125,16 @@
);
},
},
watch: {
showBanner: {
handler(newVal, oldValue) {
if (newVal !== oldValue) {
this.bannerOpened = newVal;
}
},
deep: true,
},
},
mounted() {
document.addEventListener('focusin', this.focusChange);
},
Expand All @@ -144,14 +158,19 @@
closeBanner() {
this.setLastSyncedValue(this.lastSynced);
this.setDownloadRemovedValue(this.lastDownloadRemoved);
this.showBanner = false;
this.bannerOpened = false;
if (this.previouslyFocusedElement) {
this.previouslyFocusedElement.focus();
}
},
manageChannel() {
this.$router.push('/');
const deviceManagementUrl = urls['kolibri:kolibri.plugins.device:device_management']();
if (this.canManageContent && deviceManagementUrl) {
redirectBrowser(deviceManagementUrl);
} else {
this.bannerOpened = false;
}
},
focusChange(e) {
Expand Down

0 comments on commit a17b2ac

Please sign in to comment.