Mark previewIDs as not nullable
This commit is contained in:
@@ -23,7 +23,7 @@ class FileDataService {
|
||||
final _logger = Logger("FileDataService");
|
||||
final _dio = NetworkClient.instance.enteDio;
|
||||
late final SharedPreferences _prefs;
|
||||
Map<int, PreviewInfo>? previewIds;
|
||||
Map<int, PreviewInfo> previewIds = {};
|
||||
|
||||
void init(SharedPreferences prefs) {
|
||||
_prefs = prefs;
|
||||
@@ -33,9 +33,8 @@ class FileDataService {
|
||||
/// upload is successful, instead update the local copy of those
|
||||
/// preview ids
|
||||
void appendPreview(int id, String objectId, int objectSize) {
|
||||
if (previewIds?.containsKey(id) ?? false) return;
|
||||
previewIds ??= {};
|
||||
previewIds?[id] = PreviewInfo(
|
||||
if (previewIds.containsKey(id)) return;
|
||||
previewIds[id] = PreviewInfo(
|
||||
objectId: objectId,
|
||||
objectSize: objectSize,
|
||||
);
|
||||
|
||||
@@ -106,8 +106,7 @@ class PreviewVideoStore {
|
||||
Future<bool> isSharedFileStreamble(EnteFile file) async {
|
||||
try {
|
||||
if (FileDataService.instance.previewIds
|
||||
?.containsKey(file.uploadedFileID) ??
|
||||
false) {
|
||||
.containsKey(file.uploadedFileID)) {
|
||||
return true;
|
||||
}
|
||||
await _getPreviewUrl(file);
|
||||
@@ -527,7 +526,7 @@ class PreviewVideoStore {
|
||||
try {
|
||||
late final String objectID;
|
||||
final PreviewInfo? previewInfo =
|
||||
FileDataService.instance.previewIds?[file.uploadedFileID!];
|
||||
FileDataService.instance.previewIds[file.uploadedFileID!];
|
||||
bool shouldAppendPreview = false;
|
||||
(String, String)? previewURLResult;
|
||||
if (previewInfo == null) {
|
||||
@@ -768,7 +767,7 @@ class PreviewVideoStore {
|
||||
|
||||
final previewIds = FileDataService.instance.previewIds;
|
||||
final allFiles = files
|
||||
.where((file) => previewIds?[file.uploadedFileID] == null)
|
||||
.where((file) => previewIds[file.uploadedFileID] == null)
|
||||
.sorted((a, b) {
|
||||
// put higher duration videos last along with remote files
|
||||
final first = (a.localID == null ? 2 : 0) +
|
||||
|
||||
@@ -180,8 +180,7 @@ class _FileDetailsWidgetState extends State<FileDetailsWidget> {
|
||||
const FileDetailsDivider(),
|
||||
if (widget.file.uploadedFileID != null &&
|
||||
(FileDataService.instance.previewIds
|
||||
?.containsKey(widget.file.uploadedFileID) ??
|
||||
false)) ...[
|
||||
.containsKey(widget.file.uploadedFileID))) ...[
|
||||
ValueListenableBuilder(
|
||||
valueListenable: _exifNotifier,
|
||||
builder: (context, _, __) => PreviewPropertiesItemWidget(
|
||||
|
||||
@@ -38,8 +38,7 @@ class _VideoStreamChangeWidgetState extends State<VideoStreamChangeWidget> {
|
||||
Widget build(BuildContext context) {
|
||||
final bool isPreviewAvailable = widget.file.uploadedFileID != null &&
|
||||
(FileDataService.instance.previewIds
|
||||
?.containsKey(widget.file.uploadedFileID) ??
|
||||
false);
|
||||
.containsKey(widget.file.uploadedFileID));
|
||||
if (!isPreviewAvailable) {
|
||||
return const SizedBox();
|
||||
}
|
||||
|
||||
@@ -59,8 +59,7 @@ class _VideoWidgetState extends State<VideoWidget> {
|
||||
});
|
||||
if (widget.file.isUploaded) {
|
||||
isPreviewLoadable = FileDataService.instance.previewIds
|
||||
?.containsKey(widget.file.uploadedFileID) ??
|
||||
false;
|
||||
.containsKey(widget.file.uploadedFileID);
|
||||
if (!widget.file.isOwner) {
|
||||
// For shared video, we need to on-demand check if the file is streamable
|
||||
// and if not, we need to set isPreviewLoadable to false
|
||||
|
||||
Reference in New Issue
Block a user