Prevent demo from making web requests
This commit is contained in:
parent
e94faf0444
commit
888a21c909
|
|
@ -14,6 +14,10 @@ class WebClient {
|
|||
const WebClient();
|
||||
|
||||
Future<dynamic> get(String url, String token) async {
|
||||
if (Config.DEMO_MODE) {
|
||||
throw 'Server requests are not supported in the demo';
|
||||
}
|
||||
|
||||
url = _checkUrl(url);
|
||||
print('GET: $url');
|
||||
|
||||
|
|
@ -47,6 +51,10 @@ class WebClient {
|
|||
String password,
|
||||
bool rawResponse = false,
|
||||
}) async {
|
||||
if (Config.DEMO_MODE) {
|
||||
throw 'Server requests are not supported in the demo';
|
||||
}
|
||||
|
||||
url = _checkUrl(url);
|
||||
print('POST: $url');
|
||||
debugPrint('Data: $data', wrapWidth: 1000);
|
||||
|
|
@ -81,6 +89,10 @@ class WebClient {
|
|||
String fileIndex = 'file',
|
||||
String password,
|
||||
}) async {
|
||||
if (Config.DEMO_MODE) {
|
||||
throw 'Server requests are not supported in the demo';
|
||||
}
|
||||
|
||||
url = _checkUrl(url);
|
||||
print('PUT: $url');
|
||||
debugPrint('Data: $data', wrapWidth: 1000);
|
||||
|
|
@ -104,6 +116,10 @@ class WebClient {
|
|||
}
|
||||
|
||||
Future<dynamic> delete(String url, String token, {String password}) async {
|
||||
if (Config.DEMO_MODE) {
|
||||
throw 'Server requests are not supported in the demo';
|
||||
}
|
||||
|
||||
url = _checkUrl(url);
|
||||
print('Delete: $url');
|
||||
|
||||
|
|
@ -157,18 +173,12 @@ Map<String, String> _getHeaders(String url, String token,
|
|||
}
|
||||
|
||||
void _checkResponse(http.Response response) {
|
||||
if (Config.DEMO_MODE) {
|
||||
throw 'Server requests are not supported in the demo';
|
||||
}
|
||||
|
||||
debugPrint(
|
||||
'response: ${response.statusCode} ${response.body.substring(0, min(response.body.length, 30000))}',
|
||||
wrapWidth: 1000);
|
||||
//debugPrint('response: ${response.statusCode} ${response.body}');
|
||||
print('headers: ${response.headers}');
|
||||
|
||||
print('CODE: ${response.statusCode}, >400 ${response.statusCode >= 400 ? 'YES' : 'NON'}');
|
||||
|
||||
final version = response.headers['x-app-version'];
|
||||
|
||||
if (version != null && !_isVersionSupported(version)) {
|
||||
|
|
|
|||
|
|
@ -139,6 +139,6 @@ Future<AppState> _initialState(bool isTesting) async {
|
|||
return AppState(
|
||||
prefState: prefState,
|
||||
currentRoute: currentRoute,
|
||||
url: getBrowserUrl(),
|
||||
url: Config.DEMO_MODE ? '' : getBrowserUrl(),
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,9 @@ import 'package:flutter_slidable/flutter_slidable.dart';
|
|||
import 'package:invoiceninja_flutter/data/models/models.dart';
|
||||
import 'package:invoiceninja_flutter/ui/app/lists/selected_indicator.dart';
|
||||
import 'package:invoiceninja_flutter/utils/localization.dart';
|
||||
import 'package:flutter_redux/flutter_redux.dart';
|
||||
import 'package:invoiceninja_flutter/data/models/entities.dart';
|
||||
import 'package:invoiceninja_flutter/redux/app/app_state.dart';
|
||||
|
||||
class DismissibleEntity extends StatelessWidget {
|
||||
const DismissibleEntity({
|
||||
|
|
@ -30,6 +33,9 @@ class DismissibleEntity extends StatelessWidget {
|
|||
}
|
||||
|
||||
final localization = AppLocalization.of(context);
|
||||
final store = StoreProvider.of<AppState>(context);
|
||||
final isMultiselect =
|
||||
store.state.getListState(entity.entityType).isInMultiselect();
|
||||
|
||||
return Slidable(
|
||||
actionPane: SlidableDrawerActionPane(),
|
||||
|
|
@ -83,7 +89,7 @@ class DismissibleEntity extends StatelessWidget {
|
|||
),
|
||||
],
|
||||
child: SelectedIndicator(
|
||||
isSelected: isSelected,
|
||||
isSelected: isSelected && !isMultiselect,
|
||||
child: child,
|
||||
),
|
||||
);
|
||||
|
|
|
|||
|
|
@ -64,7 +64,8 @@ class EntityDataTableSource extends AppDataTableSource {
|
|||
}
|
||||
|
||||
bool isSelected = false;
|
||||
if (state.prefState.isPreviewVisible || state.uiState.isEditing) {
|
||||
if (!listState.isInMultiselect() &&
|
||||
(state.prefState.isPreviewVisible || state.uiState.isEditing)) {
|
||||
if (state.uiState.isEditing
|
||||
? entity.id == editingId
|
||||
: entity.id == uIState.selectedId) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue