Skip to content
This repository has been archived by the owner on Nov 10, 2018. It is now read-only.

Commit

Permalink
fixes #1
Browse files Browse the repository at this point in the history
  • Loading branch information
flexsurfer committed Jan 8, 2018
1 parent a90dba0 commit 0cf4522
Show file tree
Hide file tree
Showing 29 changed files with 228 additions and 100 deletions.
Binary file added app/dev/resources/notif01.mp3
Binary file not shown.
Binary file added app/dev/resources/notif02.mp3
Binary file not shown.
Binary file added app/dev/resources/notif03.mp3
Binary file not shown.
Binary file added app/dev/resources/notif04.mp3
Binary file not shown.
Binary file added app/dev/resources/notif05.mp3
Binary file not shown.
Binary file added app/dev/resources/notif06.mp3
Binary file not shown.
Binary file added app/dev/resources/notif07.mp3
Binary file not shown.
Binary file added app/dev/resources/notif08.mp3
Binary file not shown.
2 changes: 1 addition & 1 deletion app/prod/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "status-desktop",
"name": "Status",
"version": "0.0.1",
"main": "js/main.js"
}
Binary file added app/prod/resources/notif01.mp3
Binary file not shown.
Binary file added app/prod/resources/notif02.mp3
Binary file not shown.
Binary file added app/prod/resources/notif03.mp3
Binary file not shown.
Binary file added app/prod/resources/notif04.mp3
Binary file not shown.
Binary file added app/prod/resources/notif05.mp3
Binary file not shown.
Binary file added app/prod/resources/notif06.mp3
Binary file not shown.
Binary file added app/prod/resources/notif07.mp3
Binary file not shown.
Binary file added app/prod/resources/notif08.mp3
Binary file not shown.
30 changes: 24 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 8 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,18 @@
"version": "0.0.1",
"description": "Status Desktop (React Native Web and Electron)",
"dependencies": {
"react": "16.0.0",
"react-dom": "16.0.0",
"react-native-web": "0.1.12",
"awesome-phonenumber": "^1.0.13",
"chance": "1.0.4",
"eccjs": "0.3.1",
"emojilib": "^2.2.1",
"homoglyph-finder": "^1.1.1",
"identicon.js": "github:status-im/identicon.js",
"awesome-phonenumber": "^1.0.13",
"emojilib": "^2.2.1",
"web3": "github:status-im/web3.js#status-develop",
"status-nodejs": "git+https://github.com/status-im/status-nodejs.git"
"react": "16.0.0",
"react-dom": "16.0.0",
"react-native-hyperlink": "git+https://github.com/flexsurfer/react-native-hyperlink.git",
"react-native-web": "0.1.12",
"status-nodejs": "git+https://github.com/status-im/status-nodejs.git",
"web3": "github:status-im/web3.js#status-develop"
},
"license": "MPL-2.0",
"repository": "https://github.com/status-im/status-electron"
Expand Down
10 changes: 5 additions & 5 deletions project.clj
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@
["cljsbuild" "once" "prod-front"]]

;; electron packager for production
"desktop-app-osx" ["shell" "electron-packager" "./app/prod" "status-desktop" "--platform=darwin" "--arch=x64" "--electron-version=1.8.2-beta.3" "--extraResource=./node_modules" "--icon=assets/icon1024.icns"]
"desktop-app-linux" ["shell" "electron-packager" "./app/prod" "status-desktop" "--platform=linux" "--arch=x64" "--electron-version=1.8.2-beta.3" "--extraResource=./node_modules" "--icon=assets/icon1024.png"]
"desktop-app-osx" ["shell" "electron-packager" "./app/prod" "Status" "--platform=darwin" "--arch=x64" "--electron-version=1.8.2-beta.3" "--extraResource=./node_modules" "--icon=assets/icon1024.icns"]
"desktop-app-linux" ["shell" "electron-packager" "./app/prod" "Status" "--platform=linux" "--arch=x64" "--electron-version=1.8.2-beta.3" "--extraResource=./node_modules" "--icon=assets/icon1024.png"]

