feat(@settings): Add feature flag for multi network

This commit is contained in:
Anthony Laibe 2022-02-08 10:34:45 +01:00 committed by Anthony Laibe
parent ba7a6d5d34
commit d9212565b7
3 changed files with 35 additions and 0 deletions

View File

@ -24,6 +24,8 @@ const LSS_KEY_EXPAND_USERS_LIST* = "expandUsersList"
const DEFAULT_EXPAND_USERS_LIST = false const DEFAULT_EXPAND_USERS_LIST = false
const LSS_KEY_IS_GIF_WIDGET_ENABLED* = "isGifWidgetEnabled" const LSS_KEY_IS_GIF_WIDGET_ENABLED* = "isGifWidgetEnabled"
const DEFAULT_IS_GIF_WIDGET_ENABLED = false const DEFAULT_IS_GIF_WIDGET_ENABLED = false
const LSS_KEY_IS_MULTI_NETWORK_ENABLED* = "isMultiNetworkEnabled"
const DEFAULT_IS_MULTI_NETWORK_ENABLED = false
const LSS_KEY_IS_TENOR_WARNING_ACCEPTED* = "isTenorWarningAccepted" const LSS_KEY_IS_TENOR_WARNING_ACCEPTED* = "isTenorWarningAccepted"
const DEFAULT_IS_TENOR_WARNING_ACCEPTED = false const DEFAULT_IS_TENOR_WARNING_ACCEPTED = false
const LSS_KEY_DISPLAY_CHAT_IMAGES* = "displayChatImages" const LSS_KEY_DISPLAY_CHAT_IMAGES* = "displayChatImages"
@ -315,6 +317,18 @@ QtObject:
write = setIsGifWidgetEnabled write = setIsGifWidgetEnabled
notify = isGifWidgetEnabledChanged notify = isGifWidgetEnabledChanged
proc isMultiNetworkEnabledChanged*(self: LocalAccountSensitiveSettings) {.signal.}
proc getIsMultiNetworkEnabled*(self: LocalAccountSensitiveSettings): bool {.slot.} =
getSettingsProp[bool](self, LSS_KEY_IS_MULTI_NETWORK_ENABLED, newQVariant(DEFAULT_IS_MULTI_NETWORK_ENABLED))
proc setIsMultiNetworkEnabled*(self: LocalAccountSensitiveSettings, value: bool) {.slot.} =
setSettingsProp(self, LSS_KEY_IS_MULTI_NETWORK_ENABLED, newQVariant(value)):
self.isMultiNetworkEnabledChanged()
QtProperty[bool] isMultiNetworkEnabled:
read = getIsMultiNetworkEnabled
write = setIsMultiNetworkEnabled
notify = isMultiNetworkEnabledChanged
proc isTenorWarningAcceptedChanged*(self: LocalAccountSensitiveSettings) {.signal.} proc isTenorWarningAcceptedChanged*(self: LocalAccountSensitiveSettings) {.signal.}
proc getIsTenorWarningAccepted*(self: LocalAccountSensitiveSettings): bool {.slot.} = proc getIsTenorWarningAccepted*(self: LocalAccountSensitiveSettings): bool {.slot.} =
@ -842,6 +856,7 @@ QtObject:
of LSS_KEY_SHOW_ONLINE_USERS: self.showOnlineUsersChanged() of LSS_KEY_SHOW_ONLINE_USERS: self.showOnlineUsersChanged()
of LSS_KEY_EXPAND_USERS_LIST: self.expandUsersListChanged() of LSS_KEY_EXPAND_USERS_LIST: self.expandUsersListChanged()
of LSS_KEY_IS_GIF_WIDGET_ENABLED: self.isGifWidgetEnabledChanged() of LSS_KEY_IS_GIF_WIDGET_ENABLED: self.isGifWidgetEnabledChanged()
of LSS_KEY_IS_MULTI_NETWORK_ENABLED: self.isMultiNetworkEnabledChanged()
of LSS_KEY_IS_TENOR_WARNING_ACCEPTED: self.isTenorWarningAcceptedChanged() of LSS_KEY_IS_TENOR_WARNING_ACCEPTED: self.isTenorWarningAcceptedChanged()
of LSS_KEY_DISPLAY_CHAT_IMAGES: self.displayChatImagesChanged() of LSS_KEY_DISPLAY_CHAT_IMAGES: self.displayChatImagesChanged()
of LSS_KEY_RECENT_EMOJIS: self.recentEmojisChanged() of LSS_KEY_RECENT_EMOJIS: self.recentEmojisChanged()

View File

@ -30,6 +30,7 @@ QtObject {
readonly property string onlineUsers: "onlineUsers" readonly property string onlineUsers: "onlineUsers"
readonly property string gifWidget: "gifWidget" readonly property string gifWidget: "gifWidget"
readonly property string keycard: "keycard" readonly property string keycard: "keycard"
readonly property string multiNetwork: "multiNetwork"
} }
function setGlobalNetworkId() { function setGlobalNetworkId() {
@ -140,5 +141,8 @@ QtObject {
else if (feature === experimentalFeatures.keycard) { else if (feature === experimentalFeatures.keycard) {
localAccountSettings.isKeycardEnabled = !localAccountSettings.isKeycardEnabled localAccountSettings.isKeycardEnabled = !localAccountSettings.isKeycardEnabled
} }
else if (feature === experimentalFeatures.multiNetwork) {
localAccountSensitiveSettings.isMultiNetworkEnabled = !localAccountSensitiveSettings.isMultiNetworkEnabled
}
} }
} }

View File

@ -43,6 +43,7 @@ ScrollView {
StatusSettingsLineButton { StatusSettingsLineButton {
//% "Network" //% "Network"
text: qsTrId("network") text: qsTrId("network")
visible: !localAccountSensitiveSettings.isMultiNetworkEnabled
currentValue: root.advancedStore.currentNetworkName currentValue: root.advancedStore.currentNetworkName
onClicked: networksModal.open() onClicked: networksModal.open()
} }
@ -210,6 +211,21 @@ ScrollView {
} }
} }
// TODO: replace with StatusQ component
StatusSettingsLineButton {
text: qsTr("Multi network")
isSwitch: true
switchChecked: localAccountSensitiveSettings.isMultiNetworkEnabled
onClicked: {
if (localAccountSensitiveSettings.isMultiNetworkEnabled) {
root.advancedStore.toggleExperimentalFeature(root.advancedStore.experimentalFeatures.multiNetwork)
} else {
confirmationPopup.experimentalFeature = root.advancedStore.experimentalFeatures.multiNetwork
confirmationPopup.open()
}
}
}
// TODO: replace with StatusQ component // TODO: replace with StatusQ component
StatusSettingsLineButton { StatusSettingsLineButton {
//% "Keycard" //% "Keycard"