Compare commits
No commits in common. "128a1bf35fdc5ca1d2d2eb6eff57cb681bdcf608" and "1aa73bbd7e03e660d2a5c9a203513dc0edaa9593" have entirely different histories.
128a1bf35f
...
1aa73bbd7e
|
@ -25,10 +25,11 @@ class _LoginPageState extends State<LoginPage> {
|
|||
});
|
||||
|
||||
final provider = Provider.of<ZenithClientProvider>(context, listen: false);
|
||||
final client = Client("zenith");
|
||||
|
||||
try {
|
||||
await provider.client.checkHomeserver(Uri.parse(serverController.text));
|
||||
await provider.client.login(
|
||||
await client.checkHomeserver(Uri.parse(serverController.text));
|
||||
await client.login(
|
||||
LoginType.mLoginPassword,
|
||||
password: passwordController.text,
|
||||
identifier: AuthenticationUserIdentifier(user: usernameController.text),
|
||||
|
@ -53,6 +54,7 @@ class _LoginPageState extends State<LoginPage> {
|
|||
});
|
||||
}
|
||||
|
||||
provider.setClient(client);
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
prefs.setString("homeserver", serverController.text);
|
||||
prefs.setString("username", usernameController.text);
|
||||
|
|
|
@ -50,14 +50,16 @@ class _MyHomePageState extends State<MyHomePage> {
|
|||
|
||||
if (!mounted) return;
|
||||
final provider = Provider.of<ZenithClientProvider>(context, listen: false);
|
||||
final client = Client("zenith");
|
||||
provider.setClient(client);
|
||||
setState(() {
|
||||
showRooms = true;
|
||||
});
|
||||
|
||||
try {
|
||||
await provider.client.checkHomeserver(Uri.parse(homeserver));
|
||||
if (!provider.client.isLogged())
|
||||
await provider.client.login(LoginType.mLoginPassword,
|
||||
await client.checkHomeserver(Uri.parse(homeserver));
|
||||
if (!client.isLogged())
|
||||
await client.login(LoginType.mLoginPassword,
|
||||
password: password,
|
||||
identifier: AuthenticationUserIdentifier(user: username));
|
||||
} catch (error) {
|
||||
|
|
|
@ -28,6 +28,22 @@ class _RoomsPageState extends State<RoomsPage> {
|
|||
context, MaterialPageRoute(builder: (context) => RoomPage(room: room)));
|
||||
}
|
||||
|
||||
void fixNames(Client client) async {
|
||||
final rooms = client.rooms
|
||||
.where((element) =>
|
||||
element.getLocalizedDisplayname().contains("Group with"))
|
||||
.toList();
|
||||
for (final room in rooms) {
|
||||
print("Setting power level to 100...");
|
||||
final result = await room.setPower(client.userID!, 100);
|
||||
print("Result=$result");
|
||||
print("Fixing ${room.getLocalizedDisplayname()}...");
|
||||
await room.setName(
|
||||
room.getLocalizedDisplayname().replaceAll(RegExp("Group with"), ""));
|
||||
}
|
||||
print("Fixed all.");
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
|
@ -81,12 +97,21 @@ class _RoomsPageState extends State<RoomsPage> {
|
|||
padding: const EdgeInsets.all(8.0),
|
||||
child: Center(child: Consumer<ZenithClientProvider>(
|
||||
builder: (context, provider, child) {
|
||||
print(provider.client.rooms
|
||||
.where((element) =>
|
||||
element.getLocalizedDisplayname().contains("Group with"))
|
||||
.length);
|
||||
|
||||
provider.client.onRoomState.stream.listen((event) {
|
||||
setState(() {
|
||||
loadingRooms = false;
|
||||
});
|
||||
});
|
||||
|
||||
return ElevatedButton(
|
||||
onPressed: () => fixNames(provider.client),
|
||||
child: const Text("Fix names"));
|
||||
|
||||
if (provider.client.rooms.isEmpty)
|
||||
return const CircularProgressIndicator();
|
||||
else
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:matrix/matrix.dart';
|
||||
import 'package:path_provider/path_provider.dart';
|
||||
|
||||
class ZenithClientProvider extends ChangeNotifier {
|
||||
final client = Client("zenith", databaseBuilder: (_) async {
|
||||
final dir =
|
||||
await getApplicationSupportDirectory(); // Recommend path_provider package
|
||||
final db = HiveCollectionsDatabase('matrix_example_chat', dir.path);
|
||||
await db.open();
|
||||
return db;
|
||||
});
|
||||
late Client _client;
|
||||
|
||||
Client get client => _client;
|
||||
|
||||
void setClient(Client value) {
|
||||
_client = value;
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,10 +5,8 @@
|
|||
import FlutterMacOS
|
||||
import Foundation
|
||||
|
||||
import path_provider_foundation
|
||||
import shared_preferences_foundation
|
||||
|
||||
func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
|
||||
PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin"))
|
||||
SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin"))
|
||||
}
|
||||
|
|
26
pubspec.lock
26
pubspec.lock
|
@ -344,30 +344,6 @@ packages:
|
|||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.8.3"
|
||||
path_provider:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: path_provider
|
||||
sha256: a1aa8aaa2542a6bc57e381f132af822420216c80d4781f7aa085ca3229208aaa
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.1.1"
|
||||
path_provider_android:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: path_provider_android
|
||||
sha256: "477184d672607c0a3bf68fbbf601805f92ef79c82b64b4d6eb318cbca4c48668"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.2.2"
|
||||
path_provider_foundation:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: path_provider_foundation
|
||||
sha256: "19314d595120f82aca0ba62787d58dde2cc6b5df7d2f0daf72489e38d1b57f2d"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.3.1"
|
||||
path_provider_linux:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -647,4 +623,4 @@ packages:
|
|||
version: "6.3.0"
|
||||
sdks:
|
||||
dart: ">=3.1.5 <4.0.0"
|
||||
flutter: ">=3.10.0"
|
||||
flutter: ">=3.7.0"
|
||||
|
|
|
@ -41,7 +41,6 @@ dependencies:
|
|||
provider: ^6.1.1
|
||||
shared_preferences: ^2.2.2
|
||||
file_picker: ^6.1.1
|
||||
path_provider: ^2.1.1
|
||||
|
||||
dev_dependencies:
|
||||
flutter_test:
|
||||
|
|
Loading…
Reference in New Issue
Block a user