mirror of
https://gitlab.com/famedly/fluffychat.git
synced 2024-12-18 10:52:34 +01:00
Minor fixes
This commit is contained in:
parent
61c0b986f8
commit
02675911db
@ -435,6 +435,8 @@ class L10n extends MatrixLocalizations {
|
|||||||
|
|
||||||
String get loadingPleaseWait => Intl.message("Loading... Please wait");
|
String get loadingPleaseWait => Intl.message("Loading... Please wait");
|
||||||
|
|
||||||
|
String get loadMore => Intl.message('Load more...');
|
||||||
|
|
||||||
String loadCountMoreParticipants(String count) => Intl.message(
|
String loadCountMoreParticipants(String count) => Intl.message(
|
||||||
"Load $count more participants",
|
"Load $count more participants",
|
||||||
name: "loadCountMoreParticipants",
|
name: "loadCountMoreParticipants",
|
||||||
|
@ -2,9 +2,9 @@ import 'package:famedlysdk/famedlysdk.dart';
|
|||||||
|
|
||||||
extension ClientPresenceExtension on Client {
|
extension ClientPresenceExtension on Client {
|
||||||
List<Presence> get statusList {
|
List<Presence> get statusList {
|
||||||
final statusList = presences.values.toList();
|
final statusList = presences.values.toList().reversed.toList();
|
||||||
statusList.removeWhere((p) => p.statusMsg?.isEmpty ?? true);
|
statusList.removeWhere((p) => p.statusMsg?.isEmpty ?? true);
|
||||||
statusList.sort((a, b) => b.time.compareTo(a.time));
|
statusList.reversed.toList();
|
||||||
return statusList;
|
return statusList;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -496,6 +496,10 @@ class ExtendedStore extends Store implements ExtendedStoreAPI {
|
|||||||
|
|
||||||
Future<void> forgetRoom(String roomID) async {
|
Future<void> forgetRoom(String roomID) async {
|
||||||
await _db.rawDelete("DELETE FROM Rooms WHERE room_id=?", [roomID]);
|
await _db.rawDelete("DELETE FROM Rooms WHERE room_id=?", [roomID]);
|
||||||
|
await _db.rawDelete("DELETE FROM Events WHERE room_id=?", [roomID]);
|
||||||
|
await _db.rawDelete("DELETE FROM RoomStates WHERE room_id=?", [roomID]);
|
||||||
|
await _db
|
||||||
|
.rawDelete("DELETE FROM RoomAccountData WHERE room_id=?", [roomID]);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -528,7 +532,7 @@ class ExtendedStore extends Store implements ExtendedStoreAPI {
|
|||||||
"sender": rawPresences[i]["sender"],
|
"sender": rawPresences[i]["sender"],
|
||||||
"content": json.decode(rawPresences[i]["content"]),
|
"content": json.decode(rawPresences[i]["content"]),
|
||||||
};
|
};
|
||||||
newPresences[rawPresences[i]["type"]] = Presence.fromJson(rawPresence);
|
newPresences[rawPresences[i]["sender"]] = Presence.fromJson(rawPresence);
|
||||||
}
|
}
|
||||||
return newPresences;
|
return newPresences;
|
||||||
}
|
}
|
||||||
|
@ -79,8 +79,10 @@ class _ChatState extends State<_Chat> {
|
|||||||
|
|
||||||
String inputText = "";
|
String inputText = "";
|
||||||
|
|
||||||
|
bool get _canLoadMore => timeline.events.last.type != EventTypes.RoomCreate;
|
||||||
|
|
||||||
void requestHistory() async {
|
void requestHistory() async {
|
||||||
if (timeline.events.last.type != EventTypes.RoomCreate) {
|
if (_canLoadMore) {
|
||||||
setState(() => this._loadingHistory = true);
|
setState(() => this._loadingHistory = true);
|
||||||
await timeline.requestHistory(historyCount: _loadHistoryCount);
|
await timeline.requestHistory(historyCount: _loadHistoryCount);
|
||||||
if (mounted) setState(() => this._loadingHistory = false);
|
if (mounted) setState(() => this._loadingHistory = false);
|
||||||
@ -450,16 +452,33 @@ class _ChatState extends State<_Chat> {
|
|||||||
|
|
||||||
return ListView.builder(
|
return ListView.builder(
|
||||||
reverse: true,
|
reverse: true,
|
||||||
itemCount: timeline.events.length + 1,
|
itemCount: timeline.events.length + 2,
|
||||||
controller: _scrollController,
|
controller: _scrollController,
|
||||||
itemBuilder: (BuildContext context, int i) {
|
itemBuilder: (BuildContext context, int i) {
|
||||||
return i == 0
|
return i == timeline.events.length + 1
|
||||||
|
? _canLoadMore
|
||||||
|
? FlatButton(
|
||||||
|
child: Text(
|
||||||
|
L10n.of(context).loadMore,
|
||||||
|
style: TextStyle(
|
||||||
|
color:
|
||||||
|
Theme.of(context).primaryColor,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
decoration:
|
||||||
|
TextDecoration.underline,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
onPressed: requestHistory,
|
||||||
|
)
|
||||||
|
: Container()
|
||||||
|
: i == 0
|
||||||
? AnimatedContainer(
|
? AnimatedContainer(
|
||||||
height: seenByText.isEmpty ? 0 : 24,
|
height: seenByText.isEmpty ? 0 : 24,
|
||||||
duration: seenByText.isEmpty
|
duration: seenByText.isEmpty
|
||||||
? Duration(milliseconds: 0)
|
? Duration(milliseconds: 0)
|
||||||
: Duration(milliseconds: 500),
|
: Duration(milliseconds: 500),
|
||||||
alignment: timeline.events.first.senderId ==
|
alignment:
|
||||||
|
timeline.events.first.senderId ==
|
||||||
client.userID
|
client.userID
|
||||||
? Alignment.topRight
|
? Alignment.topRight
|
||||||
: Alignment.topLeft,
|
: Alignment.topLeft,
|
||||||
@ -468,7 +487,8 @@ class _ChatState extends State<_Chat> {
|
|||||||
maxLines: 1,
|
maxLines: 1,
|
||||||
overflow: TextOverflow.ellipsis,
|
overflow: TextOverflow.ellipsis,
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: Theme.of(context).primaryColor,
|
color:
|
||||||
|
Theme.of(context).primaryColor,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
padding: EdgeInsets.only(
|
padding: EdgeInsets.only(
|
||||||
@ -479,12 +499,14 @@ class _ChatState extends State<_Chat> {
|
|||||||
)
|
)
|
||||||
: Message(timeline.events[i - 1],
|
: Message(timeline.events[i - 1],
|
||||||
onAvatarTab: (Event event) {
|
onAvatarTab: (Event event) {
|
||||||
sendController.text += ' ${event.senderId}';
|
sendController.text +=
|
||||||
|
' ${event.senderId}';
|
||||||
}, onSelect: (Event event) {
|
}, onSelect: (Event event) {
|
||||||
if (!event.redacted) {
|
if (!event.redacted) {
|
||||||
if (selectedEvents.contains(event)) {
|
if (selectedEvents.contains(event)) {
|
||||||
setState(
|
setState(
|
||||||
() => selectedEvents.remove(event),
|
() =>
|
||||||
|
selectedEvents.remove(event),
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
setState(
|
setState(
|
||||||
@ -500,8 +522,9 @@ class _ChatState extends State<_Chat> {
|
|||||||
selected: selectedEvents
|
selected: selectedEvents
|
||||||
.contains(timeline.events[i - 1]),
|
.contains(timeline.events[i - 1]),
|
||||||
timeline: timeline,
|
timeline: timeline,
|
||||||
nextEvent:
|
nextEvent: i >= 2
|
||||||
i >= 2 ? timeline.events[i - 2] : null);
|
? timeline.events[i - 2]
|
||||||
|
: null);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
@ -58,6 +58,8 @@ class _ChatListState extends State<ChatList> {
|
|||||||
bool loadingPublicRooms = false;
|
bool loadingPublicRooms = false;
|
||||||
String searchServer;
|
String searchServer;
|
||||||
|
|
||||||
|
final ScrollController _scrollController = ScrollController();
|
||||||
|
|
||||||
Future<void> waitForFirstSync(BuildContext context) async {
|
Future<void> waitForFirstSync(BuildContext context) async {
|
||||||
Client client = Matrix.of(context).client;
|
Client client = Matrix.of(context).client;
|
||||||
if (client.prevBatch?.isEmpty ?? true) {
|
if (client.prevBatch?.isEmpty ?? true) {
|
||||||
@ -66,8 +68,17 @@ class _ChatListState extends State<ChatList> {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool _scrolledToTop = true;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
|
_scrollController.addListener(() async {
|
||||||
|
if (_scrollController.position.pixels > 0 && _scrolledToTop) {
|
||||||
|
setState(() => _scrolledToTop = false);
|
||||||
|
} else if (_scrollController.position.pixels == 0 && !_scrolledToTop) {
|
||||||
|
setState(() => _scrolledToTop = true);
|
||||||
|
}
|
||||||
|
});
|
||||||
searchController.addListener(() {
|
searchController.addListener(() {
|
||||||
coolDown?.cancel();
|
coolDown?.cancel();
|
||||||
if (searchController.text.isEmpty) {
|
if (searchController.text.isEmpty) {
|
||||||
@ -272,6 +283,7 @@ class _ChatListState extends State<ChatList> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
|
elevation: _scrolledToTop ? 0 : null,
|
||||||
leading: selectMode != SelectMode.share
|
leading: selectMode != SelectMode.share
|
||||||
? null
|
? null
|
||||||
: IconButton(
|
: IconButton(
|
||||||
@ -381,6 +393,7 @@ class _ChatListState extends State<ChatList> {
|
|||||||
(publicRoomsResponse?.publicRooms?.length ?? 0);
|
(publicRoomsResponse?.publicRooms?.length ?? 0);
|
||||||
final int totalCount = rooms.length + publicRoomsCount;
|
final int totalCount = rooms.length + publicRoomsCount;
|
||||||
return ListView.separated(
|
return ListView.separated(
|
||||||
|
controller: _scrollController,
|
||||||
separatorBuilder: (BuildContext context, int i) =>
|
separatorBuilder: (BuildContext context, int i) =>
|
||||||
i == totalCount - publicRoomsCount
|
i == totalCount - publicRoomsCount
|
||||||
? Material(
|
? Material(
|
||||||
|
23
pubspec.lock
23
pubspec.lock
@ -64,6 +64,13 @@ packages:
|
|||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.1.3"
|
version: "1.1.3"
|
||||||
|
clock:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: clock
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "1.0.1"
|
||||||
collection:
|
collection:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -113,6 +120,13 @@ packages:
|
|||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.3.3"
|
version: "1.3.3"
|
||||||
|
fake_async:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: fake_async
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "1.1.0"
|
||||||
famedlysdk:
|
famedlysdk:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
@ -432,7 +446,7 @@ packages:
|
|||||||
name: path
|
name: path
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.6.4"
|
version: "1.7.0"
|
||||||
path_drawing:
|
path_drawing:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -510,13 +524,6 @@ packages:
|
|||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.4.2"
|
version: "1.4.2"
|
||||||
quiver:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: quiver
|
|
||||||
url: "https://pub.dartlang.org"
|
|
||||||
source: hosted
|
|
||||||
version: "2.1.3"
|
|
||||||
receive_sharing_intent:
|
receive_sharing_intent:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
|
Loading…
Reference in New Issue
Block a user