Move-cache-logic (#1501)

* fix(igc-cache): fix logic not to ignore ignores :P

* fix(cache logic): fix incorrect return

---------

Co-authored-by: ggurdin <46800240+ggurdin@users.noreply.github.com>
pull/1593/head
wcjord 10 months ago committed by GitHub
parent 426e37b1a5
commit cffc697df1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -1,11 +1,6 @@
import 'dart:async';
import 'dart:developer';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:matrix/matrix.dart';
import 'package:fluffychat/pangea/choreographer/controllers/choreographer.dart';
import 'package:fluffychat/pangea/choreographer/controllers/error_service.dart';
import 'package:fluffychat/pangea/choreographer/controllers/span_data_controller.dart';
@ -14,6 +9,10 @@ import 'package:fluffychat/pangea/choreographer/models/pangea_match_model.dart';
import 'package:fluffychat/pangea/choreographer/repo/igc_repo.dart';
import 'package:fluffychat/pangea/choreographer/widgets/igc/span_card.dart';
import 'package:fluffychat/pangea/events/event_wrappers/pangea_message_event.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:matrix/matrix.dart';
import '../../common/utils/error_handler.dart';
import '../../common/utils/overlay.dart';
import '../models/span_card_model.dart';
@ -103,18 +102,16 @@ class IgcController {
_initializeCacheClearing();
}
// Check if cached data exists
if (_igcTextDataCache.containsKey(reqBody.hashCode)) {
igcTextData = await _igcTextDataCache[reqBody.hashCode]!.data;
return;
// if the request is not in the cache, add it
if (!_igcTextDataCache.containsKey(reqBody.hashCode)) {
_igcTextDataCache[reqBody.hashCode] = _IGCTextDataCacheItem(
data: IgcRepo.getIGC(
choreographer.accessToken,
igcRequest: reqBody,
),
);
}
final igcFuture = IgcRepo.getIGC(
choreographer.accessToken,
igcRequest: reqBody,
);
_igcTextDataCache[reqBody.hashCode] =
_IGCTextDataCacheItem(data: igcFuture);
final IGCTextData igcTextDataResponse =
await _igcTextDataCache[reqBody.hashCode]!.data;

Loading…
Cancel
Save