|
147 | 147 | async loadBookmarks() { |
148 | 148 | const storage = this.getStorageProvider() |
149 | 149 | const bookmarks = await storage.load() |
150 | | - this.setState({ bookmarks }) |
| 150 | + |
| 151 | + // Ensure all bookmarks have the @type property |
| 152 | + const updatedBookmarks = bookmarks.map(bookmark => ({ |
| 153 | + ...bookmark, |
| 154 | + '@type': bookmark['@type'] || 'Bookmark' |
| 155 | + })) |
| 156 | + |
| 157 | + this.setState({ bookmarks: updatedBookmarks }) |
151 | 158 | console.log(`Bookmarks loaded from ${storage.type}`) |
| 159 | + |
| 160 | + // Save if any bookmarks were updated with @type |
| 161 | + if (JSON.stringify(bookmarks) !== JSON.stringify(updatedBookmarks)) { |
| 162 | + this.saveBookmarks() |
| 163 | + } |
152 | 164 | } |
153 | 165 |
|
154 | 166 | handleInputChange = e => { |
|
180 | 192 | title, |
181 | 193 | url: formattedUrl, |
182 | 194 | createdAt: new Date().toISOString(), |
183 | | - read: false |
| 195 | + read: false, |
| 196 | + '@type': 'Bookmark' |
184 | 197 | } |
185 | 198 | ] |
186 | 199 |
|
@@ -244,38 +257,30 @@ <h2 class="text-2xl font-semibold text-indigo-700 mb-4"> |
244 | 257 | </h2> |
245 | 258 | <form onSubmit=${this.addBookmark} class="space-y-4"> |
246 | 259 | <div> |
247 | | - <label |
248 | | - class="block text-sm font-medium text-indigo-600 mb-1" |
249 | | - >Title</label |
250 | | - > |
251 | 260 | <input |
252 | 261 | type="text" |
253 | 262 | name="title" |
254 | 263 | value=${this.state.newBookmark.title} |
255 | 264 | onInput=${this.handleInputChange} |
256 | | - class="w-full px-4 py-2 rounded-md border border-indigo-300 focus:outline-none focus:ring-2 focus:ring-indigo-500" |
257 | | - placeholder="Website Name" |
| 265 | + class="w-full px-4 py-3 rounded-lg border border-gray-200 focus:outline-none focus:ring-2 focus:ring-indigo-400 focus:border-transparent" |
| 266 | + placeholder="Website Title" |
258 | 267 | required |
259 | 268 | /> |
260 | 269 | </div> |
261 | 270 | <div> |
262 | | - <label |
263 | | - class="block text-sm font-medium text-indigo-600 mb-1" |
264 | | - >URL</label |
265 | | - > |
266 | 271 | <input |
267 | 272 | type="text" |
268 | 273 | name="url" |
269 | 274 | value=${this.state.newBookmark.url} |
270 | 275 | onInput=${this.handleInputChange} |
271 | | - class="w-full px-4 py-2 rounded-md border border-indigo-300 focus:outline-none focus:ring-2 focus:ring-indigo-500" |
272 | | - placeholder="https://example.com" |
| 276 | + class="w-full px-4 py-3 rounded-lg border border-gray-200 focus:outline-none focus:ring-2 focus:ring-indigo-400 focus:border-transparent" |
| 277 | + placeholder="Website URL" |
273 | 278 | required |
274 | 279 | /> |
275 | 280 | </div> |
276 | 281 | <button |
277 | 282 | type="submit" |
278 | | - class="w-full bg-gradient-to-r from-blue-400 to-indigo-500 text-white py-2 px-4 rounded-md hover:from-blue-500 hover:to-indigo-600 transition duration-300 ease-in-out transform hover:scale-105 focus:outline-none focus:ring-2 focus:ring-indigo-500" |
| 283 | + class="w-full bg-indigo-500 text-white py-3 px-4 rounded-lg hover:bg-indigo-600 transition duration-300 ease-in-out focus:outline-none focus:ring-2 focus:ring-indigo-500" |
279 | 284 | > |
280 | 285 | Add Bookmark |
281 | 286 | </button> |
|
0 commit comments