"desktop-app-store" ["shell" "electron-packager" "./app/prod" "status-desktop" "--platform=mas" "--arch=x64" "--electron-version=1.8.2-beta.3" "--extraResource=./node_modules"]
"desktop-app-win64" ["shell" "cmd.exe" "/c" "electron-packager" "./app/prod" "status-desktop" "--platform=win32" "--arch=x64" "--electron-version=1.8.2-beta.3" "--extraResource=./node_modules"]
"desktop-app-win32" ["shell" "cmd.exe" "/c" "electron-packager" "./app/prod" "status-desktop" "--platform=win32" "--arch=ia32" "--electron-version=1.8.2-beta.3" "--extraResource=./node_modules"]}
"desktop-app-store" ["shell" "electron-packager" "./app/prod" "Status" "--platform=mas" "--arch=x64" "--electron-version=1.8.2-beta.3" "--extraResource=./node_modules"]
"desktop-app-win64" ["shell" "cmd.exe" "/c" "electron-packager" "./app/prod" "Status" "--platform=win32" "--arch=x64" "--electron-version=1.8.2-beta.3" "--extraResource=./node_modules"]
"desktop-app-win32" ["shell" "cmd.exe" "/c" "electron-packager" "./app/prod" "Status" "--platform=win32" "--arch=ia32" "--electron-version=1.8.2-beta.3" "--extraResource=./node_modules"]}

