~cytrogen/fluent-reader-mobile

206160bdd33f486438c10067ba84107527f36cb6 — Bruce Liu 5 years ago 9f8ac89
fix fever api compatibility
2 files changed, 7 insertions(+), 5 deletions(-)

M lib/models/services/fever.dart
M lib/utils/utils.dart
M lib/models/services/fever.dart => lib/models/services/fever.dart +6 -2
@@ 67,7 67,8 @@ class FeverServiceHandler extends ServiceHandler {
      headers: { "content-type": "application/x-www-form-urlencoded" },
      body: "api_key=$apiKey$postparams",
    );
    return jsonDecode(response.body);
    final body = Utf8Decoder().convert(response.bodyBytes);
    return jsonDecode(body);
  }

  int get lastId => _lastId;


@@ 124,7 125,10 @@ class FeverServiceHandler extends ServiceHandler {
    do {
      response = (await _fetchAPI(params: "&items&max_id=$minId"))["items"];
      if (response == null) throw Error();
      items.addAll(response.where((i) => i["id"] > lastId));
      for (var i in response) {
        if (i["id"] is String)  i["id"] = int.parse(i["id"]);
        if (i["id"] > lastId) items.add(i);
      }
      if (response.length == 0 && minId == Utils.syncMaxId) {
        useInt32 = true;
        minId = 2147483647;

M lib/utils/utils.dart => lib/utils/utils.dart +1 -3
@@ 1,5 1,3 @@
import 'dart:math';

import 'package:fluent_reader_lite/generated/l10n.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';


@@ 7,7 5,7 @@ import 'package:http/http.dart' as http;
import 'package:url_launcher/url_launcher.dart';

abstract class Utils {
  static final syncMaxId = pow(2, 50);
  static const syncMaxId = 9007199254740991;

  static void openExternal(String url) {
    launch(url, forceSafariVC: false, forceWebView: false);