Skip to content

Commit 7ecd247

Browse files
authored
App image cache fix (#2385)
closes #2153
2 parents 1d625d2 + da6d28a commit 7ecd247

File tree

4 files changed

+10
-3
lines changed

4 files changed

+10
-3
lines changed

app/lib/pages/apps/providers/add_app_provider.dart

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import 'dart:io';
22

3+
import 'package:cached_network_image/cached_network_image.dart';
34
import 'package:flutter/cupertino.dart';
45
import 'package:flutter/material.dart';
56
import 'package:flutter/services.dart';
@@ -663,6 +664,9 @@ class AddAppProvider extends ChangeNotifier {
663664
var file = await imagePicker.pickImage(source: ImageSource.gallery);
664665
if (file != null) {
665666
imageFile = File(file.path);
667+
if (imageUrl != null) {
668+
await CachedNetworkImage.evictFromCache(imageUrl!, cacheKey: imageUrl);
669+
}
666670
imageUrl = null;
667671
}
668672
notifyListeners();

app/lib/providers/app_provider.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ class AppProvider extends BaseProvider {
5656
var app = await getAppDetailsServer(id);
5757
if (app != null) {
5858
var oldApp = apps.where((element) => element.id == id).firstOrNull;
59-
if (oldApp == null){
59+
if (oldApp == null) {
6060
return null;
6161
}
6262
var idx = apps.indexOf(oldApp);

app/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ dependencies:
8484
sign_in_with_apple: ^6.1.1
8585
google_sign_in: 6.2.1
8686
location: ^7.0.0
87-
cached_network_image: ^3.3.1
87+
cached_network_image: 3.4.1
8888
map_launcher: ^3.3.1
8989
internet_connection_checker_plus: ^2.5.0
9090
geolocator:

backend/utils/other/storage.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,7 @@ def upload_plugin_logo(file_path: str, plugin_id: str):
243243
bucket = storage_client.bucket(omi_plugins_bucket)
244244
path = f'{plugin_id}.png'
245245
blob = bucket.blob(path)
246+
blob.cache_control = 'public, no-cache'
246247
blob.upload_from_filename(file_path)
247248
return f'https://storage.googleapis.com/{omi_plugins_bucket}/{path}'
248249

@@ -258,8 +259,10 @@ def upload_app_thumbnail(file_path: str, thumbnail_id: str) -> str:
258259
bucket = storage_client.bucket(app_thumbnails_bucket)
259260
path = f'{thumbnail_id}.jpg'
260261
blob = bucket.blob(path)
262+
blob.cache_control = 'public, no-cache'
261263
blob.upload_from_filename(file_path)
262-
return f'https://storage.googleapis.com/{app_thumbnails_bucket}/{path}'
264+
public_url = f'https://storage.googleapis.com/{app_thumbnails_bucket}/{path}'
265+
return public_url
263266

264267
def get_app_thumbnail_url(thumbnail_id: str) -> str:
265268
path = f'{thumbnail_id}.jpg'

0 commit comments

Comments
 (0)