@@ -28,6 +28,7 @@ import 'presence.dart';
28
28
import 'realm.dart' ;
29
29
import 'recent_dm_conversations.dart' ;
30
30
import 'recent_senders.dart' ;
31
+ import 'server_support.dart' ;
31
32
import 'channel.dart' ;
32
33
import 'saved_snippet.dart' ;
33
34
import 'settings.dart' ;
@@ -208,7 +209,7 @@ abstract class GlobalStore extends ChangeNotifier {
208
209
assert (account != null ); // doLoadPerAccount would have thrown AccountNotFoundException
209
210
final zulipLocalizations = GlobalLocalizations .zulipLocalizations;
210
211
switch (e) {
211
- case _ServerVersionUnsupportedException ():
212
+ case ServerVersionUnsupportedException ():
212
213
reportErrorToUserModally (
213
214
zulipLocalizations.errorCouldNotConnectTitle,
214
215
message: zulipLocalizations.errorServerVersionUnsupportedMessage (
@@ -1026,9 +1027,9 @@ class UpdateMachine {
1026
1027
try {
1027
1028
initialSnapshot = await _registerQueueWithRetry (connection,
1028
1029
stopAndThrowIfNoAccount: stopAndThrowIfNoAccount);
1029
- } on _ServerVersionUnsupportedException catch (e) {
1030
+ } on ServerVersionUnsupportedException catch (e) {
1030
1031
// `!` is OK because _registerQueueWithRetry would have thrown a
1031
- // not-_ServerVersionUnsupportedException if no account
1032
+ // not-ServerVersionUnsupportedException if no account
1032
1033
final account = globalStore.getAccount (accountId)! ;
1033
1034
if (! e.data.matchesAccount (account)) {
1034
1035
await globalStore.updateZulipVersionData (accountId, e.data);
@@ -1094,7 +1095,7 @@ class UpdateMachine {
1094
1095
case MalformedServerResponseException ()
1095
1096
when (zulipVersionData = ZulipVersionData .fromMalformedServerResponseException (e))
1096
1097
? .isUnsupported == true :
1097
- throw _ServerVersionUnsupportedException (zulipVersionData! );
1098
+ throw ServerVersionUnsupportedException (zulipVersionData! );
1098
1099
case HttpException (httpStatus: 401 ):
1099
1100
// We cannot recover from this error through retrying.
1100
1101
// Leave it to [GlobalStore.loadPerAccount].
@@ -1114,7 +1115,7 @@ class UpdateMachine {
1114
1115
stopAndThrowIfNoAccount ();
1115
1116
final zulipVersionData = ZulipVersionData .fromInitialSnapshot (result);
1116
1117
if (zulipVersionData.isUnsupported) {
1117
- throw _ServerVersionUnsupportedException (zulipVersionData);
1118
+ throw ServerVersionUnsupportedException (zulipVersionData);
1118
1119
}
1119
1120
return result;
1120
1121
}
@@ -1529,58 +1530,6 @@ class UpdateMachine {
1529
1530
String toString () => '${objectRuntimeType (this , 'UpdateMachine' )}#${shortHash (this )}' ;
1530
1531
}
1531
1532
1532
- /// The fields 'zulip_version', 'zulip_merge_base', and 'zulip_feature_level'
1533
- /// from a /register response.
1534
- class ZulipVersionData {
1535
- const ZulipVersionData ({
1536
- required this .zulipVersion,
1537
- required this .zulipMergeBase,
1538
- required this .zulipFeatureLevel,
1539
- });
1540
-
1541
- factory ZulipVersionData .fromInitialSnapshot (InitialSnapshot initialSnapshot) =>
1542
- ZulipVersionData (
1543
- zulipVersion: initialSnapshot.zulipVersion,
1544
- zulipMergeBase: initialSnapshot.zulipMergeBase,
1545
- zulipFeatureLevel: initialSnapshot.zulipFeatureLevel);
1546
-
1547
- /// Make a [ZulipVersionData] from a [MalformedServerResponseException] ,
1548
- /// if the body was readable/valid JSON and contained the data, else null.
1549
- ///
1550
- /// If there's a zulip_version but no zulip_feature_level,
1551
- /// we infer it's indeed a Zulip server,
1552
- /// just an ancient one before feature levels were introduced in Zulip 3.0,
1553
- /// and we set 0 for zulipFeatureLevel.
1554
- static ZulipVersionData ? fromMalformedServerResponseException (MalformedServerResponseException e) {
1555
- try {
1556
- final data = e.data! ;
1557
- return ZulipVersionData (
1558
- zulipVersion: data['zulip_version' ] as String ,
1559
- zulipMergeBase: data['zulip_merge_base' ] as String ? ,
1560
- zulipFeatureLevel: data['zulip_feature_level' ] as int ? ?? 0 );
1561
- } catch (inner) {
1562
- return null ;
1563
- }
1564
- }
1565
-
1566
- final String zulipVersion;
1567
- final String ? zulipMergeBase;
1568
- final int zulipFeatureLevel;
1569
-
1570
- bool matchesAccount (Account account) =>
1571
- zulipVersion == account.zulipVersion
1572
- && zulipMergeBase == account.zulipMergeBase
1573
- && zulipFeatureLevel == account.zulipFeatureLevel;
1574
-
1575
- bool get isUnsupported => zulipFeatureLevel < kMinSupportedZulipFeatureLevel;
1576
- }
1577
-
1578
- class _ServerVersionUnsupportedException implements Exception {
1579
- final ZulipVersionData data;
1580
-
1581
- _ServerVersionUnsupportedException (this .data);
1582
- }
1583
-
1584
1533
class _EventHandlingException implements Exception {
1585
1534
final Object cause;
1586
1535
final Event event;
0 commit comments