Skip to content

Commit

Permalink
fix write method and preview script
Browse files Browse the repository at this point in the history
  • Loading branch information
heapwolf committed Mar 14, 2024
1 parent e35d22e commit 97d7256
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 19 deletions.
26 changes: 11 additions & 15 deletions src/components/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -273,29 +273,25 @@ class AppEditor extends Tonic {
const model = this.editor.getModel()

model.onDidChangeContent(async () => {
clearTimeout(this.writeDebounce)

if (!this.projectNode) return
const value = this.editor.getValue()
const coTerminal = document.querySelector('app-terminal')
const coProperties = document.querySelector('app-properties')

this.writeDebounce = setTimeout(() => {
if (this.projectNode.label === 'settings.json' && this.projectNode.parent.id === 'root') {
if (this.projectNode.label === 'settings.json' && this.projectNode.parent.id === 'root') {

try {
this.props.parent.state.settings = JSON.parse(value)
} catch (err) {
coTerminal.error(`Unable to parse settings file (${err.message})`)
return
}
coTerminal.info(`Settings file updated.`)
coProperties.reRender()
parent.activatePreviewWindows()
try {
this.props.parent.state.settings = JSON.parse(value)
} catch (err) {
coTerminal.error(`Unable to parse settings file (${err.message})`)
return
}
coTerminal.info(`Settings file updated.`)
coProperties.reRender()
parent.activatePreviewWindows()
}

this.writeToDisk(this.projectNode, value)
}, 620)
this.writeToDisk(this.projectNode, value)
})

window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', event => {
Expand Down
3 changes: 0 additions & 3 deletions src/components/publish.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ export class DialogPublish extends TonicDialog {
try {
// if not, initialize the directory as a git project
output = await exec('git init', { cwd })
console.log('???', output)
} catch (err) {
output.stderr = err.message
}
Expand All @@ -85,8 +84,6 @@ export class DialogPublish extends TonicDialog {
return this.html``
}

return this.html``

try {
output = await exec('git add . --ignore-errors', { cwd })
} catch (err) {
Expand Down
1 change: 1 addition & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ class AppView extends Tonic {
}

opts.userScript = this.state.userScript

if (scale > 1) {
opts.minWidth = Math.floor(width / scale)
opts.minHeight = Math.floor(height / scale)
Expand Down
5 changes: 4 additions & 1 deletion src/preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ for (const method of consoleMethods) {
}

import application from 'socket:application'
import process from 'socket:process'
import { inspect } from 'socket:util'

const previewWindowTitleBar = 38
Expand Down Expand Up @@ -55,4 +56,6 @@ const scaleToFit = e => {
}
}

window.addEventListener('resize', scaleToFit)
if (process.platform === 'ios' || process.platform === 'android') {
window.addEventListener('resize', scaleToFit)
}

0 comments on commit 97d7256

Please sign in to comment.