mirror of
https://github.com/twonlyapp/twonly-app.git
synced 2026-01-15 11:18:41 +00:00
some more missing non updating states
This commit is contained in:
parent
bfb0b64093
commit
2e20859a69
6 changed files with 67 additions and 46 deletions
|
|
@ -111,6 +111,9 @@ class _DrawLayerState extends State<DrawLayer> {
|
|||
tooltipText: context.lang.imageEditorDrawOk,
|
||||
onPressed: () async {
|
||||
widget.layerData.isEditing = false;
|
||||
if (widget.onUpdate != null) {
|
||||
widget.onUpdate!();
|
||||
}
|
||||
setState(() {});
|
||||
},
|
||||
),
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@
|
|||
"contactVerifyNumberMarkAsVerified": "Als verifiziert markieren",
|
||||
"contactVerifyNumberClearVerification": "Verifizierung aufheben",
|
||||
"contactVerifyNumberLongDesc": "Um die Ende-zu-Ende-Verschlüsselung mit {username} zu verifizieren, vergleiche die Zahlen mit ihrem Gerät. Die Person kann auch deinen Code mit ihrem Gerät scannen.",
|
||||
"contactNickame": "Spitzname",
|
||||
"contactNickname": "Spitzname",
|
||||
"contactBlock": "Blockieren",
|
||||
"contactBlockTitle": "Blockiere {username}",
|
||||
"contactBlockBody": "Ein blockierter Benutzer kann dir keine Nachrichten mehr senden, und sein Profil ist nicht mehr sichtbar. Um die Blockierung eines Benutzers aufzuheben, navigiere einfach zu Einstellungen > Datenschutz > Blockierte Benutzer.",
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@
|
|||
"contactVerifyNumberMarkAsVerified": "Mark as verified",
|
||||
"contactVerifyNumberClearVerification": "Clear verification",
|
||||
"contactVerifyNumberLongDesc": "To verify the end-to-end encryption with {username}, compare the numbers with their device. The person can also scan your code with their device.",
|
||||
"contactNickame": "Nickname",
|
||||
"contactNickname": "Nickname",
|
||||
"contactBlock": "Block",
|
||||
"contactBlockTitle": "Block {username}",
|
||||
"contactBlockBody": "A blocked user will no longer be able to send you messages and their profile will be hidden from view. To unblock a user, simply navigate to Settings > Privacy > Blocked Users.",
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ import 'package:twonly/src/model/contacts_model.dart';
|
|||
import 'package:twonly/src/model/json/message.dart';
|
||||
import 'package:twonly/src/model/messages_model.dart';
|
||||
import 'package:twonly/src/providers/api/api.dart';
|
||||
import 'package:twonly/src/providers/contacts_change_provider.dart';
|
||||
import 'package:twonly/src/providers/download_change_provider.dart';
|
||||
import 'package:twonly/src/providers/messages_change_provider.dart';
|
||||
import 'package:twonly/src/services/notification_service.dart';
|
||||
|
|
@ -131,25 +132,29 @@ class _ChatItemDetailsViewState extends State<ChatItemDetailsView> {
|
|||
int lastChangeCounter = 0;
|
||||
final TextEditingController newMessageController = TextEditingController();
|
||||
HashSet<int> alreadyReportedOpened = HashSet<int>();
|
||||
int sendTextMessages = 0;
|
||||
late Contact user;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
user = widget.user;
|
||||
_loadAsync(updateOpenStatus: true);
|
||||
}
|
||||
|
||||
Future _loadAsync({bool updateOpenStatus = false}) async {
|
||||
// if (_messages.isEmpty || updateOpenStatus) {
|
||||
_messages =
|
||||
await DbMessages.getAllMessagesForUser(widget.user.userId.toInt());
|
||||
// } else {
|
||||
if (sendTextMessages <= 0) {
|
||||
_messages = await DbMessages.getAllMessagesForUser(user.userId.toInt());
|
||||
} else {
|
||||
sendTextMessages--;
|
||||
// will not update older message states like when they now downloaded...
|
||||
// int lastMessageId = _messages.first.messageId;
|
||||
// List<DbMessage> toAppend =
|
||||
// await DbMessages.getAllMessagesForUserWithHigherMessageId(
|
||||
// widget.user.userId.toInt(), lastMessageId);
|
||||
// _messages.insertAll(0, toAppend);
|
||||
// }
|
||||
int lastMessageId = _messages.first.messageId;
|
||||
List<DbMessage> toAppend =
|
||||
await DbMessages.getAllMessagesForUserWithHigherMessageId(
|
||||
user.userId.toInt(), lastMessageId);
|
||||
_messages.insertAll(0, toAppend);
|
||||
}
|
||||
|
||||
if (updateOpenStatus) {
|
||||
_messages.where((x) => x.messageOpenedAt == null).forEach((message) {
|
||||
|
|
@ -175,20 +180,25 @@ class _ChatItemDetailsViewState extends State<ChatItemDetailsView> {
|
|||
}
|
||||
|
||||
Future _sendMessage() async {
|
||||
sendTextMessages++;
|
||||
String text = newMessageController.text;
|
||||
if (text == "") return;
|
||||
await sendTextMessage(widget.user.userId, newMessageController.text);
|
||||
await sendTextMessage(user.userId, newMessageController.text);
|
||||
newMessageController.clear();
|
||||
setState(() {});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
user = context
|
||||
.watch<ContactChangeProvider>()
|
||||
.allContacts
|
||||
.firstWhere((c) => c.userId == widget.user.userId);
|
||||
final changeCounter = context.watch<MessagesChangeProvider>().changeCounter;
|
||||
if (changeCounter.containsKey(widget.user.userId.toInt())) {
|
||||
if (changeCounter[widget.user.userId.toInt()] != lastChangeCounter) {
|
||||
if (changeCounter.containsKey(user.userId.toInt())) {
|
||||
if (changeCounter[user.userId.toInt()] != lastChangeCounter) {
|
||||
_loadAsync(updateOpenStatus: true);
|
||||
lastChangeCounter = changeCounter[widget.user.userId.toInt()]!;
|
||||
lastChangeCounter = changeCounter[user.userId.toInt()]!;
|
||||
setState(() {});
|
||||
}
|
||||
}
|
||||
|
|
@ -197,13 +207,13 @@ class _ChatItemDetailsViewState extends State<ChatItemDetailsView> {
|
|||
title: GestureDetector(
|
||||
onTap: () {
|
||||
Navigator.push(context, MaterialPageRoute(builder: (context) {
|
||||
return ContactView(widget.user);
|
||||
return ContactView(user.userId.toInt());
|
||||
}));
|
||||
},
|
||||
child: Row(
|
||||
children: [
|
||||
InitialsAvatar(
|
||||
displayName: widget.user.displayName,
|
||||
displayName: user.displayName,
|
||||
fontSize: 19,
|
||||
),
|
||||
SizedBox(width: 10),
|
||||
|
|
@ -212,9 +222,9 @@ class _ChatItemDetailsViewState extends State<ChatItemDetailsView> {
|
|||
color: Colors.transparent,
|
||||
child: Row(
|
||||
children: [
|
||||
Text(widget.user.displayName),
|
||||
Text(user.displayName),
|
||||
SizedBox(width: 10),
|
||||
VerifiedShield(widget.user),
|
||||
VerifiedShield(user),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
|
@ -248,7 +258,7 @@ class _ChatItemDetailsViewState extends State<ChatItemDetailsView> {
|
|||
}
|
||||
return ChatListEntry(
|
||||
_messages[i],
|
||||
widget.user,
|
||||
user,
|
||||
lastMessageFromSameUser,
|
||||
);
|
||||
},
|
||||
|
|
|
|||
|
|
@ -1,10 +1,12 @@
|
|||
import 'dart:convert';
|
||||
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
||||
import 'package:libsignal_protocol_dart/libsignal_protocol_dart.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:qr_flutter/qr_flutter.dart';
|
||||
import 'package:twonly/src/components/format_long_string.dart';
|
||||
import 'package:twonly/src/model/contacts_model.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:twonly/src/providers/contacts_change_provider.dart';
|
||||
import 'package:twonly/src/utils/misc.dart';
|
||||
import 'package:twonly/src/utils/signal.dart';
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
|
|
@ -34,6 +36,11 @@ class _ContactVerifyViewState extends State<ContactVerifyView> {
|
|||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
Contact contact = context
|
||||
.watch<ContactChangeProvider>()
|
||||
.allContacts
|
||||
.firstWhere((c) => c.userId == widget.contact.userId);
|
||||
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text(context.lang.contactVerifyNumberTitle),
|
||||
|
|
@ -88,8 +95,8 @@ class _ContactVerifyViewState extends State<ContactVerifyView> {
|
|||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 30),
|
||||
child: Text(
|
||||
context.lang.contactVerifyNumberLongDesc(
|
||||
widget.contact.displayName),
|
||||
context.lang
|
||||
.contactVerifyNumberLongDesc(contact.displayName),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
),
|
||||
|
|
@ -118,11 +125,11 @@ class _ContactVerifyViewState extends State<ContactVerifyView> {
|
|||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
widget.contact.verified
|
||||
contact.verified
|
||||
? OutlinedButton.icon(
|
||||
onPressed: () {
|
||||
DbContacts.updateVerificationStatus(
|
||||
widget.contact.userId.toInt(), false);
|
||||
contact.userId.toInt(), false);
|
||||
},
|
||||
label: Text(
|
||||
context.lang.contactVerifyNumberClearVerification),
|
||||
|
|
@ -131,7 +138,7 @@ class _ContactVerifyViewState extends State<ContactVerifyView> {
|
|||
icon: FaIcon(FontAwesomeIcons.shieldHeart),
|
||||
onPressed: () {
|
||||
DbContacts.updateVerificationStatus(
|
||||
widget.contact.userId.toInt(), true);
|
||||
contact.userId.toInt(), true);
|
||||
},
|
||||
label:
|
||||
Text(context.lang.contactVerifyNumberMarkAsVerified),
|
||||
|
|
|
|||
|
|
@ -7,30 +7,31 @@ import 'package:twonly/src/components/initialsavatar.dart';
|
|||
import 'package:twonly/src/components/verified_shield.dart';
|
||||
import 'package:twonly/src/model/contacts_model.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:twonly/src/providers/contacts_change_provider.dart';
|
||||
import 'package:twonly/src/providers/messages_change_provider.dart';
|
||||
import 'package:twonly/src/utils/misc.dart';
|
||||
import 'package:twonly/src/views/contact/contact_verify_view.dart';
|
||||
|
||||
class ContactView extends StatefulWidget {
|
||||
const ContactView(this.contact, {super.key});
|
||||
const ContactView(this.userId, {super.key});
|
||||
|
||||
final Contact contact;
|
||||
final int userId;
|
||||
|
||||
@override
|
||||
State<ContactView> createState() => _ContactViewState();
|
||||
}
|
||||
|
||||
class _ContactViewState extends State<ContactView> {
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
Contact contact = context
|
||||
.watch<ContactChangeProvider>()
|
||||
.allContacts
|
||||
.firstWhere((c) => c.userId == widget.userId);
|
||||
|
||||
int flameCounter = context
|
||||
.watch<MessagesChangeProvider>()
|
||||
.flamesCounter[widget.contact.userId.toInt()] ??
|
||||
.flamesCounter[contact.userId.toInt()] ??
|
||||
0;
|
||||
|
||||
return Scaffold(
|
||||
|
|
@ -42,7 +43,7 @@ class _ContactViewState extends State<ContactView> {
|
|||
Padding(
|
||||
padding: const EdgeInsets.all(10),
|
||||
child: InitialsAvatar(
|
||||
displayName: widget.contact.displayName,
|
||||
displayName: contact.displayName,
|
||||
fontSize: 30,
|
||||
),
|
||||
),
|
||||
|
|
@ -51,14 +52,14 @@ class _ContactViewState extends State<ContactView> {
|
|||
children: [
|
||||
Padding(
|
||||
padding: EdgeInsets.only(right: 10),
|
||||
child: VerifiedShield(widget.contact)),
|
||||
child: VerifiedShield(contact)),
|
||||
Text(
|
||||
widget.contact.displayName,
|
||||
contact.displayName,
|
||||
style: TextStyle(fontSize: 20),
|
||||
),
|
||||
if (flameCounter > 0)
|
||||
FlameCounterWidget(
|
||||
widget.contact,
|
||||
contact,
|
||||
flameCounter,
|
||||
110000000,
|
||||
prefix: true,
|
||||
|
|
@ -68,13 +69,13 @@ class _ContactViewState extends State<ContactView> {
|
|||
SizedBox(height: 50),
|
||||
BetterListTile(
|
||||
icon: FontAwesomeIcons.pencil,
|
||||
text: context.lang.contactNickame,
|
||||
text: context.lang.contactNickname,
|
||||
onTap: () async {
|
||||
String? newUsername =
|
||||
await showNicknameChangeDialog(context, widget.contact);
|
||||
await showNicknameChangeDialog(context, contact);
|
||||
if (newUsername != null && newUsername != "") {
|
||||
await DbContacts.changeDisplayName(
|
||||
widget.contact.userId.toInt(), newUsername);
|
||||
contact.userId.toInt(), newUsername);
|
||||
}
|
||||
},
|
||||
),
|
||||
|
|
@ -85,7 +86,7 @@ class _ContactViewState extends State<ContactView> {
|
|||
onTap: () {
|
||||
Navigator.push(context, MaterialPageRoute(
|
||||
builder: (context) {
|
||||
return ContactVerifyView(widget.contact);
|
||||
return ContactVerifyView(contact);
|
||||
},
|
||||
));
|
||||
},
|
||||
|
|
@ -97,11 +98,11 @@ class _ContactViewState extends State<ContactView> {
|
|||
onTap: () async {
|
||||
bool block = await showAlertDialog(
|
||||
context,
|
||||
context.lang.contactBlockTitle(widget.contact.displayName),
|
||||
context.lang.contactBlockTitle(contact.displayName),
|
||||
context.lang.contactBlockBody,
|
||||
);
|
||||
if (block) {
|
||||
await DbContacts.blockUser(widget.contact.userId.toInt());
|
||||
await DbContacts.blockUser(contact.userId.toInt());
|
||||
// go back to the first
|
||||
if (context.mounted) {
|
||||
Navigator.popUntil(context, (route) => route.isFirst);
|
||||
|
|
@ -140,8 +141,8 @@ Future<String?> showNicknameChangeDialog(
|
|||
TextButton(
|
||||
child: Text('Submit'),
|
||||
onPressed: () {
|
||||
String inputText = controller.text;
|
||||
Navigator.of(context).pop(inputText); // Return the input text
|
||||
Navigator.of(context)
|
||||
.pop(controller.text); // Return the input text
|
||||
},
|
||||
),
|
||||
],
|
||||
|
|
|
|||
Loading…
Reference in a new issue