Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/app/modules/main/chat_section/controller.nim
Original file line number Diff line number Diff line change
Expand Up @@ -706,6 +706,9 @@ proc getTokenByKey*(self: Controller, tokenKey: string): TokenItem =
proc getTokensByGroupKey*(self: Controller, groupKey: string): seq[TokenItem] =
return self.tokenService.getTokensByGroupKey(groupKey)

proc getTokenByKeyOrGroupKeyFromAllTokens*(self: Controller, key: string): TokenItem =
return self.tokenService.getTokenByKeyOrGroupKeyFromAllTokens(key)

proc createOrEditCommunityTokenPermission*(self: Controller, tokenPermission: CommunityTokenPermissionDto) =
self.communityService.createOrEditCommunityTokenPermission(self.sectionId, tokenPermission)

Expand Down
7 changes: 6 additions & 1 deletion src/app/modules/main/chat_section/module.nim
Original file line number Diff line number Diff line change
Expand Up @@ -1499,7 +1499,12 @@ method createOrEditCommunityTokenPermission*(self: Module, permissionId: string,
if tokenCriteriaDto.`type` != TokenType.ENS:
if not service_common_utils.isTokenKey(key):
# handle token group
let tokens = self.controller.getTokensByGroupKey(key)
var tokens = self.controller.getTokensByGroupKey(key)
if tokens.len == 0:
# fallback to get token by key or group key from all tokens
let token = self.controller.getTokenByKeyOrGroupKeyFromAllTokens(key)
if not token.isNil:
tokens = @[token]
if tokens.len == 0:
emitUnexistingKeyError(key)
return
Expand Down
4 changes: 2 additions & 2 deletions ui/app/AppLayouts/Chat/stores/RootStore.qml
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ QtObject {
proxyRoles: [
FastExpressionRole {
function collectibleIcon(icon) {
return !!icon ? icon : Assets.png("tokens/DEFAULT-TOKEN")
return !!icon ? icon : Assets.png(Constants.defaultTokenIcon)
}
name: "iconSource"
expression: collectibleIcon(model.icon)
Expand All @@ -101,7 +101,7 @@ QtObject {
},
FastExpressionRole {
function collectibleIcon(icon) {
return !!icon ? icon : Assets.png("tokens/DEFAULT-TOKEN")
return !!icon ? icon : Assets.png(Constants.defaultTokenIcon)
}
name: "collectionImageUrl"
expression: collectibleIcon(model.icon)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ StatusListView {

name: model.name
shortName: model.shortName ?? ""
iconSource: model.iconSource ? model.iconSource : Assets.png("tokens/DEFAULT-TOKEN")
iconSource: model.iconSource ? model.iconSource : Assets.png(Constants.defaultTokenIcon)
showSubItemsIcon: !!model.subItems && model.subItems.count > 0
selected: root.checkedKeys.includes(model.key)
amount: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ QtObject {

function getTokenIconByKey(model, isCollectible, key) {
const item = getTokenByKey(model, isCollectible, key)
const defaultIcon = Assets.png("tokens/DEFAULT-TOKEN")
const defaultIcon = Assets.png(Constants.defaultTokenIcon)
if (item)
return item.iconSource ? item.iconSource : defaultIcon
return defaultIcon
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ StackView {
required property var assetsModel
required property var collectiblesModel
required property var channelsModel

// Returns token that matches provided key (key can be token or group key). Use it as a last option (may affect app performances, because it fetches all tokens from stautsgo).
property var getTokenByKeyOrGroupKeyFromAllTokens: function(key){ return {}}

property bool showChannelSelector: true
property bool ensCommunityPermissionsEnabled
property alias initialPage: initialItem
Expand Down Expand Up @@ -115,6 +119,8 @@ StackView {
collectiblesModel: root.collectiblesModel
channelsModel: allChannelsTransformed

getTokenByKeyOrGroupKeyFromAllTokens: root.getTokenByKeyOrGroupKeyFromAllTokens

communityDetails: root.communityDetails

preferredContentWidth: root.preferredContentWidth
Expand Down
7 changes: 7 additions & 0 deletions ui/app/AppLayouts/Communities/popups/CreateChannelPopup.qml
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,13 @@ import AppLayouts.Communities.panels
import AppLayouts.Communities.models
import AppLayouts.Communities.controls
import AppLayouts.Communities.stores as CommunitiesStores
import AppLayouts.Wallet.stores

StatusStackModal {
id: root

property CommunitiesStores.CommunitiesStore communitiesStore
property TokensStore tokensStore

property bool isDiscordImport // creating new or importing from discord?
property bool isEdit: false
Expand Down Expand Up @@ -840,6 +842,9 @@ StatusStackModal {
permissionsModel: d.channelEditModel.channelPermissionsModel
assetsModel: root.assetsModel
collectiblesModel: root.collectiblesModel

getTokenByKeyOrGroupKeyFromAllTokens: root.tokensStore.getTokenByKeyOrGroupKeyFromAllTokens

viewOnlyCanAddReaction: root.viewOnlyCanAddReaction
channelsModel: d.channelEditModel.liveChannelsModel
communityDetails: d.communityDetails
Expand Down Expand Up @@ -936,6 +941,8 @@ StatusStackModal {
showChannelSelector: false
ensCommunityPermissionsEnabled: root.ensCommunityPermissionsEnabled

getTokenByKeyOrGroupKeyFromAllTokens: root.tokensStore.getTokenByKeyOrGroupKeyFromAllTokens

readonly property string nextButtonText: !!currentItem.permissionKeyToEdit ?
qsTr("Update permission") : qsTr("Create permission")
readonly property string stackTitleText: !!currentItem.permissionKeyToEdit ?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -562,6 +562,7 @@ Item {
id: createChannelPopup
CreateChannelPopup {
communitiesStore: root.communitiesStore
tokensStore: root.walletAssetsStore.walletTokensStore
assetsModel: root.store.assetsModel
collectiblesModel: root.store.collectiblesModel
ensCommunityPermissionsEnabled: root.ensCommunityPermissionsEnabled
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,8 @@ StatusSectionLayout {
collectiblesModel: rootStore.collectiblesModel
channelsModel: rootStore.chatCommunitySectionModule.model

getTokenByKeyOrGroupKeyFromAllTokens: root.tokensStore.getTokenByKeyOrGroupKeyFromAllTokens

ensCommunityPermissionsEnabled: root.ensCommunityPermissionsEnabled

communityDetails: d.communityDetails
Expand Down
18 changes: 17 additions & 1 deletion ui/app/AppLayouts/Communities/views/HoldingsSelectionModel.qml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,12 @@ import StatusQ.Core.Theme
import utils

SortFilterProxyModel {
id: root

property var assetsModel
property var collectiblesModel
// Returns token that matches provided key (key can be token or group key). Use it as a last option (may affect app performances, because it fetches all tokens from stautsgo).
property var getTokenByKeyOrGroupKeyFromAllTokens: function(key){ return {}}

readonly property ModelChangeTracker _assetsChanges: ModelChangeTracker {
model: assetsModel
Expand Down Expand Up @@ -45,6 +49,10 @@ SortFilterProxyModel {
: collectiblesModel

let item = PermissionsHelpers.getTokenByKey(model, collectibles, key)
if (Object.keys(item).length === 0) {
item = root.getTokenByKeyOrGroupKeyFromAllTokens(key)
}

let name = getName(type, item, key)
const decimals = getDecimals(type, item)

Expand Down Expand Up @@ -75,7 +83,15 @@ SortFilterProxyModel {
const model = type === Constants.TokenType.ERC20
? assetsModel : collectiblesModel

return PermissionsHelpers.getTokenIconByKey(model, collectibles, key)
let icon = PermissionsHelpers.getTokenIconByKey(model, collectibles, key)
if (Constants.isDefaultTokenIcon(icon)) {
const item = root.getTokenByKeyOrGroupKeyFromAllTokens(key)
if (!!item){
icon = item.logoUri
}
}

return icon
}

expression: {
Expand Down
4 changes: 4 additions & 0 deletions ui/app/AppLayouts/Communities/views/PermissionsView.qml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ ColumnLayout {
required property var collectiblesModel
required property var channelsModel

// Returns token that matches provided key (key can be token or group key). Use it as a last option (may affect app performances, because it fetches all tokens from stautsgo).
property var getTokenByKeyOrGroupKeyFromAllTokens: function(key){ return {}}

// id, name, image, color, owner, admin properties expected
required property QtObject communityDetails

Expand Down Expand Up @@ -115,6 +118,7 @@ ColumnLayout {
sourceModel: model.holdingsListModel
assetsModel: root.assetsModel
collectiblesModel: root.collectiblesModel
getTokenByKeyOrGroupKeyFromAllTokens: root.getTokenByKeyOrGroupKeyFromAllTokens
}

permissionType: model.permissionType
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ QObject {
readonly property string key: model.symbol

readonly property url icon:
model.imageUrl || model.mediaUrl || Assets.png("tokens/DEFAULT-TOKEN")
model.imageUrl || model.mediaUrl || Assets.png(Constants.defaultTokenIcon)

SortFilterProxyModel { /* 1 */
id: ownershipFiltered
Expand Down
2 changes: 1 addition & 1 deletion ui/app/AppLayouts/stores/RootStore.qml
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ QtObject {

proxyRoles: FastExpressionRole {
function collectibleIcon(icon) {
return !!icon ? icon : Assets.png("tokens/DEFAULT-TOKEN")
return !!icon ? icon : Assets.png(Constants.defaultTokenIcon)
}
name: "iconSource"
expression: collectibleIcon(model.icon)
Expand Down
6 changes: 4 additions & 2 deletions ui/imports/utils/Constants.qml
Original file line number Diff line number Diff line change
Expand Up @@ -763,6 +763,8 @@ QtObject {
Retrying = 2
}

readonly property string defaultTokenIcon: "tokens/DEFAULT-TOKEN"

readonly property string dummyText: "Dummy"

// Transaction states
Expand Down Expand Up @@ -1232,12 +1234,12 @@ QtObject {
return Assets.png("tokens/" + tmpSymbol)

if (useDefault)
return Assets.png("tokens/DEFAULT-TOKEN")
return Assets.png(root.defaultTokenIcon)
return ""
}

function isDefaultTokenIcon(url) {
return url.indexOf("DEFAULT-TOKEN") !== -1
return url.indexOf(root.defaultTokenIcon) !== -1
}

enum RecipientAddressObjectType {
Expand Down