Merge branch 'krille/stories-profiles' into 'main'

fix: Load story avatars faster

See merge request famedly/fluffychat!750
This commit is contained in:
Krille Fear 2022-02-18 20:36:16 +00:00
commit 5b91bc3a27
8 changed files with 49 additions and 19 deletions

View File

@ -121,22 +121,31 @@ class StoriesHeader extends StatelessWidget {
...client.storiesRooms.map(
(room) => Opacity(
opacity: room.hasPosts ? 1 : 0.75,
child: _StoryButton(
label: room.creatorDisplayname,
child: Avatar(
mxContent: room
.getState(EventTypes.RoomCreate)!
.sender
.avatarUrl,
name: room.creatorDisplayname,
size: 100,
fontSize: 24,
),
unread: room.membership == Membership.invite ||
room.hasNewMessages,
onPressed: () => _goToStoryAction(context, room.id),
onLongPressed: () => _contextualActions(context, room),
),
child: FutureBuilder<Profile>(
future: room.getCreatorProfile(),
builder: (context, snapshot) {
final displayname = snapshot.data?.displayName ??
room
.getState(EventTypes.RoomCreate)!
.senderId
.localpart!;
final avatarUrl = snapshot.data?.avatarUrl;
return _StoryButton(
label: displayname,
child: Avatar(
mxContent: avatarUrl,
name: displayname,
size: 100,
fontSize: 24,
),
unread: room.membership == Membership.invite ||
room.hasNewMessages,
onPressed: () =>
_goToStoryAction(context, room.id),
onLongPressed: () =>
_contextualActions(context, room),
);
}),
),
),
],
@ -148,8 +157,8 @@ class StoriesHeader extends StatelessWidget {
}
extension on Room {
String get creatorDisplayname =>
getState(EventTypes.RoomCreate)!.sender.calcDisplayname();
Future<Profile> getCreatorProfile() =>
client.getProfileFromUserId(getState(EventTypes.RoomCreate)!.senderId);
bool get hasPosts {
if (membership == Membership.invite) return true;

View File

@ -2,6 +2,7 @@ import 'dart:io';
import 'package:flutter/foundation.dart';
import 'package:desktop_lifecycle/desktop_lifecycle.dart';
import 'package:desktop_notifications/desktop_notifications.dart';
import 'package:flutter_gen/gen_l10n/l10n.dart';
import 'package:http/http.dart' as http;
@ -17,7 +18,10 @@ import 'package:fluffychat/widgets/matrix.dart';
extension LocalNotificationsExtension on MatrixState {
void showLocalNotification(EventUpdate eventUpdate) async {
final roomId = eventUpdate.roomID;
if (webHasFocus && activeRoomId == roomId) return;
if (activeRoomId == roomId) {
if (kIsWeb && webHasFocus) return;
if (Platform.isLinux && DesktopLifecycle.instance.isActive.value) return;
}
final room = client.getRoomById(roomId);
if (room == null) {
Logs().w('Can not display notification for unknown room $roomId');

View File

@ -7,6 +7,7 @@
#include "generated_plugin_registrant.h"
#include <desktop_drop/desktop_drop_plugin.h>
#include <desktop_lifecycle/desktop_lifecycle_plugin.h>
#include <file_selector_linux/file_selector_plugin.h>
#include <flutter_secure_storage_linux/flutter_secure_storage_linux_plugin.h>
#include <url_launcher_linux/url_launcher_plugin.h>
@ -15,6 +16,9 @@ void fl_register_plugins(FlPluginRegistry* registry) {
g_autoptr(FlPluginRegistrar) desktop_drop_registrar =
fl_plugin_registry_get_registrar_for_plugin(registry, "DesktopDropPlugin");
desktop_drop_plugin_register_with_registrar(desktop_drop_registrar);
g_autoptr(FlPluginRegistrar) desktop_lifecycle_registrar =
fl_plugin_registry_get_registrar_for_plugin(registry, "DesktopLifecyclePlugin");
desktop_lifecycle_plugin_register_with_registrar(desktop_lifecycle_registrar);
g_autoptr(FlPluginRegistrar) file_selector_linux_registrar =
fl_plugin_registry_get_registrar_for_plugin(registry, "FileSelectorPlugin");
file_selector_plugin_register_with_registrar(file_selector_linux_registrar);

View File

@ -4,6 +4,7 @@
list(APPEND FLUTTER_PLUGIN_LIST
desktop_drop
desktop_lifecycle
file_selector_linux
flutter_secure_storage_linux
url_launcher_linux

View File

@ -316,6 +316,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "0.3.2"
desktop_lifecycle:
dependency: "direct main"
description:
name: desktop_lifecycle
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.0"
desktop_notifications:
dependency: "direct main"
description:

View File

@ -20,6 +20,7 @@ dependencies:
connectivity_plus: ^2.2.0
cupertino_icons: any
desktop_drop: ^0.3.2
desktop_lifecycle: ^0.1.0
desktop_notifications: ^0.6.3
device_info_plus: ^3.2.1
email_validator: ^2.0.1

View File

@ -8,6 +8,7 @@
#include <connectivity_plus_windows/connectivity_plus_windows_plugin.h>
#include <desktop_drop/desktop_drop_plugin.h>
#include <desktop_lifecycle/desktop_lifecycle_plugin.h>
#include <file_selector_windows/file_selector_plugin.h>
#include <flutter_secure_storage_windows/flutter_secure_storage_windows_plugin.h>
#include <flutter_webrtc/flutter_web_r_t_c_plugin.h>
@ -18,6 +19,8 @@ void RegisterPlugins(flutter::PluginRegistry* registry) {
registry->GetRegistrarForPlugin("ConnectivityPlusWindowsPlugin"));
DesktopDropPluginRegisterWithRegistrar(
registry->GetRegistrarForPlugin("DesktopDropPlugin"));
DesktopLifecyclePluginRegisterWithRegistrar(
registry->GetRegistrarForPlugin("DesktopLifecyclePlugin"));
FileSelectorPluginRegisterWithRegistrar(
registry->GetRegistrarForPlugin("FileSelectorPlugin"));
FlutterSecureStorageWindowsPluginRegisterWithRegistrar(

View File

@ -5,6 +5,7 @@
list(APPEND FLUTTER_PLUGIN_LIST
connectivity_plus_windows
desktop_drop
desktop_lifecycle
file_selector_windows
flutter_secure_storage_windows
flutter_webrtc