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