:hooks [leiningen.cljsbuild]
:cljsbuild {:builds {:dev-main {:source-paths ["src"]
Expand Down
9 changes: 5 additions & 4 deletions src/status_desktop/core.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
(.on app "ready"
(fn []

(reset! *win* (BrowserWindow. (clj->js {:width 1200 :height 800 :icon (.resolve path (js* "__dirname") "../status.icns")})))
(reset! *win* (BrowserWindow. (clj->js {:width 1200 :height 800})))

;; when no optimize comment out
(.loadURL @*win* (str "file://" (.resolve path (js* "__dirname") "../index.html")))
Expand All @@ -50,14 +50,15 @@

(.on ipcMain "StartNode"
(fn [event config]
(let [config (.GenerateConfig status-go (.resolve path (js* "__dirname") "../ethereum") 3 0)
(let [app-path (.getPath app "userData")
config (.GenerateConfig status-go (str app-path "/ethereum") 3 0)
config' (.parse js/JSON config)
_ (set! (.-LogLevel config') "INFO")
_ (set! (.-LogFile config') (.resolve path (js* "__dirname") "../node.log"))
_ (set! (.-LogFile config') (str app-path "/node.log"))
_ (set! (.-Enabled (.-UpstreamConfig config')) true)
config'' (.stringify js/JSON config')
res (.StartNode status-go config'')]
(.log js/console (str "Node started at " (.resolve path (js* "__dirname") "../ethereum")))
(.log js/console (str "Node started at " (str app-path "/ethereum")))
(set! (.-returnValue event) (str "Config " config'' " Node result: " res)))))

(.on ipcMain "CreateAccount"
Expand Down
2 changes: 1 addition & 1 deletion src_front/status_desktop_front/core.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
{ :role "quit"}]})))
(.append menu
(MenuItem.
(clj->js {:label "Status" :submenu [{ :label "Logs" :click #(re-frame/dispatch [:logs]) :accelerator "CmdOrCtrl+L"}]})))
(clj->js {:label "Dev" :submenu [{ :label "Logs" :click #(re-frame/dispatch [:logs]) :accelerator "CmdOrCtrl+L"}]})))
(.setApplicationMenu Menu menu))
(mount-root)
(re-frame/dispatch-sync [:initialize-app]))
Expand Down
18 changes: 14 additions & 4 deletions src_front/status_desktop_front/override/chat.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,21 @@

;;;; DESKTOP

(def audio {:notif01 (js/Audio. (str js/__dirname "/resources/notif01.mp3"))
:notif02 (js/Audio. (str js/__dirname "/resources/notif02.mp3"))
:notif03 (js/Audio. (str js/__dirname "/resources/notif03.mp3"))
:notif04 (js/Audio. (str js/__dirname "/resources/notif04.mp3"))
:notif05 (js/Audio. (str js/__dirname "/resources/notif05.mp3"))
:notif06 (js/Audio. (str js/__dirname "/resources/notif06.mp3"))
:notif07 (js/Audio. (str js/__dirname "/resources/notif07.mp3"))
:notif08 (js/Audio. (str js/__dirname "/resources/notif08.mp3"))})

(re-frame/reg-fx
:send-desktop-notification
(fn [{:keys [content from]}]
(fn [{:keys [content from sound]}]
(when-not (.hasFocus js/document)
(js/Notification. from (clj->js {:body content})))))
(when sound (.play (get audio sound)))
(js/Notification. from (clj->js {:body content :silent true})))))

;;;; old events

Expand Down Expand Up @@ -100,8 +110,8 @@

(re-frame/reg-fx
:update-message
(fn [message]))
;(msg-store/update-message message)))
(fn [message]
(storage/update-message message)))

(re-frame/reg-fx
:save-message
Expand Down
5 changes: 3 additions & 2 deletions src_front/status_desktop_front/override/protocol.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
[status-desktop-front.web3-provider :as web3-provider]
[status-im.protocol.handlers :as protocol.handlers]
[status-im.constants :as constants]
[status-im.utils.handlers :as handlers]))
[status-im.utils.handlers :as handlers]
[status-desktop-front.storage :as storage]))

;;;; COFX

Expand All @@ -15,7 +16,7 @@
(re-frame/reg-cofx
::protocol.handlers/get-chat-groups
(fn [coeffects _]
(assoc coeffects :groups [])))
(assoc coeffects :groups (storage/get-active-group-chats))))

(re-frame/reg-cofx
::protocol.handlers/get-pending-messages
Expand Down
35 changes: 31 additions & 4 deletions src_front/status_desktop_front/storage.cljs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
(ns status-desktop-front.storage
(:require [alandipert.storage-atom :refer [local-storage]]
[status-im.data-store.messages :as data-store.messages]
[status-im.utils.random :as random]))
[status-im.utils.random :as random]
[status-im.constants :as constants]))
;;;; ACCOUNTS

;; I would love to have something similar in status-react instead realm
Expand All @@ -24,7 +25,7 @@
;;;; CONTACTS

(defn save-contact [contact]
(swap! (:contacts @account) assoc (:whisper-identity contact) contact))
(swap! (:contacts @account) update-in (:whisper-identity contact) merge contact))

(defn save-contacts [contacts]
(mapv save-contact contacts))
Expand Down Expand Up @@ -59,6 +60,19 @@
(> timestamp removed-from-at)
(> timestamp added-at))))

(defn- groups [active?]
(filter #(and (:group-chat %) (= (:is-active %) active?)) (get-all-chats)))

(defn get-active-group-chats []
(map (fn [{:keys [chat-id public-key private-key public?]}]
(let [group {:group-id chat-id
:public? public?}]
(if (and public-key private-key)
(assoc group :keypair {:private private-key
:public public-key})
group)))
(groups true)))

;;;; MESSAGE

(defn save-message [{:keys [message-id content] :as message}]
Expand All @@ -69,11 +83,24 @@
:timestamp (random/timestamp)})]
(swap! (:messages @account) assoc message-id message')))

(defn update-message [{:keys [message-id content] :as message}]
(swap! (:messages @account) update-in [message-id] merge message))

(defn get-message-by-id [message-id]
(get @(:messages @account) message-id))

(defn get-messages-by-chat-id [chat-id]
(filter #(= chat-id (:chat-id %)) (vals @(:messages @account))))
(defn get-messages-by-chat-id
([chat-id]
(get-messages-by-chat-id chat-id 0))
([chat-id from]
(let [chats (sort-by :timestamp > (filter #(= chat-id (:chat-id %)) (vals @(:messages @account))))
to (+ from constants/default-number-of-messages)]
(if (< to (count chats))
;;TODO yeah i know i know
(subvec (into [] chats)
from
to)
chats))))

(defn get-last-message [chat-id]
(->> (vals @(:messages @account))
Expand Down
9 changes: 8 additions & 1 deletion src_front/status_desktop_front/ui/components/views.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,14 @@
[status-desktop-front.ui.components.icons :as icons]
[status-im.ui.components.common.styles :as styles]
[status-im.ui.components.action-button.styles :as st]
[status-im.ui.components.styles :as common]))
[status-im.ui.components.styles :as common]
[status-im.ui.components.checkbox.styles :as checkbox.styles]))

(defn checkbox [{:keys [on-value-change checked?]}]
[react/touchable-highlight {:style checkbox.styles/wrapper :on-press #(do (when on-value-change (on-value-change (not checked?))))}
[react/view {:style (checkbox.styles/icon-check-container checked?)}
(when checked?
[icons/icon :icons/ok {:style checkbox.styles/check-icon}])]])

;; TODO copy-pate with minimum modifications of status-react components

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
(ns status-desktop-front.ui.screens.chat.profile.views
(:require [status-desktop-front.react-native-web :as react]
[status-im.ui.screens.profile.styles :as styles]
[status-desktop-front.ui.components.views :as components]
[re-frame.core :as re-frame]
[reagent.core :as reagent]
[status-im.utils.utils :refer [hash-tag?]]
[clojure.string :as string]
[cljs.nodejs :as nodejs])
Expand Down Expand Up @@ -76,6 +78,36 @@
[profile-info-address-item contact]
[profile-info-public-key-item public-key contact]])

(views/defview sound-view [sound label sound-name]
[react/view {:style (merge styles/profile-setting-item {:height 30})}
[react/text {:style styles/profile-setting-text} label]
[react/view {:style {:flex 1}}]
[components/checkbox {:on-value-change
#(re-frame/dispatch [:set-in [:desktop :notifications :sound] sound-name])
:checked?
(= sound sound-name)}]])

(views/defview notifications []
(views/letsubs [notifications-enabled? [:get-in [:desktop :notifications :enabled?]]
sound [:get-in [:desktop :notifications :sound]]]
[react/view
[react/view {:style styles/profile-setting-item}
[react/text {:style styles/profile-setting-text} "Notifications"]
[react/view {:style {:flex 1}}]
[components/checkbox {:on-value-change
#(re-frame/dispatch [:set-in [:desktop :notifications :enabled?] %])
:checked?
notifications-enabled?}]]
[sound-view sound "Sound 1" :notif01]
[sound-view sound "Sound 2" :notif02]
[sound-view sound "Sound 3" :notif03]
[sound-view sound "Sound 4" :notif04]
[sound-view sound "Sound 5" :notif05]
[sound-view sound "Sound 6" :notif06]
[sound-view sound "Sound 7" :notif07]
[sound-view sound "Sound 8" :notif08]]))


(views/defview profile []
(views/letsubs [{:keys [status public-key] :as current-account} [:get-current-account]]
[react/view {:style (merge styles/profile {:background-color :white})}
Expand All @@ -84,4 +116,5 @@
[profile-badge current-account]
[profile-status status true]]
[react/view {:style styles/profile-info-container}
[my-profile-info current-account]]]]))
[my-profile-info current-account]]
[notifications]]]))
Loading

0 comments on commit 0cf4522

Please sign in to comment.