Skip to content

Commit a8458ed

Browse files
authored
add character limit to tags (#15)
1 parent a075417 commit a8458ed

2 files changed

Lines changed: 7 additions & 2 deletions

File tree

modules/atomvm/examples/tagboard/js/board.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ export class TagBoard extends LitElement {
126126
127127
<div class="tags">${this.renderTags(this._tags)}</div>
128128
<form @submit=${this.onTagSubmit}>
129-
<input placeholder="Mensaje" @input=${this.onTagInput} .value=${this._content} />
129+
<input placeholder="Mensaje" @input=${this.onTagInput} .value=${this._content} maxlength="70" />
130130
<button>Enviar</button>
131131
</form>
132132
`

modules/atomvm/examples/tagboard/lib/tag_board_store.ex

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,12 @@ defmodule TagBoard.Store do
77
def add_tag(author, content, timestamp) do
88
case read_tags_from_nvs() do
99
{:ok, current_tags} ->
10-
new_tag = %{id: timestamp, author: author, content: content, timestamp: timestamp}
10+
new_tag = %{
11+
id: timestamp,
12+
author: author,
13+
content: :string.slice(content, 0, 70),
14+
timestamp: timestamp
15+
}
1116

1217
updated_tags = [new_tag | current_tags]
1318

0 commit comments

Comments
 (0)