~garritfra/FlutterFlux

e53565f3931d8891960d0f5654c648572ff107d1 — Garrit Franke 9 months ago b5aac09
feat: mark all as read
2 files changed, 19 insertions(+), 0 deletions(-)

M lib/main.dart
M lib/miniflux.dart
M lib/main.dart => lib/main.dart +9 -0
@@ 70,6 70,11 @@ class _MyHomePageState extends State<MyHomePage> {
    });
  }

  void _markAllAsRead() async {
    await MinifluxApi.instance.markAllAsRead();
    _initUnreadPosts();
  }

  @override
  void initState() {
    checkConfig().then((success) {


@@ 112,6 117,10 @@ class _MyHomePageState extends State<MyHomePage> {
                Navigator.pushNamed(context, "/config");
              },
            ),
            IconButton(
              icon: const Icon(Icons.check),
              onPressed: _markAllAsRead,
            ),
          ],
          title: Text(widget.title),
        ),

M lib/miniflux.dart => lib/miniflux.dart +10 -0
@@ 107,4 107,14 @@ class MinifluxApi {
        body: encodedBody, method: RequestMethod.put, path: "/entries");
    return res;
  }

  Future markAllAsRead() async {
    Response res = await request(method: RequestMethod.get, path: "/me");
    dynamic user = json.decode(res.body);
    int userId = user["id"];
    await request(
        method: RequestMethod.put,
        path: "/users/$userId/mark-all-as-read",
        body: {});
  }
}