mirror of
https://gitlab.com/famedly/fluffychat.git
synced 2024-11-24 04:59:26 +01:00
feat: Cache and resend status message
This commit is contained in:
parent
36e1ac6b58
commit
c8a70313b1
@ -97,6 +97,7 @@ class MatrixState extends State<Matrix> with WidgetsBindingObserver {
|
|||||||
StreamSubscription<UiaRequest> onUiaRequest;
|
StreamSubscription<UiaRequest> onUiaRequest;
|
||||||
StreamSubscription<html.Event> onFocusSub;
|
StreamSubscription<html.Event> onFocusSub;
|
||||||
StreamSubscription<html.Event> onBlurSub;
|
StreamSubscription<html.Event> onBlurSub;
|
||||||
|
StreamSubscription<Presence> onOwnPresence;
|
||||||
|
|
||||||
String _cachedPassword;
|
String _cachedPassword;
|
||||||
String get cachedPassword {
|
String get cachedPassword {
|
||||||
@ -311,6 +312,30 @@ class MatrixState extends State<Matrix> with WidgetsBindingObserver {
|
|||||||
widget.apl.currentState.pushNamedAndRemoveAllOthers('/');
|
widget.apl.currentState.pushNamedAndRemoveAllOthers('/');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Cache and resend status message
|
||||||
|
onOwnPresence ??= client.onPresence.stream.listen((presence) {
|
||||||
|
if (client.isLogged() &&
|
||||||
|
client.userID == presence.senderId &&
|
||||||
|
presence.presence?.statusMsg != null) {
|
||||||
|
Logs().v('Update status message: "${presence.presence.statusMsg}"');
|
||||||
|
store.setItem(
|
||||||
|
SettingKeys.ownStatusMessage, presence.presence.statusMsg);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (client.isLogged()) {
|
||||||
|
store.getItem(SettingKeys.ownStatusMessage).then((statusMsg) {
|
||||||
|
if (statusMsg?.isNotEmpty ?? false) {
|
||||||
|
Logs().v('Send cached status message: "$statusMsg"');
|
||||||
|
client.sendPresence(
|
||||||
|
client.userID,
|
||||||
|
PresenceType.online,
|
||||||
|
statusMsg: statusMsg,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
onUiaRequest ??= client.onUiaRequest.stream.listen(_onUiaRequest);
|
onUiaRequest ??= client.onUiaRequest.stream.listen(_onUiaRequest);
|
||||||
if (PlatformInfos.isWeb || PlatformInfos.isLinux) {
|
if (PlatformInfos.isWeb || PlatformInfos.isLinux) {
|
||||||
client.onSync.stream.first.then((s) {
|
client.onSync.stream.first.then((s) {
|
||||||
@ -381,6 +406,7 @@ class MatrixState extends State<Matrix> with WidgetsBindingObserver {
|
|||||||
onRoomKeyRequestSub?.cancel();
|
onRoomKeyRequestSub?.cancel();
|
||||||
onKeyVerificationRequestSub?.cancel();
|
onKeyVerificationRequestSub?.cancel();
|
||||||
onLoginStateChanged?.cancel();
|
onLoginStateChanged?.cancel();
|
||||||
|
onOwnPresence?.cancel();
|
||||||
onNotification?.cancel();
|
onNotification?.cancel();
|
||||||
onFocusSub?.cancel();
|
onFocusSub?.cancel();
|
||||||
onBlurSub?.cancel();
|
onBlurSub?.cancel();
|
||||||
|
@ -17,4 +17,5 @@ abstract class SettingKeys {
|
|||||||
'chat.fluffy.unifiedpush.registered';
|
'chat.fluffy.unifiedpush.registered';
|
||||||
static const String unifiedPushEndpoint = 'chat.fluffy.unifiedpush.endpoint';
|
static const String unifiedPushEndpoint = 'chat.fluffy.unifiedpush.endpoint';
|
||||||
static const String notificationCurrentIds = 'chat.fluffy.notification_ids';
|
static const String notificationCurrentIds = 'chat.fluffy.notification_ids';
|
||||||
|
static const String ownStatusMessage = 'chat.fluffy.status_msg';
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user