Skip to content

Commit

Permalink
Merge pull request #7 from deltachat-bot/adb/issue-2
Browse files Browse the repository at this point in the history
always display search bar
  • Loading branch information
adbenitez authored Sep 5, 2024
2 parents 16248d4 + 23ad071 commit f26aea2
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 22 deletions.
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

0 comments on commit f26aea2

Please sign in to comment.