Merge branch 'web-fix-login' into 'master'
[Web] Fix major issues See merge request ChristianPauly/fluffychat-flutter!20
This commit is contained in:
commit
12b9696ec3
|
@ -346,10 +346,12 @@ class MatrixState extends State<Matrix> {
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
if (widget.client == null) {
|
if (widget.client == null) {
|
||||||
|
print("[Matrix] Init matrix client");
|
||||||
client = Client(widget.clientName, debug: false);
|
client = Client(widget.clientName, debug: false);
|
||||||
if (!kIsWeb) {
|
if (!kIsWeb) {
|
||||||
_initWithStore();
|
_initWithStore();
|
||||||
} else {
|
} else {
|
||||||
|
print("[Web] Web platform detected - Store disabled!");
|
||||||
loadAccount();
|
loadAccount();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -20,7 +20,8 @@ class App extends StatelessWidget {
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Matrix(
|
return Matrix(
|
||||||
clientName: "FluffyChat",
|
clientName: "FluffyChat",
|
||||||
child: MaterialApp(
|
child: Builder(
|
||||||
|
builder: (BuildContext context) => MaterialApp(
|
||||||
title: 'FluffyChat',
|
title: 'FluffyChat',
|
||||||
theme: ThemeData(
|
theme: ThemeData(
|
||||||
brightness: Brightness.light,
|
brightness: Brightness.light,
|
||||||
|
@ -58,8 +59,7 @@ class App extends StatelessWidget {
|
||||||
const Locale('en'), // English
|
const Locale('en'), // English
|
||||||
const Locale('de'), // German
|
const Locale('de'), // German
|
||||||
],
|
],
|
||||||
home: Builder(
|
home: FutureBuilder<LoginState>(
|
||||||
builder: (BuildContext context) => FutureBuilder<LoginState>(
|
|
||||||
future: Matrix.of(context).client.onLoginStateChanged.stream.first,
|
future: Matrix.of(context).client.onLoginStateChanged.stream.first,
|
||||||
builder: (context, snapshot) {
|
builder: (context, snapshot) {
|
||||||
if (!snapshot.hasData) {
|
if (!snapshot.hasData) {
|
||||||
|
|
|
@ -7,7 +7,7 @@ extension LocalizedRoomDisplayname on Room {
|
||||||
if ((this.name?.isEmpty ?? true) &&
|
if ((this.name?.isEmpty ?? true) &&
|
||||||
(this.canonicalAlias?.isEmpty ?? true) &&
|
(this.canonicalAlias?.isEmpty ?? true) &&
|
||||||
!this.isDirectChat &&
|
!this.isDirectChat &&
|
||||||
this.mHeroes.isNotEmpty) {
|
(this.mHeroes != null && this.mHeroes.isNotEmpty)) {
|
||||||
return I18n.of(context).groupWith(this.displayname);
|
return I18n.of(context).groupWith(this.displayname);
|
||||||
}
|
}
|
||||||
return this.displayname;
|
return this.displayname;
|
||||||
|
|
|
@ -20,6 +20,7 @@ class Chat extends StatefulWidget {
|
||||||
final String id;
|
final String id;
|
||||||
|
|
||||||
const Chat(this.id, {Key key}) : super(key: key);
|
const Chat(this.id, {Key key}) : super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
_ChatState createState() => _ChatState();
|
_ChatState createState() => _ChatState();
|
||||||
}
|
}
|
||||||
|
@ -55,6 +56,8 @@ class _ChatState extends State<Chat> {
|
||||||
}
|
}
|
||||||
|
|
||||||
void updateView() {
|
void updateView() {
|
||||||
|
if (!mounted) return;
|
||||||
|
|
||||||
String seenByText = "";
|
String seenByText = "";
|
||||||
if (timeline.events.isNotEmpty) {
|
if (timeline.events.isNotEmpty) {
|
||||||
List lastReceipts = List.from(timeline.events.first.receipts);
|
List lastReceipts = List.from(timeline.events.first.receipts);
|
||||||
|
@ -74,10 +77,12 @@ class _ChatState extends State<Chat> {
|
||||||
(lastReceipts.length - 1).toString());
|
(lastReceipts.length - 1).toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (timeline != null) {
|
||||||
setState(() {
|
setState(() {
|
||||||
this.seenByText = seenByText;
|
this.seenByText = seenByText;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Future<bool> getTimeline() async {
|
Future<bool> getTimeline() async {
|
||||||
timeline ??= await room.getTimeline(onUpdate: updateView);
|
timeline ??= await room.getTimeline(onUpdate: updateView);
|
||||||
|
@ -88,6 +93,7 @@ class _ChatState extends State<Chat> {
|
||||||
@override
|
@override
|
||||||
void dispose() {
|
void dispose() {
|
||||||
timeline?.sub?.cancel();
|
timeline?.sub?.cancel();
|
||||||
|
timeline = null;
|
||||||
matrix.activeRoomId = "";
|
matrix.activeRoomId = "";
|
||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
|
@ -243,11 +249,15 @@ class _ChatState extends State<Chat> {
|
||||||
timeline.events.isNotEmpty) {
|
timeline.events.isNotEmpty) {
|
||||||
room.sendReadReceipt(timeline.events[0].eventId);
|
room.sendReadReceipt(timeline.events[0].eventId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (timeline.events.isEmpty) return Container();
|
||||||
|
|
||||||
return ListView.builder(
|
return ListView.builder(
|
||||||
reverse: true,
|
reverse: true,
|
||||||
itemCount: timeline.events.length + 1,
|
itemCount: timeline.events.length + 1,
|
||||||
controller: _scrollController,
|
controller: _scrollController,
|
||||||
itemBuilder: (BuildContext context, int i) => i == 0
|
itemBuilder: (BuildContext context, int i) {
|
||||||
|
return i == 0
|
||||||
? AnimatedContainer(
|
? AnimatedContainer(
|
||||||
height: seenByText.isEmpty ? 0 : 24,
|
height: seenByText.isEmpty ? 0 : 24,
|
||||||
duration: seenByText.isEmpty
|
duration: seenByText.isEmpty
|
||||||
|
@ -273,8 +283,8 @@ class _ChatState extends State<Chat> {
|
||||||
)
|
)
|
||||||
: Message(timeline.events[i - 1],
|
: Message(timeline.events[i - 1],
|
||||||
nextEvent:
|
nextEvent:
|
||||||
i >= 2 ? timeline.events[i - 2] : null),
|
i >= 2 ? timeline.events[i - 2] : null);
|
||||||
);
|
});
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
|
@ -13,6 +13,7 @@ import 'package:fluffychat/utils/room_extension.dart';
|
||||||
import 'package:fluffychat/utils/room_state_enums_extensions.dart';
|
import 'package:fluffychat/utils/room_state_enums_extensions.dart';
|
||||||
import 'package:fluffychat/views/chat_list.dart';
|
import 'package:fluffychat/views/chat_list.dart';
|
||||||
import 'package:fluffychat/views/invitation_selection.dart';
|
import 'package:fluffychat/views/invitation_selection.dart';
|
||||||
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
import 'package:image_picker/image_picker.dart';
|
import 'package:image_picker/image_picker.dart';
|
||||||
|
@ -181,7 +182,8 @@ class _ChatDetailsState extends State<ChatDetails> {
|
||||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
ContentBanner(widget.room.avatar,
|
ContentBanner(widget.room.avatar,
|
||||||
onEdit: widget.room.canSendEvent("m.room.avatar")
|
onEdit:
|
||||||
|
widget.room.canSendEvent("m.room.avatar") && !kIsWeb
|
||||||
? () => setAvatarAction(context)
|
? () => setAvatarAction(context)
|
||||||
: null),
|
: null),
|
||||||
Divider(height: 1),
|
Divider(height: 1),
|
||||||
|
|
|
@ -11,6 +11,7 @@ import 'package:fluffychat/utils/app_route.dart';
|
||||||
import 'package:fluffychat/utils/url_launcher.dart';
|
import 'package:fluffychat/utils/url_launcher.dart';
|
||||||
import 'package:fluffychat/views/archive.dart';
|
import 'package:fluffychat/views/archive.dart';
|
||||||
import 'package:fluffychat/views/settings.dart';
|
import 'package:fluffychat/views/settings.dart';
|
||||||
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_speed_dial/flutter_speed_dial.dart';
|
import 'package:flutter_speed_dial/flutter_speed_dial.dart';
|
||||||
import 'package:receive_sharing_intent/receive_sharing_intent.dart';
|
import 'package:receive_sharing_intent/receive_sharing_intent.dart';
|
||||||
|
@ -51,7 +52,8 @@ class _ChatListState extends State<ChatList> {
|
||||||
if (client.prevBatch?.isEmpty ?? true) {
|
if (client.prevBatch?.isEmpty ?? true) {
|
||||||
await client.onFirstSync.stream.first;
|
await client.onFirstSync.stream.first;
|
||||||
}
|
}
|
||||||
sub ??= client.onSync.stream.listen((s) => setState(() => null));
|
sub ??= client.onSync.stream
|
||||||
|
.listen((s) => mounted ? setState(() => null) : null);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,13 +62,16 @@ class _ChatListState extends State<ChatList> {
|
||||||
searchController.addListener(
|
searchController.addListener(
|
||||||
() => setState(() => null),
|
() => setState(() => null),
|
||||||
);
|
);
|
||||||
|
if (kIsWeb) {
|
||||||
getSharedData();
|
getSharedData();
|
||||||
|
}
|
||||||
super.initState();
|
super.initState();
|
||||||
}
|
}
|
||||||
|
|
||||||
StreamSubscription _intentDataStreamSubscription;
|
StreamSubscription _intentDataStreamSubscription;
|
||||||
|
|
||||||
void processSharedText(String text) {
|
void processSharedText(String text) {
|
||||||
|
if (text?.isEmpty ?? true) return;
|
||||||
if (text.startsWith("https://matrix.to/#/")) {
|
if (text.startsWith("https://matrix.to/#/")) {
|
||||||
UrlLauncher(context, text).openMatrixToUrl();
|
UrlLauncher(context, text).openMatrixToUrl();
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -4,6 +4,7 @@ import 'package:famedlysdk/famedlysdk.dart';
|
||||||
import 'package:fluffychat/components/matrix.dart';
|
import 'package:fluffychat/components/matrix.dart';
|
||||||
import 'package:fluffychat/i18n/i18n.dart';
|
import 'package:fluffychat/i18n/i18n.dart';
|
||||||
import 'package:fluffychat/utils/app_route.dart';
|
import 'package:fluffychat/utils/app_route.dart';
|
||||||
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
import 'chat_list.dart';
|
import 'chat_list.dart';
|
||||||
|
@ -73,6 +74,7 @@ class _LoginState extends State<Login> {
|
||||||
setState(() => passwordError = exception.toString());
|
setState(() => passwordError = exception.toString());
|
||||||
return setState(() => loading = false);
|
return setState(() => loading = false);
|
||||||
}
|
}
|
||||||
|
if (!kIsWeb) {
|
||||||
try {
|
try {
|
||||||
print("[Login] Setup Firebase...");
|
print("[Login] Setup Firebase...");
|
||||||
await matrix.setupFirebase();
|
await matrix.setupFirebase();
|
||||||
|
@ -83,6 +85,8 @@ class _LoginState extends State<Login> {
|
||||||
setState(() => passwordError = exception.toString());
|
setState(() => passwordError = exception.toString());
|
||||||
return setState(() => loading = false);
|
return setState(() => loading = false);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
print("[Login] Store account and go to ChatListView");
|
print("[Login] Store account and go to ChatListView");
|
||||||
await Matrix.of(context).saveAccount();
|
await Matrix.of(context).saveAccount();
|
||||||
setState(() => loading = false);
|
setState(() => loading = false);
|
||||||
|
|
|
@ -8,6 +8,7 @@ import 'package:fluffychat/i18n/i18n.dart';
|
||||||
import 'package:fluffychat/utils/app_route.dart';
|
import 'package:fluffychat/utils/app_route.dart';
|
||||||
import 'package:fluffychat/views/chat_list.dart';
|
import 'package:fluffychat/views/chat_list.dart';
|
||||||
import 'package:fluffychat/views/sign_up.dart';
|
import 'package:fluffychat/views/sign_up.dart';
|
||||||
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:image_picker/image_picker.dart';
|
import 'package:image_picker/image_picker.dart';
|
||||||
import 'package:toast/toast.dart';
|
import 'package:toast/toast.dart';
|
||||||
|
@ -106,7 +107,7 @@ class _SettingsState extends State<Settings> {
|
||||||
profile?.avatarUrl ?? MxContent(""),
|
profile?.avatarUrl ?? MxContent(""),
|
||||||
defaultIcon: Icons.account_circle,
|
defaultIcon: Icons.account_circle,
|
||||||
loading: profile == null,
|
loading: profile == null,
|
||||||
onEdit: () => setAvatarAction(context),
|
onEdit: kIsWeb ? null : () => setAvatarAction(context),
|
||||||
),
|
),
|
||||||
ListTile(
|
ListTile(
|
||||||
leading: Icon(Icons.edit),
|
leading: Icon(Icons.edit),
|
||||||
|
|
|
@ -110,8 +110,8 @@ packages:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
path: "."
|
path: "."
|
||||||
ref: "2545995bbe96a1d96fe176ab666f4dd03d591aa6"
|
ref: bc2ca9749cfcc0506c59f97f4ae4987f0e84fbf4
|
||||||
resolved-ref: "2545995bbe96a1d96fe176ab666f4dd03d591aa6"
|
resolved-ref: bc2ca9749cfcc0506c59f97f4ae4987f0e84fbf4
|
||||||
url: "https://gitlab.com/famedly/famedlysdk.git"
|
url: "https://gitlab.com/famedly/famedlysdk.git"
|
||||||
source: git
|
source: git
|
||||||
version: "0.0.1"
|
version: "0.0.1"
|
||||||
|
|
|
@ -27,7 +27,7 @@ dependencies:
|
||||||
famedlysdk:
|
famedlysdk:
|
||||||
git:
|
git:
|
||||||
url: https://gitlab.com/famedly/famedlysdk.git
|
url: https://gitlab.com/famedly/famedlysdk.git
|
||||||
ref: 2545995bbe96a1d96fe176ab666f4dd03d591aa6
|
ref: bc2ca9749cfcc0506c59f97f4ae4987f0e84fbf4
|
||||||
|
|
||||||
localstorage: ^3.0.1+4
|
localstorage: ^3.0.1+4
|
||||||
bubble: ^1.1.9+1
|
bubble: ^1.1.9+1
|
||||||
|
|
Loading…
Reference in a new issue