From 7c02a51a46d835eeac995e1f01b44d328cbc839e Mon Sep 17 00:00:00 2001 From: Jiiks Date: Mon, 6 Aug 2018 13:31:49 +0300 Subject: [PATCH] Base connectivity stuff --- .gitignore | 2 + client/src/index.js | 5 +- client/src/modules/bdwebapi.js | 35 ++++++ client/src/modules/connectivity.js | 31 +++++ client/src/modules/modules.js | 2 + .../partials/sidebarview/settingswrap.scss | 71 +++++++++++ client/src/ui/bdmenu.js | 2 + client/src/ui/components/BdSettings.vue | 5 +- .../src/ui/components/bd/ConnectivityView.vue | 112 ++++++++++++++++++ client/src/ui/components/bd/index.js | 1 + 10 files changed, 262 insertions(+), 4 deletions(-) create mode 100644 client/src/modules/bdwebapi.js create mode 100644 client/src/modules/connectivity.js create mode 100644 client/src/ui/components/bd/ConnectivityView.vue diff --git a/.gitignore b/.gitignore index 6ce1cc91..19c52db0 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,5 @@ tests/log.txt # User data tests/data user.config.json +/.vs +/npm-debug.log diff --git a/client/src/index.js b/client/src/index.js index 03c0b662..faab97ae 100644 --- a/client/src/index.js +++ b/client/src/index.js @@ -10,7 +10,7 @@ import { DOM, BdUI, BdMenu, Modals, Reflection, Toasts } from 'ui'; import BdCss from './styles/index.scss'; -import { Events, CssEditor, Globals, Settings, Database, Updater, ModuleManager, PluginManager, ThemeManager, ExtModuleManager, Vendor, WebpackModules, Patcher, MonkeyPatch, ReactComponents, ReactHelpers, ReactAutoPatcher, DiscordApi } from 'modules'; +import { Events, CssEditor, Globals, Settings, Database, Updater, ModuleManager, PluginManager, ThemeManager, ExtModuleManager, Vendor, WebpackModules, Patcher, MonkeyPatch, ReactComponents, ReactHelpers, ReactAutoPatcher, DiscordApi, BdWebApi, Connectivity } from 'modules'; import { ClientLogger as Logger, ClientIPC, Utils } from 'common'; import { EmoteModule } from 'builtin'; import electron from 'electron'; @@ -35,7 +35,8 @@ class BetterDiscord { WebpackModules, Patcher, MonkeyPatch, ReactComponents, ReactHelpers, ReactAutoPatcher, DiscordApi, EmoteModule, - + BdWebApi, + Connectivity, Logger, ClientIPC, Utils, plugins: PluginManager.localContent, diff --git a/client/src/modules/bdwebapi.js b/client/src/modules/bdwebapi.js new file mode 100644 index 00000000..7e69ba17 --- /dev/null +++ b/client/src/modules/bdwebapi.js @@ -0,0 +1,35 @@ +/** + * BetterDiscord Web Apis + * Copyright (c) 2015-present Jiiks/JsSucks - https://github.com/Jiiks / https://github.com/JsSucks + * All rights reserved. + * https://betterdiscord.net + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. +*/ + +import { request } from 'vendor'; + +const APIBASE = 'ifyouareinwebtestthenyouknowwhatthisshouldbe'; // Do not push +const ENDPOINTS = { + 'themes': `${APIBASE}/themes`, + 'users': `${APIBASE}/users`, + 'statistics': `${APIBASE}/statistics` +}; + +export default class BdWebApi { + + static async getThemes() { + const get = await request.get(ENDPOINTS.themes); + return JSON.parse(get); + } + + static async getUsers() { + const get = await request.get(ENDPOINTS.users); + return get; + } + + static async patchStatistics(json) { + return await request({ method: 'PATCH', url: ENDPOINTS.statistics, json }); + } +} diff --git a/client/src/modules/connectivity.js b/client/src/modules/connectivity.js new file mode 100644 index 00000000..af50b925 --- /dev/null +++ b/client/src/modules/connectivity.js @@ -0,0 +1,31 @@ +/** + * BetterDiscord Connectivity Module + * Copyright (c) 2015-present Jiiks/JsSucks - https://github.com/Jiiks / https://github.com/JsSucks + * All rights reserved. + * https://betterdiscord.net + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. +*/ + +import BdWebApi from './bdwebapi'; +import { ClientLogger as Logger } from 'common'; + +const APIBASE = 'ifyouareinwebtestthenyouknowwhatthisshouldbe'; // Do not push +const ENDPOINTS = { + 'themes': `${APIBASE}/themes`, + 'users': `${APIBASE}/users` +}; + +export default class Connectivity { + + static start() { + Logger.info('Connectivity', `Patching anonymous statistics`); + BdWebApi.patchStatistics({ themes: [], plugins: [] }); + setInterval(() => { + Logger.info('Connectivity', `Patching anonymous statistics`); + BdWebApi.patchStatistics({ themes: [], plugins: [] }); + }, 15*60*1000); + } + +} diff --git a/client/src/modules/modules.js b/client/src/modules/modules.js index a038ac76..95ca32d7 100644 --- a/client/src/modules/modules.js +++ b/client/src/modules/modules.js @@ -22,3 +22,5 @@ export { default as EventListener } from './eventlistener'; export { default as SocketProxy } from './socketproxy'; export { default as EventHook } from './eventhook'; export { default as DiscordApi, Modules as DiscordApiModules } from './discordapi'; +export { default as BdWebApi } from './bdwebapi'; +export { default as Connectivity } from './connectivity'; diff --git a/client/src/styles/partials/sidebarview/settingswrap.scss b/client/src/styles/partials/sidebarview/settingswrap.scss index 186fc7d7..07ee9ebc 100644 --- a/client/src/styles/partials/sidebarview/settingswrap.scss +++ b/client/src/styles/partials/sidebarview/settingswrap.scss @@ -46,6 +46,77 @@ } } + .bd-settingswrap-item { + .bd-settingswrap-button-big { + width: 150px; + height: 50px; + border-radius: 5px; + margin-bottom: 20px; + } + + .bd-settingswrap-item-desc { + color: #72767d; + font-size: 14px; + font-weight: 500; + line-height: 20px; + } + + .bd-settingswrap-infobox { + display: flex; + align-items: stretch; + background: rgba(32,34,37,.6); + border-color: #202225; + padding: 20px; + border-radius: 5px; + border-style: solid; + border-width: 1px; + position: relative; + margin-bottom: 20px; + + .bd-settingswrap-infobox-child { + background-size: 100% 100%; + + .bd-wrapper { + margin-bottom: 20px; + + h5 { + color: hsla(210,3%,87%,.3); + letter-spacing: .5px; + font-size: 12px; + text-transform: uppercase; + font-weight: 600; + line-height: 16px; + } + + > span { + color: #b9bbbe; + font-size: 12px; + line-height: 16px; + font-weight: 600; + margin-left: 5px; + margin-right: 5px; + } + + > div { + color: #b9bbbe; + + > span { + color: #b9bbbe; + opacity: 0.5; + } + } + } + } + } + } + + .bd-settingswrap-subheader { + color: #f6f6f7; + text-transform: uppercase; + margin-bottom: 20px; + font-weight: 600; + } + .bd-settingswrap-contents { padding: 0 20px; margin-bottom: 84px; diff --git a/client/src/ui/bdmenu.js b/client/src/ui/bdmenu.js index 0d58adfb..e21de6db 100644 --- a/client/src/ui/bdmenu.js +++ b/client/src/ui/bdmenu.js @@ -37,6 +37,8 @@ export const BdMenuItems = new class { Events.on('update-check-end', () => updater.hidden = true); Events.on('updates-available', () => updater.hidden = false); + this.add({ category: 'Internal', contentid: 'connectivity', text: 'Connectivity' }); + this.addSettingsSet('Internal', 'core', 'Core'); this.addSettingsSet('Internal', 'ui', 'UI'); this.addSettingsSet('Internal', 'emotes', 'Emotes'); diff --git a/client/src/ui/components/BdSettings.vue b/client/src/ui/components/BdSettings.vue index 1c190585..ab77f5b3 100644 --- a/client/src/ui/components/BdSettings.vue +++ b/client/src/ui/components/BdSettings.vue @@ -46,6 +46,7 @@ + @@ -62,7 +63,7 @@ import { BdMenuItems } from 'ui'; import { shell } from 'electron'; import { SidebarView, Sidebar, SidebarItem, ContentColumn } from './sidebar'; - import { SettingsWrapper, SettingsPanel, CssEditorView, PluginsView, ThemesView, UpdaterView } from './bd'; + import { SettingsWrapper, SettingsPanel, CssEditorView, PluginsView, ThemesView, UpdaterView, ConnectivityView } from './bd'; import { SvgX, MiGithubCircle, MiWeb, MiClose, MiTwitterCircle } from './common'; export default { @@ -82,7 +83,7 @@ props: ['active'], components: { SidebarView, Sidebar, SidebarItem, ContentColumn, - SettingsWrapper, SettingsPanel, CssEditorView, PluginsView, ThemesView, UpdaterView, + SettingsWrapper, SettingsPanel, CssEditorView, PluginsView, ThemesView, UpdaterView, ConnectivityView, MiGithubCircle, MiWeb, MiClose, MiTwitterCircle }, computed: { diff --git a/client/src/ui/components/bd/ConnectivityView.vue b/client/src/ui/components/bd/ConnectivityView.vue new file mode 100644 index 00000000..7b3aec84 --- /dev/null +++ b/client/src/ui/components/bd/ConnectivityView.vue @@ -0,0 +1,112 @@ +/** + * BetterDiscord Connectivity View Component + * Copyright (c) 2015-present Jiiks/JsSucks - https://github.com/Jiiks / https://github.com/JsSucks + * All rights reserved. + * https://betterdiscord.net + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. +*/ + + + + diff --git a/client/src/ui/components/bd/index.js b/client/src/ui/components/bd/index.js index 6e75be68..5744e2ad 100644 --- a/client/src/ui/components/bd/index.js +++ b/client/src/ui/components/bd/index.js @@ -5,3 +5,4 @@ export { default as PluginsView } from './PluginsView.vue'; export { default as ThemesView } from './ThemesView.vue'; export { default as UpdaterView } from './UpdaterView.vue'; export { default as BdBadge } from './BdBadge.vue'; +export { default as ConnectivityView } from './ConnectivityView.vue';