🐛 Fix logout will break something

This commit is contained in:
LittleSheep 2024-12-11 22:49:55 +08:00
parent f47f1b175a
commit 623095473e

View File

@ -3,6 +3,7 @@ import 'package:flutter/material.dart';
import 'package:gap/gap.dart'; import 'package:gap/gap.dart';
import 'package:go_router/go_router.dart'; import 'package:go_router/go_router.dart';
import 'package:hive/hive.dart'; import 'package:hive/hive.dart';
import 'package:hive_flutter/hive_flutter.dart';
import 'package:material_symbols_icons/symbols.dart'; import 'package:material_symbols_icons/symbols.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
import 'package:styled_widget/styled_widget.dart'; import 'package:styled_widget/styled_widget.dart';
@ -118,19 +119,19 @@ class _AuthorizedAccountScreen extends StatelessWidget {
contentPadding: const EdgeInsets.symmetric(horizontal: 24), contentPadding: const EdgeInsets.symmetric(horizontal: 24),
leading: const Icon(Symbols.logout), leading: const Icon(Symbols.logout),
trailing: const Icon(Symbols.chevron_right), trailing: const Icon(Symbols.chevron_right),
onTap: () { onTap: () async {
context final confirm = await context.showConfirmDialog(
.showConfirmDialog(
'accountLogoutConfirmTitle'.tr(), 'accountLogoutConfirmTitle'.tr(),
'accountLogoutConfirm'.tr(), 'accountLogoutConfirm'.tr(),
) );
.then((value) {
if(!context.mounted) return; if (!confirm) return;
if (value) ua.logoutUser(); if (!context.mounted) return;
final ws = context.read<WebSocketProvider>(); ua.logoutUser();
ws.disconnect(); final ws = context.read<WebSocketProvider>();
Hive.deleteFromDisk(); ws.disconnect();
}); await Hive.deleteFromDisk();
await Hive.initFlutter();
}, },
), ),
ListTile( ListTile(