ui: Re-implement the new conversation page
This commit is contained in:
@@ -11,7 +11,9 @@ import "package:moxxyv2/ui/redux/account/state.dart";
|
||||
import "package:moxxyv2/ui/redux/account/actions.dart";
|
||||
import "package:moxxyv2/ui/redux/debug/actions.dart";
|
||||
import "package:moxxyv2/ui/redux/preferences/actions.dart";
|
||||
import "package:moxxyv2/ui/pages/conversation/arguments.dart";
|
||||
|
||||
import "package:flutter/material.dart";
|
||||
import "package:get_it/get_it.dart";
|
||||
import "package:flutter_background_service/flutter_background_service.dart";
|
||||
import "package:redux/redux.dart";
|
||||
@@ -51,6 +53,7 @@ void handleBackgroundServiceData(Map<String, dynamic>? data) {
|
||||
if (event.permissionsToRequest.isNotEmpty) {
|
||||
(() async {
|
||||
for (final perm in event.permissionsToRequest) {
|
||||
// TODO: Use the function that requests multiple permissions at once
|
||||
await Permission.byValue(perm).request();
|
||||
}
|
||||
})();
|
||||
@@ -162,5 +165,20 @@ void handleBackgroundServiceData(Map<String, dynamic>? data) {
|
||||
GetIt.I.get<UIDownloadService>().onProgress(event.id, event.progress);
|
||||
}
|
||||
break;
|
||||
case events.newConversationDoneEventType: {
|
||||
final event = events.NewConversationDoneEvent.fromJson(data);
|
||||
|
||||
FlutterBackgroundService().sendData(
|
||||
commands.LoadMessagesForJidAction(jid: event.jid).toJson()
|
||||
);
|
||||
|
||||
store.dispatch(NavigateToAction.pushNamedAndRemoveUntil(
|
||||
conversationRoute,
|
||||
ModalRoute.withName(conversationsRoute),
|
||||
arguments: ConversationPageArguments(jid: event.jid)
|
||||
)
|
||||
);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,14 +1,39 @@
|
||||
import "package:moxxyv2/ui/constants.dart";
|
||||
import "package:moxxyv2/shared/commands.dart" as commands;
|
||||
import "package:moxxyv2/ui/redux/state.dart";
|
||||
import "package:moxxyv2/ui/redux/conversation/actions.dart";
|
||||
import "package:moxxyv2/ui/pages/conversation/arguments.dart";
|
||||
|
||||
import "package:flutter/material.dart";
|
||||
import "package:redux/redux.dart";
|
||||
import "package:flutter_background_service/flutter_background_service.dart";
|
||||
import "package:flutter_redux_navigation/flutter_redux_navigation.dart";
|
||||
|
||||
void conversationsMiddleware(Store<MoxxyState> store, action, NextDispatcher next) async {
|
||||
// TODO: I think this all has to go
|
||||
if (action is AddConversationFromUIAction) {
|
||||
// TODO: Notify the backend
|
||||
} else if (action is CloseConversationAction) {
|
||||
// TODO: Notify the backend
|
||||
final jid = action.jid;
|
||||
if (store.state.conversations.containsKey(jid)) {
|
||||
// Just go there
|
||||
FlutterBackgroundService().sendData(
|
||||
commands.LoadMessagesForJidAction(jid: jid).toJson()
|
||||
);
|
||||
|
||||
store.dispatch(NavigateToAction.pushNamedAndRemoveUntil(
|
||||
conversationRoute,
|
||||
ModalRoute.withName(conversationsRoute),
|
||||
arguments: ConversationPageArguments(jid: jid)
|
||||
)
|
||||
);
|
||||
} else {
|
||||
FlutterBackgroundService().sendData(
|
||||
commands.AddConversationAction(
|
||||
jid: action.jid,
|
||||
title: action.title,
|
||||
avatarUrl: action.avatarUrl,
|
||||
lastMessageBody: action.lastMessageBody
|
||||
).toJson()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
next(action);
|
||||
|
||||
Reference in New Issue
Block a user