mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-09-24 16:30:27 +08:00
Fix filtering of active broadcasts
Admin users get all the broadcasts notifications regardless of their "activation" status so we need to apply the filtering also in the client. Regular users are not affected because they can only get active broadcasts.
This commit is contained in:
@@ -16,7 +16,7 @@ export const useBroadcastsStore = defineStore(
|
||||
const dismissedBroadcasts = ref<{ [key: string]: Expirable }>({});
|
||||
|
||||
const activeBroadcasts = computed(() => {
|
||||
return broadcasts.value.filter((b) => !dismissedBroadcasts.value[b.id]);
|
||||
return broadcasts.value.filter(isActive);
|
||||
});
|
||||
|
||||
async function loadBroadcasts() {
|
||||
@@ -40,6 +40,14 @@ export const useBroadcastsStore = defineStore(
|
||||
Vue.set(dismissedBroadcasts.value, broadcast.id, { expiration_time: broadcast.expiration_time });
|
||||
}
|
||||
|
||||
function isActive(broadcast: BroadcastNotification) {
|
||||
return (
|
||||
!dismissedBroadcasts.value[broadcast.id] &&
|
||||
!hasExpired(broadcast.expiration_time) &&
|
||||
hasBeenPublished(broadcast)
|
||||
);
|
||||
}
|
||||
|
||||
function hasExpired(expirationTimeStr?: string) {
|
||||
if (!expirationTimeStr) {
|
||||
return false;
|
||||
@@ -49,6 +57,12 @@ export const useBroadcastsStore = defineStore(
|
||||
return now > expirationTime;
|
||||
}
|
||||
|
||||
function hasBeenPublished(broadcast: BroadcastNotification) {
|
||||
const publicationTime = new Date(`${broadcast.publication_time}Z`);
|
||||
const now = new Date();
|
||||
return now >= publicationTime;
|
||||
}
|
||||
|
||||
function clearExpiredDismissedBroadcasts() {
|
||||
for (const key in dismissedBroadcasts.value) {
|
||||
if (hasExpired(dismissedBroadcasts.value[key]?.expiration_time)) {
|
||||
|
||||
Reference in New Issue
Block a user