-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(dapps) move responsibility of tracking sessions from WC SDK
Updates: #14615
- Loading branch information
1 parent
0cf41a6
commit ea2b6b2
Showing
4 changed files
with
84 additions
and
84 deletions.
There are no files selected for viewing
79 changes: 79 additions & 0 deletions
79
ui/app/AppLayouts/Wallet/services/dapps/DAppsListProvider.qml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
import QtQuick 2.15 | ||
|
||
import utils 1.0 | ||
|
||
QtObject { | ||
id: root | ||
|
||
required property WalletConnectSDK sdk | ||
|
||
readonly property alias pairingsModel: d.pairingsModel | ||
readonly property alias sessionsModel: d.sessionsModel | ||
|
||
function updatePairings() { | ||
d.resetPairingsModel() | ||
} | ||
function updateSessions() { | ||
d.resetSessionsModel() | ||
} | ||
|
||
readonly property QtObject _d: QtObject { | ||
id: d | ||
|
||
property ListModel pairingsModel: ListModel { | ||
id: pairings | ||
} | ||
property ListModel sessionsModel: ListModel { | ||
id: sessions | ||
} | ||
|
||
function resetPairingsModel(entryCallback) | ||
{ | ||
pairings.clear(); | ||
|
||
// We have to postpone `getPairings` call, cause otherwise: | ||
// - the last made pairing will always have `active` prop set to false | ||
// - expiration date won't be the correct one, but one used in session proposal | ||
// - the list of pairings will display succesfully made pairing as inactive | ||
Backpressure.debounce(this, 250, () => { | ||
sdk.getPairings((pairList) => { | ||
for (let i = 0; i < pairList.length; i++) { | ||
pairings.append(pairList[i]); | ||
|
||
if (entryCallback) { | ||
entryCallback(pairList[i]) | ||
} | ||
} | ||
}); | ||
})(); | ||
} | ||
|
||
function resetSessionsModel() { | ||
sessions.clear(); | ||
|
||
Backpressure.debounce(this, 250, () => { | ||
sdk.getActiveSessions((sessionList) => { | ||
for (var topic of Object.keys(sessionList)) { | ||
sessions.append(sessionList[topic]); | ||
} | ||
}); | ||
})(); | ||
} | ||
|
||
function getPairingTopicFromPairingUrl(url) | ||
{ | ||
if (!url.startsWith("wc:")) | ||
{ | ||
return null; | ||
} | ||
|
||
const atIndex = url.indexOf("@"); | ||
if (atIndex < 0) | ||
{ | ||
return null; | ||
} | ||
|
||
return url.slice(3, atIndex); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
WalletConnectSDK 1.0 WalletConnectSDK.qml | ||
WalletConnectService 1.0 WalletConnectService.qml | ||
DAppsListProvider 1.0 DAppsListProvider.qml | ||
|
||
Helpers 1.0 helpers.js |