git ssb

10+

Matt McKegg / patchwork



Commit 88e355bf1c958e3361645fd8f0682f252a313b68

Merge pull request #624 from ssbc/5MB_cap

implement attachment block for files >5MB
mix irving authored on 9/15/2017, 2:14:53 AM
GitHub committed on 9/15/2017, 2:14:53 AM
Parent: 2275ef9b617f2f59954bbd3007e579f19adc48cb
Parent: 477c9853277d89b00196c453547b293ae7ef6c0d

Files changed

main-window.jschanged
modules/message/html/compose.jschanged
package.jsonchanged
styles/light/compose.mcsschanged
main-window.jsView
@@ -72,9 +72,10 @@
7272 Array.from(document.head.children)
7373 .filter(c => c.tagName == 'STYLE')
7474 .forEach(c => c.innerText = '')
7575
76- const theme = require('./styles')[name]
76+ var theme = require('./styles')[name]
77+ if (!theme) theme = require('./styles')['light']
7778 insertCss(theme)
7879 })
7980
8081 var container = h(`MainWindow -${process.platform}`, [
modules/message/html/compose.jsView
@@ -52,9 +52,28 @@
5252 disabled: publishing,
5353 placeholder
5454 })
5555
56+ var warningMessage = Value(null)
57+ var warning = h('section.warning',
58+ { className: when(warningMessage, '-open', '-closed') },
59+ [
60+ h('div.warning', warningMessage),
61+ h('div.close', { 'ev-click': () => warningMessage.set(null) }, 'x')
62+ ]
63+ )
5664 var fileInput = api.blob.html.input(file => {
65+ const megabytes = file.size / 1024 / 1024
66+ if (megabytes >= 5) {
67+ const rounded = Math.floor(megabytes*100)/100
68+ warningMessage.set([
69+ h('i.fa.fa-exclamation-triangle'),
70+ h('strong', file.name),
71+ ` is ${rounded}MB - the current limit is 5MB`
72+ ])
73+ return
74+ }
75+
5776 files.push(file)
5877 filesById[file.link] = file
5978
6079 var embed = file.type.indexOf('image/') === 0 ? '!' : ''
@@ -89,8 +108,9 @@
89108 when(expanded, '-expanded', '-contracted')
90109 ]
91110 }, [
92111 textArea,
112+ warning,
93113 actions
94114 ])
95115
96116 addSuggest(textArea, (inputText, cb) => {
package.jsonView
@@ -29,9 +29,9 @@
2929 "hashlru": "^2.2.0",
3030 "insert-css": "~2.0.0",
3131 "level": "~1.7.0",
3232 "lrucache": "^1.0.2",
33- "micro-css": "^2.0.0",
33+ "micro-css": "^2.0.1",
3434 "mime-types": "^2.1.15",
3535 "moment": "^2.18.1",
3636 "mutant": "^3.21.2",
3737 "mutant-pull-reduce": "^1.1.0",
styles/light/compose.mcssView
@@ -20,8 +20,35 @@
2020 background: #ebf7ee;
2121 }
2222 }
2323
24+ section.warning {
25+ color: #fff
26+ font-size: 1.2rem
27+ background-color: #ff00b6
28+
29+ height: 0
30+ padding: 0 .5rem
31+ transition: all ease-in .1s
32+
33+ display: flex
34+ justify-content: space-between
35+
36+
37+ -open {
38+ padding: .5rem
39+ height: initial
40+ }
41+
42+ i.fa { margin-right: .5rem }
43+ div.warning {
44+ strong { margin-right: .3rem }
45+ }
46+ div.close {
47+ cursor: pointer
48+ }
49+ }
50+
2451 section.actions {
2552 display: flex
2653 flex-direction: row
2754 align-items: baseline

Built with git-ssb-web