Skip to content

Commit

Permalink
fix: application will raise an error when selecting unsplash image in…
Browse files Browse the repository at this point in the history
… local mode (AppFlowy-IO#4604)
  • Loading branch information
LucasXu0 authored Feb 5, 2024
1 parent ef4bce2 commit 271f781
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import 'dart:convert';

import 'package:appflowy/shared/custom_image_cache_manager.dart';
import 'package:appflowy/util/string_extension.dart';
import 'package:appflowy_backend/log.dart';
import 'package:appflowy_backend/protobuf/flowy-user/protobuf.dart';
import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/material.dart';
Expand Down Expand Up @@ -56,7 +57,12 @@ class FlowyNetworkImage extends StatelessWidget {
final header = <String, String>{};
final token = userProfilePB?.token;
if (token != null) {
header['Authorization'] = 'Bearer ${jsonDecode(token)['access_token']}';
try {
final decodedToken = jsonDecode(token);
header['Authorization'] = 'Bearer ${decodedToken['access_token']}';
} catch (e) {
Log.error('unable to decode token: $e');
}
}
return header;
}
Expand Down

0 comments on commit 271f781

Please sign in to comment.