Skip to content
Open
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
8 changes: 5 additions & 3 deletions src/aiseed_weather/components/amedas_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

from __future__ import annotations

import asyncio

import flet as ft

from aiseed_weather.services.jma_amedas_service import JmaAmedasService
Expand Down Expand Up @@ -43,7 +45,7 @@ async def load(force: bool = False):
set_error(str(e))
set_state("error")

ft.use_effect(lambda: ft.run_task(load), [])
ft.use_effect(lambda: asyncio.create_task(load()) and None, [])

if state in ("idle", "loading"):
return ft.Column(
Expand All @@ -61,7 +63,7 @@ async def load(force: bool = False):
ft.Text(f"Could not fetch AMeDAS: {error}", color=ft.Colors.RED),
ft.FilledButton(
content=ft.Text("再取得 / Retry"),
on_click=lambda _: ft.run_task(lambda: load(force=True)),
on_click=lambda _: asyncio.create_task(load(force=True)),
),
],
)
Expand All @@ -73,7 +75,7 @@ async def load(force: bool = False):
ft.Text("AMeDAS (JMA)", size=18, weight=ft.FontWeight.BOLD),
ft.FilledButton(
content=ft.Text("再取得"),
on_click=lambda _: ft.run_task(lambda: load(force=True)),
on_click=lambda _: asyncio.create_task(load(force=True)),
),
],
alignment=ft.MainAxisAlignment.SPACE_BETWEEN,
Expand Down
6 changes: 3 additions & 3 deletions src/aiseed_weather/components/map_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ async def load(force: bool = False):
set_error(f"{type(e).__name__}: {e}")
set_state("error")

ft.use_effect(lambda: ft.run_task(load), [])
ft.use_effect(lambda: asyncio.create_task(load()) and None, [])

if state == "disabled":
return ft.Column(
Expand Down Expand Up @@ -104,7 +104,7 @@ async def load(force: bool = False):
ft.Text(f"Could not render map: {error}", color=ft.Colors.RED),
ft.FilledButton(
content=ft.Text("再取得 / Retry"),
on_click=lambda _: ft.run_task(lambda: load(force=True)),
on_click=lambda _: asyncio.create_task(load(force=True)),
),
],
)
Expand All @@ -120,7 +120,7 @@ async def load(force: bool = False):
),
ft.FilledButton(
content=ft.Text("再取得"),
on_click=lambda _: ft.run_task(lambda: load(force=True)),
on_click=lambda _: asyncio.create_task(load(force=True)),
),
],
alignment=ft.MainAxisAlignment.SPACE_BETWEEN,
Expand Down
8 changes: 5 additions & 3 deletions src/aiseed_weather/components/radar_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

from __future__ import annotations

import asyncio

import flet as ft

from aiseed_weather.services.jma_radar_service import JmaRadarService
Expand All @@ -34,7 +36,7 @@ async def load(force: bool = False):
set_state("error")

# Mount-time fetch. Runs once per RadarView instance.
ft.use_effect(lambda: ft.run_task(load), [])
ft.use_effect(lambda: asyncio.create_task(load()) and None, [])

if state in ("idle", "loading"):
return ft.Column(
Expand All @@ -52,7 +54,7 @@ async def load(force: bool = False):
ft.Text(f"Could not fetch radar: {error}", color=ft.Colors.RED),
ft.FilledButton(
content=ft.Text("再取得 / Retry"),
on_click=lambda _: ft.run_task(lambda: load(force=True)),
on_click=lambda _: asyncio.create_task(load(force=True)),
),
],
)
Expand All @@ -65,7 +67,7 @@ async def load(force: bool = False):
ft.Text("Rainfall Nowcast (JMA)", size=18, weight=ft.FontWeight.BOLD),
ft.FilledButton(
content=ft.Text("再取得"),
on_click=lambda _: ft.run_task(lambda: load(force=True)),
on_click=lambda _: asyncio.create_task(load(force=True)),
),
],
alignment=ft.MainAxisAlignment.SPACE_BETWEEN,
Expand Down