From 23ad071cf6c2695b278633610d1a35d7d504d6bc Mon Sep 17 00:00:00 2001 From: adbenitez Date: Thu, 5 Sep 2024 05:55:41 +0200 Subject: [PATCH] always display search bar also allow to refresh data by clicking bottom bar --- .goreleaser.yaml | 5 ++--- frontend/src/pages/Home.css | 1 + frontend/src/pages/Home.tsx | 36 +++++++++++++++++++----------------- frontend/src/store.ts | 5 +++-- 4 files changed, 25 insertions(+), 22 deletions(-) diff --git a/.goreleaser.yaml b/.goreleaser.yaml index 26df4ed..01c369c 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -1,5 +1,4 @@ -# This is an example .goreleaser.yml file with some sensible defaults. -# Make sure to check the documentation at https://goreleaser.com +version: 2 before: hooks: # You may remove this if you don't use go modules. @@ -33,7 +32,7 @@ archives: checksum: name_template: 'checksums.txt' snapshot: - name_template: "{{ incpatch .Version }}-next" + version_template: "{{ incpatch .Version }}-next" changelog: sort: asc filters: diff --git a/frontend/src/pages/Home.css b/frontend/src/pages/Home.css index e82c773..4a2eed6 100644 --- a/frontend/src/pages/Home.css +++ b/frontend/src/pages/Home.css @@ -15,4 +15,5 @@ .footer ion-toolbar { text-align: center; color: #8c8c8c; + cursor: pointer; } diff --git a/frontend/src/pages/Home.tsx b/frontend/src/pages/Home.tsx index d843231..2ac4efe 100644 --- a/frontend/src/pages/Home.tsx +++ b/frontend/src/pages/Home.tsx @@ -1,6 +1,7 @@ import { IonContent, IonPage, + IonIcon, IonItem, IonList, IonSpinner, @@ -13,9 +14,9 @@ import { import Fuse from "fuse.js"; import { create } from "zustand"; import { useState } from "react"; -import { warningOutline } from "ionicons/icons"; +import { warningOutline, refreshOutline } from "ionicons/icons"; -import { useStore, Bot } from "../store"; +import { useStore, Bot, api } from "../store"; import BotItem from "../components/BotItem"; import { getText as _, format } from "../i18n"; import "./Home.css"; @@ -58,20 +59,17 @@ const Home: React.FC = () => { return ( + {state.bots.length > 0 && ( + +
+ handleInput(ev)} + placeholder={format(_("search-placeholder"), state.bots.length)} + > +
+ )} - {state.syncing && state.hash && ( - - )} - {state.bots.length > 0 && ( - <> -
- handleInput(ev)} - placeholder={format(_("search-placeholder"), state.bots.length)} - > - - )} {state.hash ? ( {results.map((bot) => ( @@ -95,9 +93,13 @@ const Home: React.FC = () => { )}
{state.lastSync && ( - - + + api.sync(true)}> + {format(_("last-updated"), state.lastSync.toLocaleString())} + {state.syncing && state.hash && ( + + )} )} diff --git a/frontend/src/store.ts b/frontend/src/store.ts index 5806079..360180f 100644 --- a/frontend/src/store.ts +++ b/frontend/src/store.ts @@ -8,15 +8,16 @@ function isOnline(lastSync: Date, lastSeen?: Date): boolean { return timeAgo <= recently; } -const api = (() => { +export const api = (() => { return { - sync: () => { + sync: (force: boolean = false) => { const lastSyncReq = localStorage.getItem(lastSyncReqKey) || localStorage.getItem(lastSyncKey) || ""; const hash = localStorage.getItem(hashKey) || null; if ( + !force && lastSyncReq && new Date().getTime() - new Date(lastSyncReq).getTime() <= 1000 * 60 * (hash ? 10 : 1)