mirror of
https://gitlab.com/famedly/fluffychat.git
synced 2024-11-27 23:09:35 +01:00
fix: linux snap notification avatar
This commit is contained in:
parent
12e9637ddc
commit
227869d84d
@ -3,9 +3,10 @@ import 'dart:io';
|
|||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
|
|
||||||
import 'package:desktop_notifications/desktop_notifications.dart';
|
import 'package:desktop_notifications/desktop_notifications.dart';
|
||||||
import 'package:flutter_cache_manager/flutter_cache_manager.dart';
|
|
||||||
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
||||||
|
import 'package:http/http.dart' as http;
|
||||||
import 'package:matrix/matrix.dart';
|
import 'package:matrix/matrix.dart';
|
||||||
|
import 'package:path_provider/path_provider.dart';
|
||||||
import 'package:universal_html/html.dart' as html;
|
import 'package:universal_html/html.dart' as html;
|
||||||
|
|
||||||
import 'package:fluffychat/config/app_config.dart';
|
import 'package:fluffychat/config/app_config.dart';
|
||||||
@ -45,14 +46,23 @@ extension LocalNotificationsExtension on MatrixState {
|
|||||||
icon: icon.toString(),
|
icon: icon.toString(),
|
||||||
);
|
);
|
||||||
} else if (Platform.isLinux) {
|
} else if (Platform.isLinux) {
|
||||||
final appIconUrl = room.avatar
|
final appIconUrl = room.avatar?.getThumbnail(
|
||||||
?.getThumbnail(
|
|
||||||
room.client,
|
room.client,
|
||||||
width: 56,
|
width: 56,
|
||||||
height: 56,
|
height: 56,
|
||||||
)
|
);
|
||||||
.toString();
|
File appIconFile;
|
||||||
final appIconFile = await DefaultCacheManager().getSingleFile(appIconUrl);
|
if (appIconUrl != null) {
|
||||||
|
final tempDirectory = await getApplicationSupportDirectory();
|
||||||
|
final avatarDirectory =
|
||||||
|
await Directory('${tempDirectory.path}/notiavatars/').create();
|
||||||
|
appIconFile = File(
|
||||||
|
'${avatarDirectory.path}/${Uri.encodeComponent(appIconUrl.toString())}');
|
||||||
|
if (await appIconFile.exists() == false) {
|
||||||
|
final response = await http.get(appIconUrl);
|
||||||
|
await appIconFile.writeAsBytes(response.bodyBytes);
|
||||||
|
}
|
||||||
|
}
|
||||||
final notification = await linuxNotifications.notify(
|
final notification = await linuxNotifications.notify(
|
||||||
title,
|
title,
|
||||||
body: body,
|
body: body,
|
||||||
|
Loading…
Reference in New Issue
Block a user