Skip to content

Commit 5ddf316

Browse files
author
Piotr Gulbinowicz
committed
fix paging
1 parent e5828c4 commit 5ddf316

File tree

1 file changed

+21
-16
lines changed

1 file changed

+21
-16
lines changed

pwa/flush/components.go

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,20 @@ import (
1313
)
1414

1515
const (
16-
YellowButtonCss = "font-bold bg-amber-600 p-2 rounded mx-1"
17-
ErrorDivCss = "flex flex-row fixed bottom-4 left-4 bg-red-500 p-4 text-xl rounded-lg"
18-
CenteringDivCss = "flex flex-row min-h-screen justify-center items-center"
19-
WindowDivCss = "p-4 text-center text-xl shadow-lg bg-zinc-800 rounded-lg mx-10"
20-
InviCss = "fixed invisible"
21-
RootContainerCss = "shadow-lg bg-zinc-800 rounded-lg p-6 min-h-72 relative"
22-
LoadingCss = "flex flex-row justify-center items-center"
23-
RemoveButtonCss = "font-bold bg-red-500 p-2 rounded hover:bg-red-700 m-1"
24-
LogoutButtonCss = "font-bold bg-orange-600 p-2 rounded mx-1 hover:bg-orange-800"
25-
UpdateButtonCss = "bg-green-600 hover:bg-green-800 text-xl p-2 rounded bottom-4 right-4 fixed"
26-
InstallButtonCss = "bg-green-600 hover:bg-green-800 p-2 rounded m-2"
27-
BurgerMenuButtonCss = "text-xl fixed top-4 right-4"
28-
RootButtonsCss = "flex flex-col absolute top-12 right-4"
16+
YellowButtonCss = "font-bold bg-amber-600 p-2 rounded mx-1"
17+
ErrorDivCss = "flex flex-row fixed bottom-4 left-4 bg-red-500 p-4 text-xl rounded-lg"
18+
CenteringDivCss = "flex flex-row min-h-screen justify-center items-center"
19+
WindowDivCss = "p-4 text-center text-xl shadow-lg bg-zinc-800 rounded-lg mx-10"
20+
InviCss = "fixed invisible"
21+
RootContainerCss = "shadow-lg bg-zinc-800 rounded-lg p-6 min-h-72 relative"
22+
LoadingCss = "flex flex-row justify-center items-center"
23+
RemoveButtonCss = "font-bold bg-red-500 p-2 rounded hover:bg-red-700 m-1"
24+
LogoutButtonCss = "font-bold bg-orange-600 p-2 rounded mx-1 hover:bg-orange-800"
25+
UpdateButtonCss = "bg-green-600 hover:bg-green-800 text-xl p-2 rounded bottom-4 right-4 fixed"
26+
InstallButtonCss = "bg-green-600 hover:bg-green-800 p-2 rounded m-2"
27+
BurgerMenuButtonCss = "text-xl fixed top-4 right-4"
28+
RootButtonsCss = "flex flex-col absolute top-12 right-4"
29+
LoadFlushesButtonCss = YellowButtonCss + " hover:bg-amber-800 align-middle"
2930
)
3031

3132
type ErrorContainer struct {
@@ -100,7 +101,6 @@ func (b *RootContainer) OnMount(ctx app.Context) {
100101
if !creds.LoggedIn {
101102
log.Println("Not logged in at root...")
102103
} else {
103-
Hide("update-button")
104104
app.Window().GetElementByID("root-container").Set("className", RootContainerCss)
105105
app.Window().GetElementByID("about-container").Set("className", "invisible fixed")
106106
ShowLoading("flushes-loading")
@@ -111,6 +111,9 @@ func (b *RootContainer) OnMount(ctx app.Context) {
111111
ctx.Dispatch(func(ctx app.Context) {
112112
if !more {
113113
Hide("update-button")
114+
} else {
115+
log.Println("*** Showing update button...")
116+
app.Window().GetElementByID("update-button").Set("className", LoadFlushesButtonCss)
114117
}
115118
if err != nil {
116119
ShowErrorDiv(ctx, err, 2)
@@ -183,17 +186,19 @@ type buttonUpdate struct {
183186

184187
func (b *buttonUpdate) Render() app.UI {
185188
return app.Button().Text("Load More").OnClick(b.onClick).Class(
186-
YellowButtonCss + " hover:bg-amber-800 align-middle").ID("update-button")
189+
LoadFlushesButtonCss).ID("update-button")
187190
}
188191
func (b *buttonUpdate) onClick(ctx app.Context, e app.Event) {
189192
ShowLoading("flushes-loading-update")
190-
Hide("update-button")
191193
ctx.Async(func() {
192194
result, more := GetFlushesFromOID(ctx)
193195
log.Println("more-data: ", more)
194196
ctx.Dispatch(func(ctx app.Context) {
195197
if !more {
196198
Hide("update-button")
199+
} else {
200+
log.Println("*** Showing update button...")
201+
app.Window().GetElementByID("update-button").Set("className", LoadFlushesButtonCss)
197202
}
198203
defer Hide("flushes-loading-update")
199204
if result == nil {

0 commit comments

Comments
 (0)