Skip to content

Commit 97d7256

Browse files
committed
fix write method and preview script
1 parent e35d22e commit 97d7256

File tree

4 files changed

+16
-19
lines changed

4 files changed

+16
-19
lines changed

src/components/editor.js

+11-15
Original file line numberDiff line numberDiff line change
@@ -273,29 +273,25 @@ class AppEditor extends Tonic {
273273
const model = this.editor.getModel()
274274

275275
model.onDidChangeContent(async () => {
276-
clearTimeout(this.writeDebounce)
277-
278276
if (!this.projectNode) return
279277
const value = this.editor.getValue()
280278
const coTerminal = document.querySelector('app-terminal')
281279
const coProperties = document.querySelector('app-properties')
282280

283-
this.writeDebounce = setTimeout(() => {
284-
if (this.projectNode.label === 'settings.json' && this.projectNode.parent.id === 'root') {
281+
if (this.projectNode.label === 'settings.json' && this.projectNode.parent.id === 'root') {
285282

286-
try {
287-
this.props.parent.state.settings = JSON.parse(value)
288-
} catch (err) {
289-
coTerminal.error(`Unable to parse settings file (${err.message})`)
290-
return
291-
}
292-
coTerminal.info(`Settings file updated.`)
293-
coProperties.reRender()
294-
parent.activatePreviewWindows()
283+
try {
284+
this.props.parent.state.settings = JSON.parse(value)
285+
} catch (err) {
286+
coTerminal.error(`Unable to parse settings file (${err.message})`)
287+
return
295288
}
289+
coTerminal.info(`Settings file updated.`)
290+
coProperties.reRender()
291+
parent.activatePreviewWindows()
292+
}
296293

297-
this.writeToDisk(this.projectNode, value)
298-
}, 620)
294+
this.writeToDisk(this.projectNode, value)
299295
})
300296

301297
window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', event => {

src/components/publish.js

-3
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ export class DialogPublish extends TonicDialog {
6161
try {
6262
// if not, initialize the directory as a git project
6363
output = await exec('git init', { cwd })
64-
console.log('???', output)
6564
} catch (err) {
6665
output.stderr = err.message
6766
}
@@ -85,8 +84,6 @@ export class DialogPublish extends TonicDialog {
8584
return this.html``
8685
}
8786

88-
return this.html``
89-
9087
try {
9188
output = await exec('git add . --ignore-errors', { cwd })
9289
} catch (err) {

src/index.js

+1
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,7 @@ class AppView extends Tonic {
217217
}
218218

219219
opts.userScript = this.state.userScript
220+
220221
if (scale > 1) {
221222
opts.minWidth = Math.floor(width / scale)
222223
opts.minHeight = Math.floor(height / scale)

src/preview.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ for (const method of consoleMethods) {
1919
}
2020

2121
import application from 'socket:application'
22+
import process from 'socket:process'
2223
import { inspect } from 'socket:util'
2324

2425
const previewWindowTitleBar = 38
@@ -55,4 +56,6 @@ const scaleToFit = e => {
5556
}
5657
}
5758

58-
window.addEventListener('resize', scaleToFit)
59+
if (process.platform === 'ios' || process.platform === 'android') {
60+
window.addEventListener('resize', scaleToFit)
61+
}

0 commit comments

Comments
 (0)