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: {});
+ }
}