Add failed attempt to fix all room names
This commit is contained in:
parent
6ca8f646b2
commit
1aa73bbd7e
|
@ -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
|
||||||
|
|
Loading…
Reference in New Issue
Block a user