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