git ssb

16+

Dominic / patchbay



Commit 78dec1818c3a24d568c11eeaeaf553ac7a3e9140

block attachments > 5MB (finally)

mix irving committed on 9/10/2017, 11:41:09 PM
Parent: ab6df04b9be0d7e7e8108e0ef9204006980fc7f1

Files changed

message/html/compose.jschanged
message/html/compose.mcsschanged
message/html/compose.jsView
@@ -64,17 +64,37 @@
6464 placeholder
6565 })
6666 textArea.publish = publish // TODO: fix - clunky api for the keyboard shortcut to target
6767
68 + var warningMessage = Value(null)
69 + var warning = h('section.warning',
70 + { className: when(warningMessage, '-open', '-closed') },
71 + [
72 + h('div.warning', warningMessage),
73 + h('div.close', { 'ev-click': () => warningMessage.set(null) }, 'x')
74 + ]
75 + )
6876 var fileInput = api.blob.html.input(file => {
77 +
78 + const megabytes = file.size / 1024 / 1024
79 + if (megabytes >= 5) {
80 + const rounded = Math.floor(megabytes*100)/100
81 + warningMessage.set([
82 + h('i.fa.fa-exclamation-triangle'),
83 + h('strong', file.name),
84 + ` is ${rounded}MB - the current limit is 5MB`
85 + ])
86 + return
87 + }
88 +
6989 files.push(file)
7090 filesById[file.link] = file
7191
72- var embed = file.type.match(/^image/) ? '!' : ''
73- var spacer = embed ? '\n' : ' '
74- var insertLink = spacer + embed + '[' + file.name + ']' + '(' + file.link + ')' + spacer
92 + const pos = textArea.selectionStart
93 + const embed = file.type.match(/^image/) ? '!' : ''
94 + const spacer = embed ? '\n' : ' '
95 + const insertLink = spacer + embed + '[' + file.name + ']' + '(' + file.link + ')' + spacer
7596
76- var pos = textArea.selectionStart
7797 textArea.value = textArea.value.slice(0, pos) + insertLink + textArea.value.slice(pos)
7898
7999 console.log('added:', file)
80100 })
@@ -92,8 +112,9 @@
92112 classList: when(expanded, '-expanded', '-contracted')
93113 }, [
94114 channelInput,
95115 textArea,
116 + warning,
96117 actions
97118 ])
98119
99120 addSuggest(channelInput, (inputText, cb) => {
message/html/compose.mcssView
@@ -26,8 +26,34 @@
2626 cursor: not-allowed
2727 }
2828 }
2929
30 + section.warning {
31 + color: #fff
32 + background-color: red
33 +
34 + height: 0
35 + padding: 0 .5rem
36 + transition: all ease-in .1s
37 +
38 + display: flex
39 + justify-content: space-between
40 +
41 +
42 + -open {
43 + padding: .5rem
44 + height: initial
45 + }
46 +
47 + i.fa { margin-right: .5rem }
48 + div.warning {
49 + strong { margin-right: .3rem }
50 + }
51 + div.close {
52 + cursor: pointer
53 + }
54 + }
55 +
3056 section.actions {
3157 display: flex
3258 flex-direction: row
3359 align-items: baseline

Built with git-ssb-web