[#11643] Display profile picture only of users I have added to contacts

Signed-off-by: andrey <motor4ik@gmail.com>
This commit is contained in:
andrey 2021-01-15 11:56:39 +01:00 committed by Andrea Maria Piana
parent d8be02d9a9
commit d0e40699b9
No known key found for this signature in database
GPG Key ID: AA6CCA6DE0E06424
9 changed files with 109 additions and 25 deletions

View File

@ -57,6 +57,10 @@
(def command-state-transaction-pending 6)
(def command-state-transaction-sent 7)
(def profile-pictures-visibility-contacts-only 1)
(def profile-pictures-visibility-everyone 2)
(def profile-pictures-visibility-none 3)
(def min-password-length 6)
(def max-group-chat-participants 20)
(def default-number-of-messages 20)

View File

@ -4,7 +4,8 @@
[status-im.ethereum.core :as ethereum]
[status-im.utils.gfycat.core :as gfycat]
[status-im.utils.identicon :as identicon]
[status-im.multiaccounts.core :as multiaccounts]))
[status-im.multiaccounts.core :as multiaccounts]
[status-im.constants :as constants]))
(defn public-key->new-contact [public-key]
(let [alias (gfycat/generate-gfy public-key)]
@ -54,7 +55,7 @@
[members admins contacts {:keys [public-key] :as current-account}]
(let [current-contact (some->
current-account
(select-keys [:name :preferred-name :public-key :identicon])
(select-keys [:name :preferred-name :public-key :identicon :images])
(clojure.set/rename-keys {:name :alias
:preferred-name :name}))
all-contacts (cond-> contacts
@ -130,19 +131,26 @@
:added? (contains? system-tags :contact/added)))))
(defn enrich-contact
[{:keys [system-tags] :as contact}]
(-> contact
(dissoc :ens-verified-at :ens-verification-retries)
(assoc :pending? (pending? contact)
:blocked? (blocked? contact)
:active? (active? contact)
:added? (contains? system-tags :contact/added))
(multiaccounts/contact-with-names)))
([contact] (enrich-contact contact nil nil))
([{:keys [system-tags public-key] :as contact} setting own-public-key]
(let [added? (contains? system-tags :contact/added)]
(cond-> (-> contact
(dissoc :ens-verified-at :ens-verification-retries)
(assoc :pending? (pending? contact)
:blocked? (blocked? contact)
:active? (active? contact)
:added? added?)
(multiaccounts/contact-with-names))
(and setting (not= public-key own-public-key)
(or (= setting constants/profile-pictures-visibility-none)
(and (= setting constants/profile-pictures-visibility-contacts-only)
(not added?))))
(dissoc :images)))))
(defn enrich-contacts
[contacts]
[contacts profile-pictures-visibility own-public-key]
(reduce-kv (fn [acc public-key contact]
(assoc acc public-key (enrich-contact contact)))
(assoc acc public-key (enrich-contact contact profile-pictures-visibility own-public-key)))
{}
contacts))

View File

