Sfoglia il codice sorgente

Interval fetching for app

Nicolas Meienberger 3 anni fa
parent
commit
a424c9ebc1

+ 9 - 1
packages/dashboard/src/modules/Apps/containers/AppDetails.tsx

@@ -1,5 +1,5 @@
 import { SlideFade, Image, VStack, Flex, Divider, useDisclosure, useToast } from '@chakra-ui/react';
-import React from 'react';
+import React, { useEffect } from 'react';
 import { FiExternalLink } from 'react-icons/fi';
 import { AppConfig } from '../../../core/types';
 import { useAppsStore } from '../../../state/appsStore';
@@ -22,6 +22,14 @@ const AppDetails: React.FC<IProps> = ({ app }) => {
 
   const { install, update, uninstall, stop, start, fetchApp } = useAppsStore();
 
+  useEffect(() => {
+    const interval = setInterval(() => {
+      fetchApp(app.id);
+    }, 3000);
+
+    return () => clearInterval(interval);
+  }, [app.id, fetchApp]);
+
   const handleError = (error: unknown) => {
     if (error instanceof Error) {
       toast({

+ 8 - 10
scripts/start.sh

@@ -50,16 +50,6 @@ function derive_entropy() {
   printf "%s" "${identifier}" | openssl dgst -sha256 -hmac "${tipi_seed}" | sed 's/^.* //'
 }
 
-
-
-# Get dns ip if pihole is installed
-str=$(get_json_field ${STATE_FOLDER}/apps.json installed)
-
-# if pihole is present in str add it as DNS
-if [[ $str = *"pihole"* ]]; then
-  DNS_IP=10.21.21.201
-fi
-
 PUID="$(id -u)"
 PGID="$(id -g)"
 TZ="$(cat /etc/timezone | sed 's/\//\\\//g' || echo "Europe/Berlin")"
@@ -77,6 +67,14 @@ fi
 chown -R 1000:1000 "${STATE_FOLDER}/apps.json"
 chown -R 1000:1000 "${STATE_FOLDER}/users.json"
 
+# Get dns ip if pihole is installed
+str=$(get_json_field ${STATE_FOLDER}/apps.json installed)
+
+# if pihole is present in str add it as DNS
+if [[ $str = *"pihole"* ]]; then
+  DNS_IP=10.21.21.201
+fi
+
 # Create seed file with cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1
 if [[ ! -f "${STATE_FOLDER}/seed" ]]; then
   echo "Generating seed..."