Donut check for updates with every request of an admin user, only check on admin index page...

This commit is contained in:
Crimekillz 2024-04-07 02:57:21 +02:00
parent 2a68b8e51f
commit c10ca1c333
3 changed files with 7 additions and 12 deletions

View File

@ -41,7 +41,7 @@ export default define(meta, paramDef, async (ps, user, token) => {
userProfile.loggedInDates = [...userProfile.loggedInDates, today]; userProfile.loggedInDates = [...userProfile.loggedInDates, today];
} }
return await Users.pack<true, true>(userProfile.user!, userProfile.user!, { return await Users.pack<true, true>(user.id, user, {
detail: true, detail: true,
includeSecrets: isSecure, includeSecrets: isSecure,
userProfile, userProfile,

View File

@ -21,9 +21,13 @@ export default define(meta, paramDef, async () => {
) )
.then((response) => response.json()) .then((response) => response.json())
.then((data) => { .then((data) => {
tag_name = data[0].tag_name; if (data.length > 0)
tag_name = data[0].tag_name ?? undefined;
}); });
if (!tag_name)
throw new Error('Could not fetch latest release information. Please check manually if your release of TrashPoss is up to date.');
return { return {
tag_name, tag_name,
}; };

View File

@ -83,8 +83,7 @@
v-if=" v-if="
thereIsUnresolvedAbuseReport || thereIsUnresolvedAbuseReport ||
noMaintainerInformation || noMaintainerInformation ||
noBotProtection || noBotProtection
updateAvailable
" "
class="indicator" class="indicator"
><i class="icon ph-circle ph-fill"></i> ><i class="icon ph-circle ph-fill"></i>
@ -148,7 +147,6 @@ import { defaultStore } from "@/store";
import { i18n } from "@/i18n"; import { i18n } from "@/i18n";
import { instance } from "@/instance"; import { instance } from "@/instance";
import { version } from "@/config"; import { version } from "@/config";
import { isUpdateAvailable } from "@/scripts/is-update-available.js";
const isEmpty = (x: string | null) => x == null || x === ""; const isEmpty = (x: string | null) => x == null || x === "";
@ -184,7 +182,6 @@ let noBotProtection =
!instance.enableHcaptcha && !instance.enableHcaptcha &&
!instance.enableRecaptcha; !instance.enableRecaptcha;
let thereIsUnresolvedAbuseReport = $ref(false); let thereIsUnresolvedAbuseReport = $ref(false);
let updateAvailable = $ref(false);
if ($i?.isAdmin) { if ($i?.isAdmin) {
os.api("admin/abuse-user-reports", { os.api("admin/abuse-user-reports", {
@ -193,12 +190,6 @@ if ($i?.isAdmin) {
}).then((reports) => { }).then((reports) => {
if (reports?.length > 0) thereIsUnresolvedAbuseReport = true; if (reports?.length > 0) thereIsUnresolvedAbuseReport = true;
}); });
if (defaultStore.state.showAdminUpdates) {
isUpdateAvailable().then(res => {
updateAvailable = res;
});
}
} }
function openAccountMenu(ev: MouseEvent) { function openAccountMenu(ev: MouseEvent) {