Skip to content

Commit

Permalink
Merge pull request #510 from golos-blockchain/apk
Browse files Browse the repository at this point in the history
apk -> beta
  • Loading branch information
1aerostorm authored Nov 22, 2024
2 parents 68605e5 + dd3ec60 commit 6081598
Show file tree
Hide file tree
Showing 114 changed files with 3,041 additions and 317 deletions.
159 changes: 117 additions & 42 deletions app/MainApp.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,41 @@ import renderApp from 'app/renderApp'
import golos from 'golos-lib-js'
import tt from 'counterpart'

import { openAppSettings } from 'app/components/pages/app/AppSettings'
import * as api from 'app/utils/APIWrapper'
import getState from 'app/utils/StateBuilder'
import { checkUpdates } from './appUpdater'
import { addShortcut } from 'app/utils/app/ShortcutUtils'
import { checkUpdates } from 'app/utils/app/UpdateUtils'
import defaultCfg from 'app/app_cfg'
require('app/cookieHelper')

const appConfig = window.appSettings.load()
let appConfig
if (process.env.MOBILE_APP) {
console.log('Loading app config...')
let cfg = localStorage.getItem('app_settings')
if (cfg) {
try {
cfg = JSON.parse(cfg)
// Add here migrations
cfg = { ...defaultCfg, ...cfg }
} catch (err) {
console.error('Cannot parse app_settings', err)
cfg = defaultCfg
}
} else {
cfg = defaultCfg
}
if (!cfg.ws_connection_client) {
cfg.ws_connection_client = cfg.ws_connection_app[0].address
}
if (cfg.images.use_img_proxy === undefined) {
cfg.images.use_img_proxy = true
}
cfg.app_version = defaultCfg.app_version
appConfig = cfg
} else {
appConfig = window.appSettings.load()
}

const initialState = {
offchain: {
Expand All @@ -28,60 +57,106 @@ window.$STM_Config = initialState.offchain.config
window.$STM_csrf = null // not used in app

function closeSplash() {
if (window.appSplash)
window.appSplash.contentLoaded()
try {
if (process.env.MOBILE_APP) {
navigator.splashscreen.hide()
} else {
window.appSplash.contentLoaded()
}
} catch (err) {
console.error('closeSplash', err)
}
}

const isSettings = () => {
return window.location.hash === '#app-settings' ||
window.location.pathname === '/__app_settings'
}

function showNodeError() {
alert(tt('app_settings.node_error_NODE', { NODE: $STM_Config.ws_connection_client }))
if (isSettings()) return
if (confirm(tt('app_settings.node_error_new_NODE', { NODE: $STM_Config.ws_connection_client })
+ ' ' + tt('app_settings.node_error_new_NODE2') + '?')) {
openAppSettings()
}
}

const showError = (err, label = '') => {
if (!process.env.MOBILE_APP) return
alert(label + ' error:\n'
+ (err && err.toString()) + '\n'
+ (err && JSON.stringify(err.stack))
)
}

async function initState() {
// these are need for getState
await golos.importNativeLib();
const config = initialState.offchain.config
golos.config.set('websocket', config.ws_connection_client)
if (config.chain_id)
golos.config.set('chain_id', config.chain_id)

const { pathname } = window.location
if (pathname.startsWith('/__app_')) {
return {
content: {}
try {
// these are need for getState
await golos.importNativeLib();
const config = initialState.offchain.config
golos.config.set('websocket', config.ws_connection_client)
if (config.chain_id)
golos.config.set('chain_id', config.chain_id)

const { pathname } = window.location
if (pathname.startsWith('/__app_')) {
return {
content: {}
}
}
}

let splashTimeout = setTimeout(() => {
closeSplash()
showNodeError()
}, 30000)
// First add - for case if all failed at all, and not rendering
if (process.env.MOBILE_APP) {
await addShortcut({
id: 'the_settings',
shortLabel: 'Настройки',
longLabel: 'Настройки',
hash: '#app-settings'
})
}

let splashTimeout = setTimeout(() => {
closeSplash()
showNodeError()
}, 30000)

const doUpdate = Math.random() > 0.7
if (doUpdate) {
try {
$STM_Config.add_notify_site = await checkUpdates()
} catch (err) {
console.error('Cannot check updates', err)
clearTimeout(splashTimeout)
closeSplash()
alert('Cannot check updates' + err)
//showError(err, 'Cannot check updates')
}
}

let onchain
let nodeError = null
try {
onchain = await getState(api, pathname, initialState.offchain)
} catch (error) {
nodeError = error
}

try {
$STM_Config.add_notify_site = await checkUpdates()
} catch (err) {
console.error('Cannot check updates', err)
clearTimeout(splashTimeout)
closeSplash()
alert('Cannot check updates' + err)
}

let onchain
let nodeError = null
try {
onchain = await getState(api, pathname, initialState.offchain)
} catch (error) {
nodeError = error
}

clearTimeout(splashTimeout)
closeSplash()
if (nodeError) {
showNodeError()
throw nodeError
}

if (nodeError) {
showNodeError()
throw nodeError
return onchain
} catch (err) {
if (isSettings()) {
console.error(err)
return
}
showError(err, 'initState')
}

return onchain
}

initState().then((onchain) => {
Expand Down
79 changes: 79 additions & 0 deletions app/app_cfg.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
/* Only Mobile. Generated automatically. Do not edit. */
module.exports = {
"app_version": "1.5.0",
"ws_connection_app": [
{
"address": "wss://apibeta.golos.today/ws"
},
{
"address": "wss://api.golos.id/ws"
},
{
"address": "wss://api.aleksw.space/ws"
},
{
"address": "wss://api-golos.blckchnd.com/ws"
}
],
"ws_connection_exchange": "wss://apibeta.golos.today/ws",
"logo": {
"icon": "https://i.imgur.com/Q7GCdPf.png",
"title": "https://i.imgur.com/36zv8We.png"
},
"images": {
"img_proxy_prefix": "https://devimages.golos.today",
"img_proxy_backup_prefix": "https://steemitimages.com",
"upload_image": "https://api.imgur.com/3/image",
"client_id": "6c09ebf8c548126"
},
"wallet_service": {
"host": "https://devwallet.golos.today"
},
"messenger_service": {
"host": "https://devchat.golos.app"
},
"auth_service": {
"host": "https://dev.golos.app",
"custom_client": "blogs"
},
"notify_service": {
"host": "https://devnotify.golos.app",
"host_ws": "wss://devnotify.golos.app/ws"
},
"elastic_search": {
"url": "https://search.golos.today",
"login": "golosclient",
"password": "golosclient"
},
"apidex_service": {
"host": "https://devapi-dex.golos.app",
"host_local": "https://devapi-dex.golos.app"
},
"app_updater": {
"host": "https://files.golos.app"
},
"forums": {
"white_list": [
"fm-golostalk",
"fm-prizmtalk",
"fm-graphenetalks"
],
"fm-golostalk": {
"domain": "golostalk.com"
},
"fm-prizmtalk": {
"domain": "prizmtalk.com"
},
"fm-graphenetalks": {
"domain": "forum.gph.ai"
}
},
"hidden_assets": {
"RUDEX": true,
"PRIZM": true,
"DOGECOIN": true,
"YMZEC": true,
"YMWMZ": true,
"YMBTC": true
}
}
13 changes: 13 additions & 0 deletions app/assets/icons/badge-new-nobg.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 12 additions & 0 deletions app/assets/icons/badge-new.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/app/android48x48.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 6081598

Please sign in to comment.