Skip to content

Commit

Permalink
Merge branch 'develop' into bugfix/LIVE-11922
Browse files Browse the repository at this point in the history
  • Loading branch information
kallen-ledger committed Aug 2, 2024
2 parents dca83b6 + 7193e79 commit a4e979b
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 36 deletions.
5 changes: 5 additions & 0 deletions .changeset/silly-penguins-thank.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"ledger-live-desktop": patch
---

Sync onboarding: fix text not wrapping in "install apps" step
1 change: 1 addition & 0 deletions CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ apps/cli/src/commands/devices @ledgerhq/liv
**/screens/CustomImage @ledgerhq/live-devices
**/components/CustomImage @ledgerhq/live-devices
**/SyncOnboarding/** @ledgerhq/live-devices
**/OnboardingAppInstall/** @ledgerhq/live-devices
apps/**/components/DeviceAction/ @ledgerhq/live-devices
apps/ledger-live-mobile/src/screens/MyLedger*/ @ledgerhq/live-devices
apps/ledger-live-mobile/src/newArch/features/FirmwareUpdate/ @ledgerhq/live-devices
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,10 @@ const InstallSetOfApps = ({
/>
<Flex height="100%">
<Flex flex={1} alignItems="flex-start" flexDirection="column">
<Flex style={{ width: "100%" }} flexDirection="row" justifyContent="space-between" mb={6}>
<Text data-testid="installing-text">{t("onboardingAppInstall.progress.progress")}</Text>
<Flex flexDirection="row" justifyContent="space-between" mb={6}>
<Text flex={1} data-testid="installing-text">
{t("onboardingAppInstall.progress.progress")}
</Text>
</Flex>
{missingApps ? (
<Alert title={t("onboardingAppInstall.progress.skippedInfo", { productName })} />
Expand Down
16 changes: 16 additions & 0 deletions apps/web-tools/trustchain/components/AppAccountsSync.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import { Loading } from "./Loading";
import { TrustchainEjected } from "@ledgerhq/trustchain/lib-es/errors";
import { Tick } from "./Tick";
import { State } from "./types";
import { Actionable } from "./Actionable";

/*
import * as icons from "@ledgerhq/crypto-icons-ui/react";
Expand Down Expand Up @@ -176,6 +177,8 @@ export default function AppAccountsSync({
const [timestamp, setTimestamp] = useState(0);
const [onUserRefresh, setOnUserRefresh] = useState<() => void>(() => () => {});

const [watchConfig, setWatchConfig] = useState({ notificationsEnabled: false });

// pull and push wallet sync loop
useEffect(() => {
const localIncrementUpdate = makeLocalIncrementalUpdate({
Expand All @@ -187,6 +190,7 @@ export default function AppAccountsSync({
});

const { unsubscribe, onUserRefreshIntent } = walletSyncWatchLoop({
watchConfig,
walletSyncSdk,
localIncrementUpdate,
trustchain,
Expand Down Expand Up @@ -214,6 +218,7 @@ export default function AppAccountsSync({
getState,
saveUpdate,
ctx,
watchConfig,
]);

const setAccounts = useCallback(
Expand Down Expand Up @@ -264,6 +269,17 @@ export default function AppAccountsSync({
bridgeCache={bridgeCache}
setAccounts={setAccounts}
/>

<Actionable
buttonTitle="Toggle WebSocket notifications"
inputs={[watchConfig.notificationsEnabled]}
action={enabled => !enabled}
value={watchConfig.notificationsEnabled}
setValue={notificationsEnabled =>
typeof notificationsEnabled === "boolean" && setWatchConfig({ notificationsEnabled })
}
valueDisplay={v => (v ? "Listening" : "Not listening")}
/>
</div>
);
}
Expand Down
74 changes: 40 additions & 34 deletions libs/live-wallet/src/walletsync/createWalletSyncWatchLoop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,14 @@ import { MemberCredentials, Trustchain } from "@ledgerhq/trustchain/types";
import { WalletSyncDataManager } from "./types";
import { log } from "@ledgerhq/logs";
import { TrustchainEjected, TrustchainOutdated } from "@ledgerhq/trustchain/errors";
import { Subscription } from "rxjs";

export type WatchConfig =
| {
type: "polling";
pollingInterval?: number;
initialTimeout?: number;
userIntentDebounce?: number;
}
| {
type: "notifications";
};
export type WatchConfig = {
notificationsEnabled?: boolean;
pollingInterval?: number;
initialTimeout?: number;
userIntentDebounce?: number;
};

export type VisualConfig = {
visualPendingTimeout: number;
Expand Down Expand Up @@ -171,31 +168,40 @@ export function createWalletSyncWatchLoop<
}
}

if (watchConfig?.type === "notifications") {
throw new Error("notifications not implemented yet");
} else {
const pollingInterval = watchConfig?.pollingInterval || 30000;
const initialTimeout = watchConfig?.initialTimeout || 5000;
const userIntentDebounce = watchConfig?.userIntentDebounce || 1000;
const notificationsEnabled = watchConfig?.notificationsEnabled || false;
const pollingInterval = watchConfig?.pollingInterval || 10000;
const initialTimeout = watchConfig?.initialTimeout || 5000;
const userIntentDebounce = watchConfig?.userIntentDebounce || 1000;

// main loop
const callback = () => {
timeout = setTimeout(callback, pollingInterval);
loop();
};
let timeout = setTimeout(callback, initialTimeout);
// main loop
const callback = () => {
timeout = setTimeout(callback, pollingInterval);
loop();
};
let timeout = setTimeout(callback, initialTimeout);

return {
onUserRefreshIntent: () => {
if (unsubscribed) return;
// user intent will cancel the next loop call and reschedule one in a short time
clearTimeout(timeout);
timeout = setTimeout(callback, userIntentDebounce);
},
unsubscribe: () => {
unsubscribed = true;
clearInterval(timeout);
},
};
let notificationsSub: Subscription | null = null;
if (notificationsEnabled) {
// minimal implementation that do not handle any retry in case the notification stream is lost.
notificationsSub = walletSyncSdk
.listenNotifications(trustchain, memberCredentials)
.subscribe(() => {
log("walletsync", "notification");
loop();
});
}

return {
onUserRefreshIntent: () => {
if (unsubscribed) return;
// user intent will cancel the next loop call and reschedule one in a short time
clearTimeout(timeout);
timeout = setTimeout(callback, userIntentDebounce);
},
unsubscribe: () => {
unsubscribed = true;
clearInterval(timeout);
if (notificationsSub) notificationsSub.unsubscribe();
},
};
}

0 comments on commit a4e979b

Please sign in to comment.