-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature(connector)_: Add model join to handle connected dApps
- Loading branch information
Showing
9 changed files
with
244 additions
and
8 deletions.
There are no files selected for viewing
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
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
69 changes: 69 additions & 0 deletions
69
ui/app/AppLayouts/Wallet/services/dapps/ConnectorDAppsListProvider.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,69 @@ | ||
import QtQuick 2.15 | ||
import StatusQ.Core.Utils 0.1 | ||
import AppLayouts.Wallet.services.dapps 1.0 | ||
import shared.stores 1.0 | ||
import utils 1.0 | ||
|
||
QObject { | ||
id: root | ||
|
||
readonly property alias dappsModel: d.dappsModel | ||
|
||
function addSession(session) { | ||
d.addSession(session) | ||
} | ||
|
||
function revokeSession(session) { | ||
d.revokeSession(session) | ||
} | ||
|
||
function getActiveSession(dAppUrl) { | ||
return d.getActionSession(dAppUrl) | ||
} | ||
|
||
QObject { | ||
id: d | ||
|
||
property ListModel dappsModel: ListModel { | ||
id: dapps | ||
} | ||
|
||
function addSession(dappInfo) { | ||
let dappItem = JSON.parse(dappInfo) | ||
dapps.append(dappItem) | ||
} | ||
|
||
function revokeSession(dappInfo) { | ||
let dappItem = JSON.parse(dappInfo) | ||
for (let i = 0; i < dapps.count; i++) { | ||
let existingDapp = dapps.get(i) | ||
if (existingDapp.url === dappItem.url) { | ||
dapps.remove(i) | ||
break | ||
} | ||
} | ||
} | ||
|
||
function revokeAllSessions() { | ||
for (let i = 0; i < dapps.count; i++) { | ||
dapps.remove(i) | ||
} | ||
} | ||
|
||
function getActionSession(dAppUrl) { | ||
for (let i = 0; i < dapps.count; i++) { | ||
let existingDapp = dapps.get(i) | ||
|
||
if (existingDapp.url === dAppUrl) { | ||
return JSON.stringify({ | ||
name: existingDapp.name, | ||
url: existingDapp.url, | ||
icon: existingDapp.iconUrl | ||
}); | ||
} | ||
} | ||
|
||
return null | ||
} | ||
} | ||
} |
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
Oops, something went wrong.