Merge pull request #5284 from status-im/desktop_leftovers
Leftovers from desktop branch since 9th July
This commit is contained in:
commit
ac624ca447
|
@ -1,3 +1,12 @@
|
|||
properties([
|
||||
buildDiscarder(logRotator(
|
||||
numToKeepStr: '2',
|
||||
daysToKeepStr: '3',
|
||||
artifactNumToKeepStr: '2',
|
||||
artifactDaysToKeepStr: '3'
|
||||
))
|
||||
])
|
||||
|
||||
env.LANG="en_US.UTF-8"
|
||||
env.LANGUAGE="en_US.UTF-8"
|
||||
env.LC_ALL="en_US.UTF-8"
|
||||
|
|
|
@ -8,16 +8,16 @@
|
|||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*/
|
||||
|
||||
// #define BUILD_FOR_BUNDLE
|
||||
// #define BUILD_FOR_BUNDLE
|
||||
|
||||
#include <QCommandLineParser>
|
||||
#include <QFile>
|
||||
#include <QGuiApplication>
|
||||
#include <QProcess>
|
||||
#include <QQuickView>
|
||||
#include <QStandardPaths>
|
||||
#include <QTimer>
|
||||
#include <QUrl>
|
||||
#include <QStandardPaths>
|
||||
|
||||
#include "attachedproperties.h"
|
||||
#include "reactitem.h"
|
||||
|
@ -29,6 +29,9 @@ QStringList consoleOutputStrings;
|
|||
bool ubuntuServerStarted = false;
|
||||
#endif
|
||||
|
||||
const int MAIN_WINDOW_WIDTH = 1024;
|
||||
const int MAIN_WINDOW_HEIGHT = 768;
|
||||
|
||||
// TODO: some way to change while running
|
||||
class ReactNativeProperties : public QObject {
|
||||
Q_OBJECT
|
||||
|
@ -141,14 +144,7 @@ int main(int argc, char **argv) {
|
|||
Q_INIT_RESOURCE(react_resources);
|
||||
|
||||
#ifdef BUILD_FOR_BUNDLE
|
||||
QString dataFolder = QDir::homePath() + "/Library/StatusIm/";
|
||||
qInstallMessageHandler(saveMessage);
|
||||
|
||||
QDir dir(dataFolder + "ethereum/mainnet_rpc");
|
||||
if (!dir.exists()) {
|
||||
dir.mkpath(".");
|
||||
}
|
||||
|
||||
runUbuntuServer();
|
||||
#endif
|
||||
|
||||
|
@ -188,6 +184,7 @@ int main(int argc, char **argv) {
|
|||
view.rootContext()->setContextProperty("ReactNativeProperties", rnp);
|
||||
view.setSource(QUrl("qrc:///main.qml"));
|
||||
view.setResizeMode(QQuickView::SizeRootObjectToView);
|
||||
view.resize(MAIN_WINDOW_WIDTH, MAIN_WINDOW_HEIGHT);
|
||||
view.show();
|
||||
|
||||
#ifdef BUILD_FOR_BUNDLE
|
||||
|
@ -202,8 +199,18 @@ int main(int argc, char **argv) {
|
|||
|
||||
#ifdef BUILD_FOR_BUNDLE
|
||||
|
||||
QString getDataStoragePath() {
|
||||
QString dataStoragePath =
|
||||
QStandardPaths::writableLocation(QStandardPaths::AppDataLocation);
|
||||
QDir dir(dataStoragePath);
|
||||
if (!dir.exists()) {
|
||||
dir.mkpath(".");
|
||||
}
|
||||
return dataStoragePath;
|
||||
}
|
||||
|
||||
void writeLogsToFile() {
|
||||
QFile logFile(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + "/StatusIm.log");
|
||||
QFile logFile(getDataStoragePath() + "/StatusIm.log");
|
||||
if (logFile.open(QIODevice::WriteOnly | QIODevice::Append)) {
|
||||
for (QString message : consoleOutputStrings) {
|
||||
logFile.write(message.toStdString().c_str());
|
||||
|
@ -217,6 +224,7 @@ void writeLogsToFile() {
|
|||
|
||||
void runUbuntuServer() {
|
||||
QProcess *process = new QProcess();
|
||||
process->setWorkingDirectory(getDataStoragePath());
|
||||
process->setProgram(QGuiApplication::applicationDirPath() + "/ubuntu-server");
|
||||
QObject::connect(process, &QProcess::errorOccurred,
|
||||
[=](QProcess::ProcessError) {
|
||||
|
|
|
@ -63,35 +63,6 @@ QVariantMap RCTStatus::constantsToExport() {
|
|||
return QVariantMap();
|
||||
}
|
||||
|
||||
void RCTStatus::initJail(QString js, double callbackId) {
|
||||
Q_D(RCTStatus);
|
||||
qDebug() << "call of RCTStatus::initJail with param js:" << " and callback id: " << callbackId;
|
||||
|
||||
InitJail(js.toUtf8().data());
|
||||
|
||||
d->bridge->invokePromiseCallback(callbackId, QVariantList{ "{\"result\":\"\"}" });
|
||||
}
|
||||
|
||||
|
||||
void RCTStatus::parseJail(QString chatId, QString js, double callbackId) {
|
||||
Q_D(RCTStatus);
|
||||
qDebug() << "call of RCTStatus::parseJail with param chatId: " << chatId << " js:" << " and callback id: " << callbackId;
|
||||
|
||||
const char* result = Parse(chatId.toUtf8().data(), js.toUtf8().data());
|
||||
qDebug() << "RCTStatus::parseJail parseJail result: " << result;
|
||||
d->bridge->invokePromiseCallback(callbackId, QVariantList{result});
|
||||
}
|
||||
|
||||
|
||||
void RCTStatus::callJail(QString chatId, QString path, QString params, double callbackId) {
|
||||
Q_D(RCTStatus);
|
||||
qDebug() << "call of RCTStatus::callJail with param chatId: " << chatId << " path: " << path << " params: " << params << " and callback id: " << callbackId;
|
||||
|
||||
const char* result = Call(chatId.toUtf8().data(), path.toUtf8().data(), params.toUtf8().data());
|
||||
qDebug() << "RCTStatus::callJail callJail result: " << result;
|
||||
d->bridge->invokePromiseCallback(callbackId, QVariantList{result});
|
||||
}
|
||||
|
||||
void RCTStatus::getDeviceUUID(double callbackId) {
|
||||
Q_D(RCTStatus);
|
||||
qDebug() << "call of RCTStatus::getDeviceUUID";
|
||||
|
@ -113,12 +84,12 @@ void RCTStatus::startNode(QString configString) {
|
|||
qDebug() << " RCTStatus::startNode configString: " << jsonDoc.toVariant().toMap();
|
||||
QVariantMap configJSON = jsonDoc.toVariant().toMap();
|
||||
|
||||
QString newKeystoreUrl = "keystore";
|
||||
|
||||
int networkId = configJSON["NetworkId"].toInt();
|
||||
QString dataDir = configJSON["DataDir"].toString();
|
||||
|
||||
QString networkDir = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + "/" + dataDir;
|
||||
QString rootDirPath = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + "/";
|
||||
QString networkDir = rootDirPath + dataDir;
|
||||
QString keyStoreDir = rootDirPath + "keystore";
|
||||
QDir dir(networkDir);
|
||||
if (!dir.exists()) {
|
||||
dir.mkpath(".");
|
||||
|
@ -136,7 +107,7 @@ void RCTStatus::startNode(QString configString) {
|
|||
|
||||
qDebug() << " RCTStatus::startNode GenerateConfig configString: " << jsonDoc.toVariant().toMap();
|
||||
QVariantMap generatedConfig = jsonDoc.toVariant().toMap();
|
||||
generatedConfig["KeyStoreDir"] = newKeystoreUrl;
|
||||
generatedConfig["KeyStoreDir"] = keyStoreDir;
|
||||
generatedConfig["LogEnabled"] = true;
|
||||
generatedConfig["LogFile"] = networkDir + "/geth.log";
|
||||
//generatedConfig["LogLevel"] = "DEBUG";
|
||||
|
|
|
@ -32,9 +32,6 @@ public:
|
|||
QList<ModuleMethod*> methodsToExport() override;
|
||||
QVariantMap constantsToExport() override;
|
||||
|
||||
Q_INVOKABLE void initJail(QString js, double callbackId);
|
||||
Q_INVOKABLE void parseJail(QString chatId, QString js, double callbackId);
|
||||
Q_INVOKABLE void callJail(QString chatId, QString path, QString params, double callbackId);
|
||||
Q_INVOKABLE void startNode(QString configString);
|
||||
Q_INVOKABLE void shouldMoveToInternalStorage(double callbackId);
|
||||
Q_INVOKABLE void moveToInternalStorage(double callbackId);
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
(ns status-im.ui.components.desktop.events
|
||||
(:require [status-im.utils.handlers :as handlers]
|
||||
[status-im.utils.handlers-macro :as handlers-macro]))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:show-desktop-tab
|
||||
(fn [{:keys [db] :as cofx} [_ tab-name]]
|
||||
{:db (assoc-in db [:desktop/desktop :tab-view-id] tab-name)}))
|
|
@ -1,5 +1,6 @@
|
|||
(ns status-im.ui.components.desktop.tabs
|
||||
(:require [re-frame.core :as re-frame]
|
||||
status-im.ui.components.desktop.events
|
||||
[status-im.ui.components.icons.vector-icons :as icons]
|
||||
[taoensso.timbre :as log]
|
||||
[status-im.ui.components.colors :as colors]
|
||||
|
@ -40,7 +41,7 @@
|
|||
:disabled active?
|
||||
:on-press #(do
|
||||
(re-frame/dispatch [:navigate-to :home])
|
||||
(re-frame/dispatch [:set-in [:desktop/desktop :tab-view-id] view-id]))}
|
||||
(re-frame/dispatch [:show-desktop-tab view-id]))}
|
||||
[react/view
|
||||
[content active?]]])
|
||||
|
||||
|
|
|
@ -5,11 +5,12 @@
|
|||
[clojure.string :as string]))
|
||||
|
||||
(defn- validate-pub-key [whisper-identity {:keys [address public-key]}]
|
||||
(when (and whisper-identity (not (string/blank? whisper-identity)))
|
||||
(cond
|
||||
(#{(hex/normalize-hex address) (hex/normalize-hex public-key)}
|
||||
(hex/normalize-hex whisper-identity))
|
||||
(i18n/label :t/can-not-add-yourself)
|
||||
(cond
|
||||
(string/blank? whisper-identity)
|
||||
(i18n/label :t/use-valid-contact-code)
|
||||
(#{(hex/normalize-hex address) (hex/normalize-hex public-key)}
|
||||
(hex/normalize-hex whisper-identity))
|
||||
(i18n/label :t/can-not-add-yourself)
|
||||
|
||||
(not (spec/valid? :global/public-key whisper-identity))
|
||||
(i18n/label :t/use-valid-contact-code))))
|
||||
(not (spec/valid? :global/public-key whisper-identity))
|
||||
(i18n/label :t/use-valid-contact-code)))
|
||||
|
|
|
@ -7,4 +7,4 @@
|
|||
:<- [:get :contacts/new-identity]
|
||||
:<- [:get-current-account]
|
||||
(fn [[new-identity account]]
|
||||
(db/validate-pub-key new-identity account)))
|
||||
(db/validate-pub-key new-identity account)))
|
||||
|
|
|
@ -62,34 +62,53 @@
|
|||
{:flex 1
|
||||
:background-color colors/gray-lighter})
|
||||
|
||||
(def img-container
|
||||
{:height 56
|
||||
:justify-content :center})
|
||||
|
||||
(def messages-scrollview-inner
|
||||
{:padding-vertical 46})
|
||||
|
||||
(def photo-style
|
||||
{:borderRadius 20
|
||||
:width 40
|
||||
:height 40
|
||||
:margin-right 8})
|
||||
{:border-radius 20
|
||||
:width 40
|
||||
:height 40
|
||||
:margin-right 8})
|
||||
|
||||
(def photo-style-toolbar
|
||||
{:border-radius 32
|
||||
:width 32
|
||||
:height 32
|
||||
:margin-right 8})
|
||||
|
||||
(defn topic-image [color]
|
||||
(merge photo-style-toolbar
|
||||
{:background-color color
|
||||
:align-items :center
|
||||
:justify-content :center}))
|
||||
|
||||
(def topic-text
|
||||
{:font-size 18
|
||||
:color colors/white})
|
||||
|
||||
(def toolbar-chat-view
|
||||
{:align-items :center
|
||||
:padding 11
|
||||
{:margin-left 11
|
||||
:justify-content :center})
|
||||
|
||||
(def toolbar-chat-name
|
||||
{:font-size 16
|
||||
:color :black
|
||||
:font-weight "600"})
|
||||
:font-weight "300"})
|
||||
|
||||
(def add-contact
|
||||
{:background-color :white
|
||||
:border-radius 6
|
||||
:margin-top 3
|
||||
:padding 4})
|
||||
:padding-top 1})
|
||||
|
||||
(def add-contact-text
|
||||
{:font-size 14
|
||||
:color colors/gray})
|
||||
:color colors/blue})
|
||||
|
||||
(def message-text
|
||||
{:font-size 14})
|
||||
|
@ -113,4 +132,41 @@
|
|||
|
||||
(def chat-view
|
||||
{:flex 1
|
||||
:background-color :white})
|
||||
:background-color :white})
|
||||
|
||||
(defn contact-card-text [color]
|
||||
{:color color
|
||||
:font-size 14})
|
||||
|
||||
(def contact-card-gray-text
|
||||
{:color colors/gray
|
||||
:font-size 14})
|
||||
|
||||
(def chat-profile-body
|
||||
{:margin 32})
|
||||
|
||||
(def chat-profile-row
|
||||
{:flex-direction :row
|
||||
:align-items :center
|
||||
:margin-bottom 10})
|
||||
|
||||
(def chat-profile-icon-container
|
||||
{:background-color (colors/alpha colors/blue 0.1)
|
||||
:justify-content :center
|
||||
:align-items :center
|
||||
:border-radius 15
|
||||
;; not sure idiomatic reagent for multiple style values
|
||||
;; for margin
|
||||
:width 22
|
||||
:height 22
|
||||
:margin-right 10})
|
||||
|
||||
(defn chat-profile-icon [color]
|
||||
{:tint-color color
|
||||
:width 15
|
||||
:height 15})
|
||||
|
||||
(def chat-profile-contact-code
|
||||
{:color colors/gray
|
||||
:margin-top 10
|
||||
:margin-bottom 5})
|
||||
|
|
|
@ -13,32 +13,40 @@
|
|||
[status-im.ui.components.react :as react]
|
||||
[status-im.ui.components.colors :as colors]
|
||||
[status-im.chat.views.message.datemark :as message.datemark]
|
||||
[status-im.ui.screens.desktop.main.tabs.profile.views :as profile.views]
|
||||
[status-im.ui.components.icons.vector-icons :as vector-icons]
|
||||
[status-im.ui.screens.desktop.main.chat.styles :as styles]
|
||||
[status-im.i18n :as i18n]))
|
||||
|
||||
(views/defview toolbar-chat-view []
|
||||
(views/letsubs [{:keys [chat-id name public-key public? group-chat]} [:get-current-chat]
|
||||
{:keys [pending?]} [:get-current-chat-contact]]
|
||||
(let [chat-name (str
|
||||
(if public? "#" "")
|
||||
(if (string/blank? name)
|
||||
(gfycat.core/generate-gfy public-key)
|
||||
(or name
|
||||
(i18n/label :t/chat-name))))]
|
||||
[react/view {:style styles/toolbar-chat-view}
|
||||
[react/view {:style {:flex-direction :row}}
|
||||
(when public?
|
||||
[icons/icon :icons/public-chat])
|
||||
(when (and group-chat (not public?))
|
||||
[icons/icon :icons/group-chat])
|
||||
[react/text {:style styles/toolbar-chat-name}
|
||||
chat-name]]
|
||||
(views/letsubs [{:keys [chat-id public-key public? group-chat color]} [:get-current-chat]
|
||||
{:keys [pending? whisper-identity photo-path]} [:get-current-chat-contact]
|
||||
current-chat-name [:get-current-chat-name]]
|
||||
[react/view {:style styles/toolbar-chat-view}
|
||||
[react/view {:style {:flex-direction :row
|
||||
:align-items :center}}
|
||||
|
||||
[react/view {:style styles/img-container}
|
||||
(if public?
|
||||
[react/view {:style (styles/topic-image color)}
|
||||
[react/text {:style styles/topic-text}
|
||||
(string/capitalize (first current-chat-name))]]
|
||||
[react/image {:style styles/photo-style-toolbar
|
||||
:source {:uri photo-path}}])]
|
||||
|
||||
[react/view
|
||||
[react/text {:style styles/toolbar-chat-name} current-chat-name]
|
||||
(when pending?
|
||||
[react/touchable-highlight
|
||||
{:on-press #(re-frame/dispatch [:add-pending-contact chat-id])}
|
||||
[react/view {:style styles/add-contact} ;style/add-contact
|
||||
{:on-press #(re-frame/dispatch [:add-contact whisper-identity])}
|
||||
[react/view {:style styles/add-contact}
|
||||
[react/text {:style styles/add-contact-text}
|
||||
(i18n/label :t/add-to-contacts)]]])])))
|
||||
(i18n/label :t/add-to-contacts)]]])]
|
||||
(when (and (not group-chat) (not public?))
|
||||
[react/text {:style {:position :absolute
|
||||
:right 20}
|
||||
:on-press #(re-frame/dispatch [:navigate-to :chat-profile])}
|
||||
(i18n/label :t/view-profile)])]]))
|
||||
|
||||
(views/defview message-author-name [{:keys [outgoing from] :as message}]
|
||||
(views/letsubs [current-account [:get-current-account]
|
||||
|
@ -92,6 +100,8 @@
|
|||
|
||||
(defn message [text me? {:keys [message-id chat-id message-status user-statuses from
|
||||
current-public-key content-type group-chat outgoing type value] :as message}]
|
||||
(when (nil? message-id)
|
||||
(log/debug "nil?" message))
|
||||
(if (= type :datemark)
|
||||
^{:key (str "datemark" message-id)}
|
||||
[message.datemark/chat-datemark value]
|
||||
|
@ -177,3 +187,32 @@
|
|||
[toolbar-chat-view]
|
||||
[messages-view current-chat]
|
||||
[chat-text-input]]))
|
||||
|
||||
(views/defview chat-profile []
|
||||
(views/letsubs [{:keys [pending? whisper-identity public-key] :as contact} [:get-current-chat-contact]]
|
||||
[react/view {:style styles/chat-profile-body}
|
||||
[profile.views/profile-badge contact]
|
||||
;; for private chat, public key will be chat-id
|
||||
[react/view
|
||||
(if pending?
|
||||
[react/touchable-highlight {:on-press #(re-frame/dispatch [:add-contact whisper-identity])}
|
||||
[react/view {:style styles/chat-profile-row}
|
||||
[react/view {:style styles/chat-profile-icon-container
|
||||
:accessibility-label :add-contact-link}
|
||||
[vector-icons/icon :icons/add {:style (styles/chat-profile-icon colors/blue)}]]
|
||||
[react/text {:style (styles/contact-card-text colors/blue)} (i18n/label :t/add-to-contacts)]]]
|
||||
[react/view {:style styles/chat-profile-row}
|
||||
[react/view {:style styles/chat-profile-icon-container
|
||||
:accessibility-label :add-contact-link}
|
||||
[vector-icons/icon :icons/add {:style (styles/chat-profile-icon colors/gray)}]]
|
||||
[react/text {:style (styles/contact-card-text colors/gray)} (i18n/label :t/in-contacts)]])
|
||||
[react/touchable-highlight {:on-press #(re-frame/dispatch [:navigate-to-chat public-key])}
|
||||
[react/view {:style styles/chat-profile-row}
|
||||
[react/view {:style styles/chat-profile-icon-container
|
||||
:accessibility-label :send-message-link}
|
||||
[vector-icons/icon :icons/chats {:style (styles/chat-profile-icon colors/blue)}]]
|
||||
[react/text {:style (styles/contact-card-text colors/blue)}
|
||||
(i18n/label :t/send-message)]]]
|
||||
[react/text {:style styles/chat-profile-contact-code} (i18n/label :t/contact-code)]
|
||||
[react/text {:style {:font-size 14}
|
||||
:selectable true} public-key]]]))
|
||||
|
|
|
@ -63,12 +63,16 @@
|
|||
:accessibility-label :share-my-contact-code-button}
|
||||
[vector-icons/icon :icons/qr {:style {:tint-color colors/blue}}]]]])
|
||||
|
||||
(views/defview profile []
|
||||
(views/letsubs [current-account [:get-current-account]]
|
||||
[react/view styles/profile-view
|
||||
[profile-badge current-account]
|
||||
[share-contact-code]
|
||||
[react/view {:style styles/logout-row}
|
||||
[react/touchable-highlight {:on-press #(re-frame/dispatch [:logout])}
|
||||
[react/text {:style (styles/logout-row-text colors/red)} (i18n/label :t/logout)]]
|
||||
[react/view [react/text {:style (styles/logout-row-text colors/gray)} "V" build/version]]]]))
|
||||
(views/defview profile [user]
|
||||
[react/view styles/profile-view
|
||||
[profile-badge user]
|
||||
[share-contact-code]
|
||||
[react/view {:style styles/logout-row}
|
||||
[react/touchable-highlight {:on-press #(re-frame/dispatch [:logout])}
|
||||
[react/text {:style (styles/logout-row-text colors/red)} (i18n/label :t/logout)]]
|
||||
[react/view [react/text {:style (styles/logout-row-text colors/gray)} "V" build/version " (" build/commit-sha ")"]]]])
|
||||
|
||||
(views/defview profile-data []
|
||||
(views/letsubs
|
||||
[user [:get-current-account]]
|
||||
[profile user]))
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
(views/defview tab-views []
|
||||
(views/letsubs [tab [:get-in [:desktop/desktop :tab-view-id]]]
|
||||
(let [component (case tab
|
||||
:profile profile.views/profile
|
||||
:profile profile.views/profile-data
|
||||
:home home.views/chat-list-view
|
||||
react/view)]
|
||||
[react/view {:style {:flex 1}}
|
||||
|
@ -25,9 +25,10 @@
|
|||
(views/defview main-view []
|
||||
(views/letsubs [view-id [:get :view-id]]
|
||||
(let [component (case view-id
|
||||
:chat chat.views/chat-view
|
||||
:new-contact add-new.views/new-contact
|
||||
:qr-code profile.views/qr-code
|
||||
:chat chat.views/chat-view
|
||||
:new-contact add-new.views/new-contact
|
||||
:qr-code profile.views/qr-code
|
||||
:chat-profile chat.views/chat-profile
|
||||
status-view)]
|
||||
[react/view {:style {:flex 1}}
|
||||
[component]])))
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
:accounts accounts.views/accounts
|
||||
:recover recover.views/recover
|
||||
:create-account create.views/create-account
|
||||
(:new-contact :chat :home :qr-code) main.views/main-views
|
||||
(:new-contact :chat :home :qr-code :chat-profile) main.views/main-views
|
||||
:login login.views/login
|
||||
react/view)]
|
||||
[react/view {:style {:flex 1}}
|
||||
|
|
|
@ -26,6 +26,12 @@
|
|||
:out
|
||||
(string/replace "\n" "")))
|
||||
|
||||
(defmacro get-current-sha []
|
||||
"fetches the latest commit sha from the current branch"
|
||||
(-> (shell/sh "bash" "-c" "git describe --always")
|
||||
:out
|
||||
(string/replace "\n" "")))
|
||||
|
||||
(defmacro git-short-version []
|
||||
(let [version-file-path "VERSION"
|
||||
version-file (io/file version-file-path)]
|
||||
|
|
|
@ -2,4 +2,5 @@
|
|||
(:require-macros [status-im.utils.build :as build]))
|
||||
|
||||
(def version (build/git-short-version))
|
||||
(def commit-sha (build/get-current-sha))
|
||||
(def build-no (build/get-build-no))
|
||||
|
|
Loading…
Reference in New Issue