fix(service): Fix defaultMuteState not being honoured

This commit is contained in:
PapaTutuWawa 2022-12-10 12:02:09 +01:00
parent a08a110ef6
commit 21878ae135
2 changed files with 21 additions and 10 deletions

View File

@ -191,6 +191,7 @@ Future<void> performAddConversation(AddConversationCommand command, { dynamic ex
final updatedConversation = await cs.updateConversation(
conversation.id,
open: true,
lastChangeTimestamp: DateTime.now().millisecondsSinceEpoch,
);
sendEvent(
@ -208,17 +209,17 @@ Future<void> performAddConversation(AddConversationCommand command, { dynamic ex
);
return;
} else {
final preferences = await GetIt.I.get<PreferencesService>().getPreferences();
final conversation = await cs.addConversationFromData(
command.title,
null,
command.avatarUrl,
command.jid,
0,
-1,
DateTime.now().millisecondsSinceEpoch,
true,
// TODO(PapaTutuWawa): Take as an argument
false,
(await GetIt.I.get<PreferencesService>().getPreferences()).enableOmemoByDefault,
preferences.defaultMuteState,
preferences.enableOmemoByDefault,
);
sendEvent(
@ -341,24 +342,25 @@ Future<void> performAddContact(AddContactCommand command, { dynamic extra }) asy
final c = await cs.updateConversation(
conversation.id,
open: true,
lastChangeTimestamp: DateTime.now().millisecondsSinceEpoch,
);
sendEvent(
AddContactResultEvent(conversation: c, added: false),
id: id,
);
} else {
} else {
final prefs = await GetIt.I.get<PreferencesService>().getPreferences();
final c = await cs.addConversationFromData(
jid.split('@')[0],
null,
'',
jid,
0,
-1,
DateTime.now().millisecondsSinceEpoch,
true,
// TODO(PapaTutuWawa): Take as an argument
false,
(await GetIt.I.get<PreferencesService>().getPreferences()).enableOmemoByDefault,
prefs.defaultMuteState,
prefs.enableOmemoByDefault,
);
sendEvent(
AddContactResultEvent(conversation: c, added: true),

View File

@ -271,7 +271,16 @@ class ConversationBloc extends Bloc<ConversationEvent, ConversationState> {
}
Future<void> _onJidAdded(JidAddedEvent event, Emitter<ConversationState> emit) async {
// TODO(Unknown): Maybe have some state here
// Just update the state here. If it does not work, then the next conversation
// update will fix it.
emit(
state.copyWith(
conversation: state.conversation!.copyWith(
inRoster: true,
),
),
);
await MoxplatformPlugin.handler.getDataSender().sendData(
AddContactCommand(jid: state.conversation!.jid),
);