mirror of
https://gitlab.com/famedly/fluffychat.git
synced 2025-04-10 18:27:57 +02:00
fix: onboarding UX
- add option to enable locale based homeservers Signed-off-by: TheOneWithTheBraid <the-one@with-the-braid.cf>
This commit is contained in:
parent
6e0610dfdc
commit
c0d918cbe9
@ -6,5 +6,6 @@
|
||||
"privacy_url": "https://fluffychat.im/en/privacy.html",
|
||||
"render_html": false,
|
||||
"hide_redacted_events": false,
|
||||
"hide_unknown_events": false
|
||||
"hide_unknown_events": false,
|
||||
"use_location_based_homeserver": true
|
||||
}
|
@ -60,6 +60,7 @@ abstract class AppConfig {
|
||||
'https://github.com/googlefonts/noto-emoji/';
|
||||
static const double borderRadius = 16.0;
|
||||
static const double columnWidth = 360.0;
|
||||
static bool useLocaleBasedHomeserver = true;
|
||||
|
||||
static void loadFromJson(Map<String, dynamic> json) {
|
||||
if (json['chat_color'] != null) {
|
||||
@ -95,5 +96,8 @@ abstract class AppConfig {
|
||||
if (json['hide_unknown_events'] is bool) {
|
||||
hideUnknownEvents = json['hide_unknown_events'];
|
||||
}
|
||||
if (json['use_location_based_homeserver'] is bool) {
|
||||
useLocaleBasedHomeserver = json['use_location_based_homeserver'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
import 'dart:async';
|
||||
import 'dart:ui';
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
@ -90,7 +91,8 @@ class HomeserverPickerController extends State<HomeserverPicker> {
|
||||
|
||||
void _loadHomeserverList() async {
|
||||
try {
|
||||
final homeserverList = await JoinmatrixOrgParser().fetchHomeservers();
|
||||
final homeserverList =
|
||||
await const JoinmatrixOrgParser().fetchHomeservers();
|
||||
final benchmark = await HomeserverListProvider.benchmarkHomeserver(
|
||||
homeserverList,
|
||||
timeout: const Duration(seconds: 10),
|
||||
@ -159,6 +161,14 @@ class HomeserverPickerController extends State<HomeserverPicker> {
|
||||
}
|
||||
}
|
||||
|
||||
void _defaultHomeserverByLocale() {
|
||||
final servers =
|
||||
LocalHomeserverParser(window.locale.countryCode).fetchHomeservers();
|
||||
if (servers.isNotEmpty) {
|
||||
setState(() => homeserverController.text = servers.first.baseUrl.host);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
homeserverFocusNode.removeListener(_updateFocus);
|
||||
@ -169,6 +179,10 @@ class HomeserverPickerController extends State<HomeserverPicker> {
|
||||
void initState() {
|
||||
homeserverFocusNode.addListener(_updateFocus);
|
||||
_checkTorBrowser();
|
||||
if (AppConfig.useLocaleBasedHomeserver) {
|
||||
WidgetsBinding.instance
|
||||
.addPostFrameCallback((timeStamp) => _defaultHomeserverByLocale());
|
||||
}
|
||||
super.initState();
|
||||
}
|
||||
|
||||
|
@ -1047,7 +1047,7 @@ packages:
|
||||
name: matrix_homeserver_recommendations
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.2.1"
|
||||
version: "0.3.0"
|
||||
matrix_link_text:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
|
@ -61,7 +61,7 @@ dependencies:
|
||||
localstorage: ^4.0.0+1
|
||||
lottie: ^1.2.2
|
||||
matrix: ^0.10.3
|
||||
matrix_homeserver_recommendations: ^0.2.1
|
||||
matrix_homeserver_recommendations: ^0.3.0
|
||||
matrix_link_text: ^1.0.2
|
||||
native_imaging:
|
||||
git: https://gitlab.com/famedly/company/frontend/libraries/native_imaging.git
|
||||
|
Loading…
x
Reference in New Issue
Block a user