@ -160,6 +160,11 @@
{::switch-theme theme}
(multiaccounts.update/multiaccount-update :appearance theme {})))
(fx/defn switch-appearance-profile
{:events [:multiaccounts.ui/appearance-profile-switched]}
[cofx id]
(multiaccounts.update/multiaccount-update cofx :profile-pictures-visibility id {}))
(defn clean-path [path]
(if path
(string/replace-first path #"file://" "")

View File

@ -894,7 +894,7 @@
(re-frame/reg-sub
:chats/photo-path
:<- [::contacts]
:<- [:contacts/contacts]
:<- [:multiaccount]
(fn [[contacts multiaccount] [_ id identicon]]
(let [contact (or (get contacts id)
@ -1785,11 +1785,19 @@
(fn [[chat contacts] [_ query-fn]]
(contact.db/query-chat-contacts chat contacts query-fn)))
(re-frame/reg-sub
::profile-pictures-visibility
:<- [:multiaccount]
(fn [multiaccount]
(get multiaccount :profile-pictures-visibility)))
(re-frame/reg-sub
:contacts/contacts
:<- [::contacts]
(fn [contacts]
(contact.db/enrich-contacts contacts)))
:<- [::profile-pictures-visibility]
:<- [:multiaccount/public-key]
(fn [[contacts profile-pictures-visibility public-key]]
(contact.db/enrich-contacts contacts profile-pictures-visibility public-key)))
(re-frame/reg-sub
:contacts/active
@ -2081,7 +2089,7 @@
(re-frame/reg-sub
:search/filtered-chats
:<- [:chats/active-chats]
:<- [::contacts]
:<- [:contacts/contacts]
:<- [:search/home-filter]
(fn [[chats contacts search-filter]]
;; Short-circuit if search-filter is empty

View File

@ -6,7 +6,12 @@
[status-im.react-native.resources :as resources]
[quo.core :as quo]
[status-im.ui.components.colors :as colors]
[status-im.i18n :as i18n]))
[status-im.i18n :as i18n]
[status-im.constants :as constants]))
(def titles {constants/profile-pictures-visibility-contacts-only (i18n/label :t/recent-recipients)
constants/profile-pictures-visibility-everyone (i18n/label :t/everyone)
constants/profile-pictures-visibility-none (i18n/label :t/none)})
(defn button [label icon theme selected?]
[react/touchable-highlight
@ -19,12 +24,36 @@
(i18n/label label)]]])
(views/defview appearance []
(views/letsubs [{:keys [appearance]} [:multiaccount]]
(views/letsubs [{:keys [appearance profile-pictures-visibility]} [:multiaccount]]
[react/view {:flex 1}
[topbar/topbar {:title (i18n/label :t/appearance)}]
[quo/list-header (i18n/label :t/preference)]
[react/view {:flex-direction :row :flex 1 :padding-horizontal 8
:justify-content :space-between :margin-top 16}
[react/view {:flex-direction :row :padding-horizontal 8
:justify-content :space-between :margin-vertical 16}
[button :t/light :theme-light 1 (= 1 appearance)]
[button :t/dark :theme-dark 2 (= 2 appearance)]
[button :t/system :theme-system 0 (= 0 appearance)]]]))
[button :t/system :theme-system 0 (= 0 appearance)]]
[quo/list-header (i18n/label :t/chat)]
[quo/list-item
{:title (i18n/label :t/show-profile-pictures)
:accessibility-label :show-profile-pictures
:accessory :text
:accessory-text (get titles profile-pictures-visibility)
:on-press #(re-frame/dispatch [:navigate-to :appearance-profile-pic])
:chevron true}]]))
(defn radio-item [id value]
[quo/list-item
{:active (= value id)
:accessory :radio
:title (get titles id)
:on-press #(re-frame/dispatch [:multiaccounts.ui/appearance-profile-switched id])}])
(views/defview profile-pic []
(views/letsubs [{:keys [profile-pictures-visibility]} [:multiaccount]]
[react/view {:flex 1}
[topbar/topbar {:title (i18n/label :t/show-profile-pictures)}]
[react/view {:margin-top 8}
[radio-item constants/profile-pictures-visibility-everyone profile-pictures-visibility]
[radio-item constants/profile-pictures-visibility-contacts-only profile-pictures-visibility]
[radio-item constants/profile-pictures-visibility-none profile-pictures-visibility]]]))

View File

@ -83,6 +83,8 @@
:component privacy-and-security/privacy-and-security}
{:name :appearance
:component appearance/appearance}
{:name :appearance-profile-pic
:component appearance/profile-pic}
{:name :notifications
:component notifications-settings/notifications-settings}
{:name :notifications-servers

View File

@ -78,6 +78,7 @@
:wallet/visible-tokens {:mainnet #{:SNT}}
:currency :usd
:appearance 0
:profile-pictures-visibility 1
:log-level log-level
:webview-allow-permission-requests? false
:link-previews-enabled-sites #{}

View File

@ -2,7 +2,7 @@
"_comment": "DO NOT EDIT THIS FILE BY HAND. USE 'scripts/update-status-go.sh <tag>' instead",
"owner": "status-im",
"repo": "status-go",
"version": "v0.67.2",
"commit-sha1": "e1465ca8900a37becf3dd5da5606fe10970d961a",
"src-sha256": "1sxjawn40ppj7mnzmxbv8320wcdd1lj0jyr8p0bzn6gj9nz8j9lf"
"version": "v0.67.2+hotfix.1",
"commit-sha1": "af8a9f1e75f58a6ebcdddaafc1237098d4074570",
"src-sha256": "1l4xdxcbahv0c1vch7p45wrx89jm74ym38mh6scj7l2g0b6xmb0b"
}

View File

@ -1373,5 +1373,32 @@
"connect-wallet": "Connect wallet",
"open-chat": "Open chat",
"favourite-description": "Your favourite websites will appear here",
"transfers-fetching-failure": "Transfers history could not be updated. Check your connection and pull down to try again"
"transfers-fetching-failure": "Transfers history could not be updated. Check your connection and pull down to try again",
"move-and-reset": "Move and Reset",
"move-keystore-file-to-keycard": "Move keystore file to keycard?",
"database-reset-warning": "Database will be reset. Chats, contacts and settings will be deleted",
"empty-keycard-required": "Requires an empty Keycard",
"current": "Current",
"choose-storage": "Choose storage",
"choose-new-location-for-keystore": "Choose a new location to save your keystore file",
"get-a-keycard": "Get a Keycard",
"keycard-upsell-subtitle": "Your portable, easy to use hardware wallet",
"actions": "Actions",
"move-keystore-file": "Move keystore file",
"select-new-location-for-keys": "Select a new location to save your private key(s)",
"reset-database": "Reset database",
"reset-database-warning": "Delete chats, contacts and settings. Required when youve lost your password",
"key-managment": "Key management",
"choose-actions": "Choose actions",
"master-account": "Master account",
"back-up": "Back up",
"key-on-device": "Private key is saved on this device",
"seed-key-uid-mismatch": "Seed doesn't match",
"seed-key-uid-mismatch-desc-1": "The seed phrase you entered does not match {{multiaccount-name}}",
"seed-key-uid-mismatch-desc-2": "To manage keys for this account verify your seed phrase and try again.",
"recover-with-seed-phrase": "Recover with seed phrase",
"transfer-ma-unknown-error-desc-1": "It looks like your multiaccount was not deleted. Database may have been reset",
"transfer-ma-unknown-error-desc-2": "Please check your account list and try again. If the account is not listed go to Access existing keys to recover with seed phrase",
"everyone": "Everyone",
"show-profile-pictures": "Show profile pictures of"
}