From f1bfd363e501b6406d8ecc7c37d2418ea77922ae Mon Sep 17 00:00:00 2001 From: Lucas Phang Date: Fri, 14 May 2021 17:13:49 +1000 Subject: [PATCH] Add display dialog logic --- js/background.js | 4 +++ js/views/app_view.js | 6 ++++ js/views/onion_status_dialog_view.js | 38 ++++++++++++++++++++++++++ stylesheets/_index.scss | 3 +- ts/components/OnionStatusDialog.tsx | 11 +------- ts/components/session/ActionsPanel.tsx | 2 +- ts/window.d.ts | 1 + 7 files changed, 53 insertions(+), 12 deletions(-) create mode 100644 js/views/onion_status_dialog_view.js diff --git a/js/background.js b/js/background.js index 62fc44ddc..3b6e3ac27 100644 --- a/js/background.js +++ b/js/background.js @@ -527,6 +527,10 @@ } }; + window.showOnionStatusDialog = () => { + appView.showOnionStatusDialog(); + } + // Set user's launch count. const prevLaunchCount = window.getSettingValue('launch-count'); const launchCount = !prevLaunchCount ? 1 : prevLaunchCount + 1; diff --git a/js/views/app_view.js b/js/views/app_view.js index bd23dac0e..404141564 100644 --- a/js/views/app_view.js +++ b/js/views/app_view.js @@ -126,6 +126,12 @@ const dialog = new Whisper.SessionNicknameDialog(modifiedOptions); this.el.prepend(dialog.el); }, + showOnionStatusDialog() { + // eslint-disable-next-line no-param-reassign + const theme = this.getThemeObject(); + const dialog = new Whisper.OnionStatusDialogView({theme}); + this.el.prepend(dialog.el); + }, showResetSessionIdDialog() { const theme = this.getThemeObject(); const resetSessionIDDialog = new Whisper.SessionIDResetDialog({ theme }); diff --git a/js/views/onion_status_dialog_view.js b/js/views/onion_status_dialog_view.js new file mode 100644 index 000000000..893f687e9 --- /dev/null +++ b/js/views/onion_status_dialog_view.js @@ -0,0 +1,38 @@ +/* global i18n, Whisper */ + +// eslint-disable-next-line func-names +(function() { + 'use strict'; + + window.Whisper = window.Whisper || {}; + + Whisper.EditProfileDialogView = Whisper.View.extend({ + className: 'loki-dialog modal', + initialize({ theme }) { + this.close = this.close.bind(this); + + this.theme = theme; + + this.$el.focus(); + this.render(); + }, + render() { + this.dialogView = new Whisper.ReactWrapperView({ + className: 'onion-status-dialog', + Component: window.Signal.Components.OnionStatusDialog, + props: { + onClose: this.close, + i18n, + theme: this.theme, + }, + }); + + this.$el.append(this.dialogView.el); + return this; + }, + close() { + this.remove(); + }, + }); + })(); + \ No newline at end of file diff --git a/stylesheets/_index.scss b/stylesheets/_index.scss index 39481fced..47864e729 100644 --- a/stylesheets/_index.scss +++ b/stylesheets/_index.scss @@ -9,7 +9,8 @@ .edit-profile-dialog, .create-group-dialog, -.user-details-dialog { +.user-details-dialog, +.onion-status-dialog { .content { max-width: 100% !important; } diff --git a/ts/components/OnionStatusDialog.tsx b/ts/components/OnionStatusDialog.tsx index 47b666575..69f9967a5 100644 --- a/ts/components/OnionStatusDialog.tsx +++ b/ts/components/OnionStatusDialog.tsx @@ -14,15 +14,6 @@ import { DefaultTheme } from 'styled-components'; import { MAX_USERNAME_LENGTH } from './session/registration/RegistrationTabs'; import { SessionSpinner } from './session/SessionSpinner'; -// interface Props { -// i18n: any; -// profileName: string; -// avatarPath: string; -// pubkey: string; -// onClose: any; -// onOk: any; -// theme: DefaultTheme; -// } interface State { profileName: string; @@ -35,7 +26,7 @@ interface State { interface Props { i18n: any; theme: DefaultTheme; - nodes: Array; + nodes?: Array; onClose: any; } diff --git a/ts/components/session/ActionsPanel.tsx b/ts/components/session/ActionsPanel.tsx index 67876fb4b..03efc4378 100644 --- a/ts/components/session/ActionsPanel.tsx +++ b/ts/components/session/ActionsPanel.tsx @@ -70,7 +70,7 @@ const Section = (props: { type: SectionType; avatarPath?: string }) => { } else if (type === SectionType.PathIndicator) { // Show Path Indicator Modal console.log("status clicked") - // window.showOnionStatusDialog(); + window.showOnionStatusDialog(); } else { dispatch(clearSearch()); diff --git a/ts/window.d.ts b/ts/window.d.ts index 7ca723f2c..5eb9706cf 100644 --- a/ts/window.d.ts +++ b/ts/window.d.ts @@ -69,6 +69,7 @@ declare global { setSettingValue: any; showEditProfileDialog: any; showNicknameDialog: (options: { convoId: string }) => void; + showOnionStatusDialog: any; showResetSessionIdDialog: any; storage: any; textsecure: LibTextsecure;