Skip to content

Commit db05c88

Browse files
add ids and open file
1 parent 23c75e0 commit db05c88

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

todo.html

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,10 +165,11 @@
165165
e.preventDefault()
166166
if (!this.state.newTodo.trim()) return
167167

168+
const now = Date.now()
168169
const newTodos = [
169170
...this.state.todos,
170171
{
171-
id: Date.now(),
172+
'@id': `#${Math.floor(now / 1000)}.${now % 1000}`,
172173
text: this.state.newTodo,
173174
completed: false
174175
}
@@ -198,6 +199,16 @@
198199
this.saveTodos(newTodos)
199200
}
200201

202+
openStorageFile = () => {
203+
const pubkey = localStorage.getItem('pubkey')
204+
if (pubkey) {
205+
const url = `https://nosdav.net/${pubkey}/todos.json`
206+
window.open(url, '_blank')
207+
} else {
208+
alert('No pubkey found. Cannot open storage file.')
209+
}
210+
}
211+
201212
render() {
202213
return html`
203214
<div class="min-h-screen flex flex-col">
@@ -290,6 +301,13 @@
290301
class="text-green-600 bg-green-100 rounded-full px-3 py-1 inline-block"
291302
>
292303
Using nosdav cloud storage
304+
<button
305+
onClick=${this.openStorageFile}
306+
class="ml-2 bg-blue-500 hover:bg-blue-600 text-white rounded-full px-2 py-0.5 text-xs"
307+
title="Open storage file in new tab"
308+
>
309+
View File
310+
</button>
293311
</div>`
294312
: html`<div
295313
class="text-yellow-600 bg-yellow-100 rounded-full px-3 py-1 inline-block"

0 commit comments

Comments
 (0)