diff --git a/.run/macos.run.xml b/.run/macos.run.xml new file mode 100644 index 0000000000..a8536c4ad1 --- /dev/null +++ b/.run/macos.run.xml @@ -0,0 +1,7 @@ + + + + \ No newline at end of file diff --git a/.run/windows.run.xml b/.run/windows.run.xml new file mode 100644 index 0000000000..54874b50e5 --- /dev/null +++ b/.run/windows.run.xml @@ -0,0 +1,7 @@ + + + + \ No newline at end of file diff --git a/desktop/app/app.go b/desktop/app/app.go index 0ba46b06f3..6fbfd91b26 100644 --- a/desktop/app/app.go +++ b/desktop/app/app.go @@ -376,7 +376,10 @@ func (app *App) OnStatsChange(fn func(stats.Stats)) { func (app *App) afterStart(cl *flashlightClient.Client) { ctx := context.Background() go app.fetchOrCreateUser(ctx) - go app.proClient.DesktopPaymentMethods(ctx) + if app.settings.GetUserID() != 0 { + // fetch plan only if user is created + go app.proClient.DesktopPaymentMethods(ctx) + } go app.fetchDeviceLinkingCode(ctx) app.OnSettingChange(settings.SNSystemProxy, func(val interface{}) { @@ -667,9 +670,12 @@ func (app *App) ProClient() proclient.ProClient { } // Client session methods +// this method get call when user is being created first time func (app *App) FetchUserData() error { go app.proClient.UserData(context.Background()) go app.proClient.FetchPaymentMethodsAndCache(context.Background()) + //Update UI + app.sendConfigOptions() return nil } diff --git a/desktop/datacap/datacap.go b/desktop/datacap/datacap.go index 9ec2a172ef..7a05fef991 100644 --- a/desktop/datacap/datacap.go +++ b/desktop/datacap/datacap.go @@ -4,7 +4,6 @@ import ( "strconv" "strings" "sync" - "time" "github.com/getlantern/flashlight/v7/bandwidth" "github.com/getlantern/flashlight/v7/common" @@ -28,13 +27,6 @@ var ( log = golog.LoggerFor("lantern-desktop.datacap") translationAppName = strings.ToUpper(common.DefaultAppName) - - uncapped = &bandwidth.Quota{ - MiBAllowed: 0, - MiBUsed: 0, - AsOf: time.Now(), - TTLSeconds: 0, - } ) type dataCap struct { @@ -49,10 +41,14 @@ func ServeDataCap(channel ws.UIChannel, iconURL func() string, clickURL func() s q, _ := bandwidth.GetQuota() if q == nil { // On client first connecting, if we don't have a datacap, assume we're uncapped - q = uncapped + uncapped := map[string]interface{}{ + "percent": 0, + "mibUsed": 0, + "mibAllowed": 0, + } + log.Debugf("Sending current bandwidth quota to new client: %v", q) + write(uncapped) } - log.Debugf("Sending current bandwidth quota to new client: %v", q) - write(q) } bservice, err := channel.Register("bandwidth", helloFn) if err != nil { diff --git a/desktop/lib.go b/desktop/lib.go index 095b09ef38..9439adf0f8 100644 --- a/desktop/lib.go +++ b/desktop/lib.go @@ -430,6 +430,16 @@ func reportIssue(email, issueType, description *C.char) *C.char { return C.CString("true") } +//export updatePaymentMethod +func updatePaymentMethod() *C.char { + _, err := a.ProClient().DesktopPaymentMethods(context.Background()) + if err != nil { + return sendError(err) + } + a.SendConfig() + return C.CString("true") +} + //export checkUpdates func checkUpdates() *C.char { log.Debug("Checking for updates") diff --git a/go.mod b/go.mod index b8051e3bb7..c0d6b5ae08 100644 --- a/go.mod +++ b/go.mod @@ -37,7 +37,7 @@ require ( github.com/getlantern/eventual v1.0.0 github.com/getlantern/eventual/v2 v2.0.2 github.com/getlantern/filepersist v0.0.0-20210901195658-ed29a1cb0b7c - github.com/getlantern/flashlight/v7 v7.6.173 + github.com/getlantern/flashlight/v7 v7.6.175 github.com/getlantern/fronted v0.0.0-20241218113928-4db253857875 github.com/getlantern/geolookup v0.0.0-20230327091034-aebe73c6eef4 github.com/getlantern/golog v0.0.0-20230503153817-8e72de7e0a65 diff --git a/go.sum b/go.sum index fe369b9f54..307f3fad12 100644 --- a/go.sum +++ b/go.sum @@ -315,8 +315,8 @@ github.com/getlantern/fdcount v0.0.0-20210503151800-5decd65b3731/go.mod h1:XZwE+ github.com/getlantern/filepersist v0.0.0-20160317154340-c5f0cd24e799/go.mod h1:8DGAx0LNUfXNnEH+fXI0s3OCBA/351kZCiz/8YSK3i8= github.com/getlantern/filepersist v0.0.0-20210901195658-ed29a1cb0b7c h1:mcz27xtAkb1OuOLBct/uFfL1p3XxAIcFct82GbT+UZM= github.com/getlantern/filepersist v0.0.0-20210901195658-ed29a1cb0b7c/go.mod h1:8DGAx0LNUfXNnEH+fXI0s3OCBA/351kZCiz/8YSK3i8= -github.com/getlantern/flashlight/v7 v7.6.173 h1:JvFMZlysbBcURai0JsuIrnlku6EUsbWuqcSn3aTbcYI= -github.com/getlantern/flashlight/v7 v7.6.173/go.mod h1:2HDjD6lx7W5hbTh3Vg572bHVFd9YZ4YODLl2b+d7JBw= +github.com/getlantern/flashlight/v7 v7.6.175 h1:Jmkf4n6gxiUWLEcmTqSZNoLp7Q+CdUAuZgROwkHXBFI= +github.com/getlantern/flashlight/v7 v7.6.175/go.mod h1:2HDjD6lx7W5hbTh3Vg572bHVFd9YZ4YODLl2b+d7JBw= github.com/getlantern/framed v0.0.0-20190601192238-ceb6431eeede h1:yrU6Px3ZkvCsDLPryPGi6FN+2iqFPq+JeCb7EFoDBhw= github.com/getlantern/framed v0.0.0-20190601192238-ceb6431eeede/go.mod h1:nhnoiS6DE6zfe+BaCMU4YI01UpsuiXnDqM5S8jxHuuI= github.com/getlantern/fronted v0.0.0-20241218113928-4db253857875 h1:i87Jjwv5XdhTMWvkU3zZusp9A5NvSbX39x38UEuJ3cw= diff --git a/internalsdk/session_model.go b/internalsdk/session_model.go index 6c26a18a33..cf0c74a48d 100644 --- a/internalsdk/session_model.go +++ b/internalsdk/session_model.go @@ -757,11 +757,6 @@ func (m *SessionModel) initSessionModel(ctx context.Context, opts *SessionModelO pathdb.Mutate(m.db, func(tx pathdb.TX) error { return pathdb.Put(tx, pathIsFirstTime, true, "") }) - - // err = m.userCreate(ctx) - // if err != nil { - // log.Error(err) - // } go m.proClient.RetryCreateUser(ctx, m, 10*time.Minute) } else { // Get all user details diff --git a/lib/core/app/app_webview.dart b/lib/core/app/app_webview.dart index 6538e82bef..8b92ac0d4b 100644 --- a/lib/core/app/app_webview.dart +++ b/lib/core/app/app_webview.dart @@ -104,26 +104,26 @@ class _AppWebViewState extends State { onReceivedError: (controller, request, error) => showErrorDialog("Failed to load", error.description), initialSettings: InAppWebViewSettings( - isInspectable: kDebugMode, - javaScriptEnabled: true, - supportZoom: true, - domStorageEnabled: true, - allowFileAccess: true, - useWideViewPort: !isDesktop(), - loadWithOverviewMode: !isDesktop(), - clearCache: true, - mixedContentMode: MixedContentMode.MIXED_CONTENT_ALWAYS_ALLOW, - builtInZoomControls: Platform.isAndroid, - displayZoomControls: false, - mediaPlaybackRequiresUserGesture: false, - allowsInlineMediaPlayback: false, - underPageBackgroundColor: Colors.white, - transparentBackground: true, - allowFileAccessFromFileURLs: true, - preferredContentMode: isMobile() - ? UserPreferredContentMode.MOBILE - : UserPreferredContentMode.RECOMMENDED, - ), + isInspectable: kDebugMode, + javaScriptEnabled: true, + supportZoom: true, + domStorageEnabled: true, + allowFileAccess: true, + useWideViewPort: false, + loadWithOverviewMode: true, + clearCache: true, + mixedContentMode: MixedContentMode.MIXED_CONTENT_ALWAYS_ALLOW, + builtInZoomControls: Platform.isAndroid, + displayZoomControls: false, + mediaPlaybackRequiresUserGesture: false, + allowsInlineMediaPlayback: false, + underPageBackgroundColor: Colors.white, + transparentBackground: true, + allowFileAccessFromFileURLs: true, + //We want to use mobile mode for webview on desktop + // Since we are showign app on mobile size it will be better to use mobile mode + // showing recommended mode user has to scroll a lot + preferredContentMode: UserPreferredContentMode.MOBILE), onProgressChanged: (controller, progress) => appLogger.i("Loading progress: $progress%"), ), diff --git a/lib/core/service/lantern_ffi_service.dart b/lib/core/service/lantern_ffi_service.dart index 14fa73eae6..0203ac6888 100644 --- a/lib/core/service/lantern_ffi_service.dart +++ b/lib/core/service/lantern_ffi_service.dart @@ -1,6 +1,5 @@ import 'dart:isolate'; -import 'package:ffi/ffi.dart'; import 'package:lantern/core/utils/common.dart'; import 'package:lantern/core/utils/common_desktop.dart'; import 'package:sentry_flutter/sentry_flutter.dart'; @@ -342,6 +341,13 @@ class LanternFFI { checkAuthAPIError(result); return Future.value(result.toBool()); } + + static FutureOr updatePaymentPlans(dynamic context) { + final result = + _lanternFFI.updatePaymentMethod().cast().toDartString(); + checkAPIError(result, 'we_are_experiencing_technical_difficulties'.i18n); + return Future.value(result.toBool()); + } } // checkAPIError throws a PlatformException if the API response contains an error @@ -375,5 +381,3 @@ void checkAuthAPIError(result) { return; } } - -// final lanternFFI = LanternFFI; diff --git a/lib/features/checkout/checkout_legacy.dart b/lib/features/checkout/checkout_legacy.dart index 9e1ca8a305..5bb24d9ff0 100644 --- a/lib/features/checkout/checkout_legacy.dart +++ b/lib/features/checkout/checkout_legacy.dart @@ -10,12 +10,11 @@ import 'package:retry/retry.dart'; class CheckoutLegacy extends StatefulWidget { final Plan plan; final bool isPro; - const CheckoutLegacy({ required this.plan, required this.isPro, - Key? key, - }) : super(key: key); + super.key, + }); @override State createState() => _CheckoutLegacyState(); diff --git a/lib/features/home/session_model.dart b/lib/features/home/session_model.dart index e068a9488e..4a06d24363 100644 --- a/lib/features/home/session_model.dart +++ b/lib/features/home/session_model.dart @@ -122,7 +122,8 @@ class SessionModel extends Model { Widget proUser(ValueWidgetBuilder builder) { if (isMobile()) { - return subscribedSingleValueBuilder('prouser', builder: builder,defaultValue: false); + return subscribedSingleValueBuilder('prouser', + builder: builder, defaultValue: false); } return FfiValueBuilder('prouser', proUserNotifier, builder); } @@ -607,6 +608,9 @@ class SessionModel extends Model { } Future updatePaymentPlans() async { + if (isDesktop()) { + return compute(LanternFFI.updatePaymentPlans, ''); + } return methodChannel.invokeMethod('updatePaymentPlans', ''); } diff --git a/lib/features/vpn/vpn_bandwidth.dart b/lib/features/vpn/vpn_bandwidth.dart index 55d01889ad..926f8e1bc6 100644 --- a/lib/features/vpn/vpn_bandwidth.dart +++ b/lib/features/vpn/vpn_bandwidth.dart @@ -15,6 +15,11 @@ class VPNBandwidth extends StatelessWidget { // received any bandwidth updates return const SizedBox(); } + // If the user is uncap, don't show the data usage + if (bandwidth.mibAllowed == 0) { + return const SizedBox(); + } + return Column( children: [ Container( diff --git a/lib/generated_bindings.dart b/lib/generated_bindings.dart index dda498ca7d..9f96c25ca6 100644 --- a/lib/generated_bindings.dart +++ b/lib/generated_bindings.dart @@ -569,6 +569,16 @@ class NativeLibrary { ffi.Pointer Function(ffi.Pointer, ffi.Pointer, ffi.Pointer)>(); + ffi.Pointer updatePaymentMethod() { + return _updatePaymentMethod(); + } + + late final _updatePaymentMethodPtr = + _lookup Function()>>( + 'updatePaymentMethod'); + late final _updatePaymentMethod = + _updatePaymentMethodPtr.asFunction Function()>(); + ffi.Pointer checkUpdates() { return _checkUpdates(); } diff --git a/liblantern_amd64.h b/liblantern_amd64.h index ee32cf6a82..598c1b16dd 100644 --- a/liblantern_amd64.h +++ b/liblantern_amd64.h @@ -136,6 +136,7 @@ extern char* deviceLinkingCode(); extern char* paymentRedirect(char* planID, char* currency, char* provider, char* email, char* deviceName); extern void exitApp(); extern char* reportIssue(char* email, char* issueType, char* description); +extern char* updatePaymentMethod(); extern char* checkUpdates(); #ifdef __cplusplus diff --git a/liblantern_arm64.h b/liblantern_arm64.h index ee32cf6a82..598c1b16dd 100644 --- a/liblantern_arm64.h +++ b/liblantern_arm64.h @@ -136,6 +136,7 @@ extern char* deviceLinkingCode(); extern char* paymentRedirect(char* planID, char* currency, char* provider, char* email, char* deviceName); extern void exitApp(); extern char* reportIssue(char* email, char* issueType, char* description); +extern char* updatePaymentMethod(); extern char* checkUpdates(); #ifdef __cplusplus