Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

always display search bar #7

Merged
merged 1 commit into from
Sep 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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:
Expand Down
1 change: 1 addition & 0 deletions frontend/src/pages/Home.css
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@
.footer ion-toolbar {
text-align: center;
color: #8c8c8c;
cursor: pointer;
}
36 changes: 19 additions & 17 deletions frontend/src/pages/Home.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {
IonContent,
IonPage,
IonIcon,
IonItem,
IonList,
IonSpinner,
Expand All @@ -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";
Expand Down Expand Up @@ -58,20 +59,17 @@ const Home: React.FC = () => {

return (
<IonPage>
{state.bots.length > 0 && (
<IonToolbar>
<br />
<IonSearchbar
debounce={200}
onIonInput={(ev) => handleInput(ev)}
placeholder={format(_("search-placeholder"), state.bots.length)}
></IonSearchbar>
</IonToolbar>
)}
<IonContent fullscreen>
{state.syncing && state.hash && (
<IonProgressBar type="indeterminate"></IonProgressBar>
)}
{state.bots.length > 0 && (
<>
<br />
<IonSearchbar
debounce={200}
onIonInput={(ev) => handleInput(ev)}
placeholder={format(_("search-placeholder"), state.bots.length)}
></IonSearchbar>
</>
)}
{state.hash ? (
<IonList>
{results.map((bot) => (
Expand All @@ -95,9 +93,13 @@ const Home: React.FC = () => {
)}
</IonContent>
{state.lastSync && (
<IonFooter translucent collapse="fade" class="footer">
<IonToolbar>
<IonFooter collapse="fade" class="footer">
<IonToolbar onClick={() => api.sync(true)}>
<IonIcon slot="start" icon={refreshOutline} />
{format(_("last-updated"), state.lastSync.toLocaleString())}
{state.syncing && state.hash && (
<IonProgressBar type="indeterminate"></IonProgressBar>
)}
</IonToolbar>
</IonFooter>
)}
Expand Down
5 changes: 3 additions & 2 deletions frontend/src/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Loading