mirror of
https://github.com/status-im/status-mobile.git
synced 2025-01-26 08:30:01 +00:00
sending images over waku
This commit is contained in:
parent
60d5815bde
commit
91bcd0c861
@ -20,7 +20,7 @@
|
||||
[status-im.chat.models.message-seen :as message-seen]
|
||||
[status-im.chat.models.loading :as loading]
|
||||
[status-im.utils.image-processing :as image-processing]
|
||||
[status-im.ipfs.core :as ipfs]))
|
||||
[taoensso.timbre :as log]))
|
||||
|
||||
(defn- get-chat [cofx chat-id]
|
||||
(get-in cofx [:db :chats chat-id]))
|
||||
@ -322,20 +322,10 @@
|
||||
400 400
|
||||
(fn [resized-image]
|
||||
(re-frame/dispatch [:chat.ui/set-chat-ui-props {:send-image (aget resized-image "path")}]))
|
||||
#()))
|
||||
"any")))
|
||||
#(log/error "could not resize image" %)))
|
||||
"photo")))
|
||||
|
||||
(fx/defn chat-open-image-picker
|
||||
{:events [:chat.ui/open-image-picker]}
|
||||
[cofx]
|
||||
{:chat-open-image-picker nil})
|
||||
|
||||
(fx/defn send-image
|
||||
{:events [:chat.ui/send-image]}
|
||||
[{:keys [db] :as cofx} send-image]
|
||||
(fx/merge cofx
|
||||
{:db (set-chat-ui-props db {:send-image-loading? true})}
|
||||
(ipfs/add {:value #js {:uri send-image :name "image"}
|
||||
:opts {:headers {"Content-Type" "multipart/form-data"}}
|
||||
:on-failure #(re-frame/dispatch [:chat.ui/set-chat-ui-props {:send-image-loading? false}])
|
||||
:on-success #(re-frame/dispatch [:chat-image-added-to-ipfs %])})))
|
@ -112,6 +112,18 @@
|
||||
(chat-input-clear :input-ref)
|
||||
(process-cooldown)))))
|
||||
|
||||
(fx/defn send-image
|
||||
{:events [:chat.ui/send-image]}
|
||||
[{{:keys [current-chat-id] :as db} :db :as cofx} send-image]
|
||||
(println "SENDING" send-image)
|
||||
(fx/merge cofx
|
||||
{:db (chat/set-chat-ui-props db {:send-image-loading? true})}
|
||||
(when-not (string/blank? send-image)
|
||||
(chat.message/send-message {:chat-id current-chat-id
|
||||
:content-type constants/content-type-image
|
||||
:image-path send-image
|
||||
:text "Update to latest version to see a nice image here!"}))))
|
||||
|
||||
(fx/defn send-sticker-fx
|
||||
[{:keys [db] :as cofx} {:keys [hash pack]} current-chat-id]
|
||||
(when-not (string/blank? hash)
|
||||
@ -121,14 +133,6 @@
|
||||
:pack pack}
|
||||
:text "Update to latest version to see a nice sticker here!"})))
|
||||
|
||||
(fx/defn send-image
|
||||
[{:keys [db] :as cofx} hash]
|
||||
(when-not (string/blank? hash)
|
||||
(chat.message/send-message cofx {:chat-id (:current-chat-id db)
|
||||
:content-type constants/content-type-image
|
||||
:content {:chat-id (:current-chat-id db)
|
||||
:hash hash}})))
|
||||
|
||||
(fx/defn send-current-message
|
||||
"Sends message from current chat input"
|
||||
[{{:keys [current-chat-id] :as db} :db :as cofx}]
|
||||
@ -141,13 +145,6 @@
|
||||
;;TODO: should be implemented on status-go side
|
||||
;;see https://github.com/status-im/team-core/blob/6c3d67d8e8bd8500abe52dab06a59e976ec942d2/rfc-001.md#status-gostatus-react-interface
|
||||
|
||||
(fx/defn chat-image-added-to-ipfs
|
||||
{:events [:chat-image-added-to-ipfs]}
|
||||
[{:keys [db] :as cofx} {:keys [hash]}]
|
||||
(fx/merge cofx
|
||||
{:db (chat/set-chat-ui-props db {:send-image-loading? false :show-image? nil :send-image nil})}
|
||||
(send-image hash)))
|
||||
|
||||
;; effects
|
||||
|
||||
(re-frame/reg-fx
|
||||
|
@ -31,6 +31,7 @@
|
||||
:commandState :command-state})
|
||||
(assoc :content {:chat-id (:chatId message)
|
||||
:text (:text message)
|
||||
:image (:image message)
|
||||
:sticker (:sticker message)
|
||||
:ens-name (:ensName message)
|
||||
:line-count (:lineCount message)
|
||||
@ -38,7 +39,7 @@
|
||||
:rtl? (:rtl message)
|
||||
:response-to (:responseTo message)}
|
||||
:outgoing (boolean (:outgoingStatus message)))
|
||||
(dissoc :ensName :chatId :text :rtl :responseTo :sticker :lineCount :parsedText)))
|
||||
(dissoc :ensName :chatId :text :rtl :responseTo :image :sticker :lineCount :parsedText)))
|
||||
|
||||
(defn update-outgoing-status-rpc [waku-enabled? message-id status]
|
||||
{::json-rpc/call [{:method (json-rpc/call-ext-method waku-enabled? "updateMessageOutgoingStatus")
|
||||
|
@ -123,7 +123,7 @@
|
||||
{:Enabled true
|
||||
:BloomFilterMode waku-bloom-filter-mode
|
||||
:LightClient true
|
||||
:MinimumPoW 0.001}
|
||||
:MinimumPoW 0.000001}
|
||||
:ShhextConfig
|
||||
{:BackupDisabledDataDir (utils.platform/no-backup-directory)
|
||||
:InstallationID installation-id
|
||||
|
@ -9,6 +9,7 @@
|
||||
text
|
||||
response-to
|
||||
ens-name
|
||||
image-path
|
||||
message-type
|
||||
sticker
|
||||
content-type]
|
||||
@ -20,6 +21,7 @@
|
||||
:text text
|
||||
:responseTo response-to
|
||||
:ensName ens-name
|
||||
:imagePath image-path
|
||||
:sticker sticker
|
||||
:contentType content-type}]
|
||||
:on-success
|
||||
|
@ -297,5 +297,5 @@
|
||||
:source {:uri (contenthash/url (-> content :sticker :hash))}}]
|
||||
(if (= content-type constants/content-type-image)
|
||||
[react/image {:style {:margin-vertical 10 :width 140 :height 140 :border-radius 8}
|
||||
:source {:uri (str "https://ipfs.infura.io/ipfs/" (:hash content))}}]
|
||||
:source {:uri (:image content)}}]
|
||||
[unknown-content-type message])))))]])))
|
||||
|
@ -51,6 +51,6 @@
|
||||
string/upper-case))
|
||||
(def fleet (get-config :FLEET "eth.staging"))
|
||||
(def default-network (get-config :DEFAULT_NETWORK))
|
||||
(def pow-target (js/parseFloat (get-config :POW_TARGET "0.002")))
|
||||
(def pow-target (js/parseFloat (get-config :POW_TARGET "0.0001")))
|
||||
(def pow-time (js/parseInt (get-config :POW_TIME "1")))
|
||||
(def max-installations 2)
|
||||
|
@ -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.53.2",
|
||||
"commit-sha1": "ee0a83fdc4a19f70fa8d08347ef67c0ca3d67f1e",
|
||||
"src-sha256": "1jv7cw6a41czhslmqxbqjw2alv9yb0ddpbxyin2l0kdpnxvph965"
|
||||
"version": "feature/content-type-images",
|
||||
"commit-sha1": "514923e84df1426a85cac1f2470f064820ab6d4b",
|
||||
"src-sha256": "03k55hn20ijr98j80p20j38i2lpl6f3dib70b3d83zjcz00wpgqh"
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user