1
0
Fork 0
mirror of https://github.com/immich-app/immich.git synced 2025-03-01 15:11:21 +01:00

Fixed problem of not disconnecting Websocket when logging out

This commit is contained in:
Alex Tran 2022-02-14 14:42:06 -06:00
parent c234c95880
commit 75b1ed08b4
2 changed files with 46 additions and 47 deletions

View file

@ -51,56 +51,55 @@ class ImageViewerPage extends HookConsumerWidget {
}); });
}, },
), ),
body: Center( body: SafeArea(
child: Hero( child: Center(
tag: heroTag, child: Hero(
child: CachedNetworkImage( tag: heroTag,
fit: BoxFit.cover, child: CachedNetworkImage(
imageUrl: imageUrl, fit: BoxFit.cover,
httpHeaders: {"Authorization": "Bearer ${box.get(accessTokenKey)}"}, imageUrl: imageUrl,
fadeInDuration: const Duration(milliseconds: 250), httpHeaders: {"Authorization": "Bearer ${box.get(accessTokenKey)}"},
errorWidget: (context, url, error) => ConstrainedBox( fadeInDuration: const Duration(milliseconds: 250),
constraints: const BoxConstraints(maxWidth: 300), errorWidget: (context, url, error) => ConstrainedBox(
child: Wrap( constraints: const BoxConstraints(maxWidth: 300),
spacing: 32, child: Wrap(
runSpacing: 32, spacing: 32,
alignment: WrapAlignment.center, runSpacing: 32,
children: [ alignment: WrapAlignment.center,
const Text( children: [
"Failed To Render Image - Possibly Corrupted Data", const Text(
textAlign: TextAlign.center, "Failed To Render Image - Possibly Corrupted Data",
style: TextStyle(fontSize: 16, color: Colors.white),
),
SingleChildScrollView(
child: Text(
error.toString(),
textAlign: TextAlign.center, textAlign: TextAlign.center,
style: TextStyle(fontSize: 12, color: Colors.grey[400]), style: TextStyle(fontSize: 16, color: Colors.white),
), ),
), SingleChildScrollView(
], child: Text(
error.toString(),
textAlign: TextAlign.center,
style: TextStyle(fontSize: 12, color: Colors.grey[400]),
),
),
],
),
), ),
placeholder: (context, url) {
return CachedNetworkImage(
cacheKey: thumbnailUrl,
fit: BoxFit.cover,
imageUrl: thumbnailUrl,
httpHeaders: {"Authorization": "Bearer ${box.get(accessTokenKey)}"},
placeholderFadeInDuration: const Duration(milliseconds: 0),
progressIndicatorBuilder: (context, url, downloadProgress) => Transform.scale(
scale: 0.2,
child: CircularProgressIndicator(value: downloadProgress.progress),
),
errorWidget: (context, url, error) => Icon(
Icons.error,
color: Colors.grey[300],
),
);
},
), ),
// imageBuilder: (context, imageProvider) {
// return PhotoView(imageProvider: imageProvider);
// },
placeholder: (context, url) {
return CachedNetworkImage(
cacheKey: thumbnailUrl,
fit: BoxFit.cover,
imageUrl: thumbnailUrl,
httpHeaders: {"Authorization": "Bearer ${box.get(accessTokenKey)}"},
placeholderFadeInDuration: const Duration(milliseconds: 0),
progressIndicatorBuilder: (context, url, downloadProgress) => Transform.scale(
scale: 0.2,
child: CircularProgressIndicator(value: downloadProgress.progress),
),
errorWidget: (context, url, error) => Icon(
Icons.error,
color: Colors.grey[300],
),
);
},
), ),
), ),
), ),

View file

@ -51,7 +51,7 @@ class WebsocketNotifier extends StateNotifier<WebscoketState> {
final Ref ref; final Ref ref;
connect() { connect() {
var authenticationState = ref.watch(authenticationProvider); var authenticationState = ref.read(authenticationProvider);
if (authenticationState.isAuthenticated) { if (authenticationState.isAuthenticated) {
var accessToken = Hive.box(userInfoBox).get(accessTokenKey); var accessToken = Hive.box(userInfoBox).get(accessTokenKey);