Skip to content

Commit f2645e1

Browse files
committed
Bugfixes
1 parent 6a6f8ba commit f2645e1

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

lib/app/layouts/settings/pages/profile/profile_panel.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -723,7 +723,7 @@ class _ProfilePanelState extends OptimizedState<ProfilePanel> with WidgetsBindin
723723
));
724724

725725
if (status.statusCode != 200) {
726-
if (status.data.contains("No device available!")) {
726+
if (status.data.toString().contains("No device available!")) {
727727
Timer(const Duration(milliseconds: 100), () => pushService.offerHostedRefund(false));
728728
}
729729
throw Exception("Failed to swap ${status.data}");

lib/app/layouts/setup/setup_view.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -721,7 +721,7 @@ class SetupViewController extends StatefulController {
721721
));
722722

723723
if (status.statusCode != 200) {
724-
if (status.data.contains("No device available!")) {
724+
if (status.data.toString().contains("No device available!")) {
725725
Timer(const Duration(milliseconds: 100), () => pushService.offerHostedRefund(false));
726726
}
727727
throw Exception("Failed to swap ${status.statusCode}");

lib/services/rustpush/rustpush_service.dart

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -686,7 +686,7 @@ class RustPushBackend implements BackendService {
686686
var state = await api.getRegstate(state: pushService.state!.client);
687687
var deviceState = await api.getDeviceInfo(config: pushService.state!.osConfig);
688688
var stateStr = "";
689-
if (!detail && ss.settings.deviceIsHosted.value) {
689+
if (!detail && ss.settings.deviceIsHosted.value && ss.settings.hostedToken.value != null) {
690690
stateStr = "Subscription not active!";
691691
} else if (state is api.RegisterState_Registered) {
692692
stateStr = "Connected (renew in ${formatDuration(state.nextS)})";
@@ -2590,6 +2590,11 @@ class RustPushService extends GetxService {
25902590
Future<PurchaseWrapper?> getPurchaseDetails() async {
25912591
try {
25922592
var purchases = await pushService.client.runWithClient((client) => client.queryPurchases(ProductType.subs));
2593+
var token = purchases.purchasesList.firstOrNull?.purchaseToken;
2594+
if (token != null && ss.settings.deviceIsHosted.value) {
2595+
ss.settings.hostedToken.value = token;
2596+
ss.saveSettings();
2597+
}
25932598
return purchases.purchasesList.firstOrNull;
25942599
} catch (e, s) {
25952600
Logger.error("Failed to get purchase details", error: e, trace: s);
@@ -4587,7 +4592,7 @@ class RustPushService extends GetxService {
45874592
if (state == null) {
45884593
return;
45894594
}
4590-
if (!ss.settings.deviceIsHosted.value) return;
4595+
if (!ss.settings.deviceIsHosted.value || ss.settings.hostedToken.value == null) return;
45914596
var detail = await checkPurchaseState();
45924597
if (!detail) {
45934598
if (!notifiedSubFailed) {

0 commit comments

Comments
 (0)