MCPcopy Create free account
hub / github.com/firebase/codelab-friendlychat-web / onMediaFileSelected

Function onMediaFileSelected

web-start/src/index.js:108–128  ·  view source on GitHub ↗
(event)

Source from the content-addressed store, hash-verified

106
107// Triggered when a file is selected via the media picker.
108function onMediaFileSelected(event) {
109 event.preventDefault();
110 var file = event.target.files[0];
111
112 // Clear the selection in the file picker input.
113 imageFormElement.reset();
114
115 // Check if the file is an image.
116 if (!file.type.match('image.*')) {
117 var data = {
118 message: 'You can only share images',
119 timeout: 2000,
120 };
121 signInSnackbarElement.MaterialSnackbar.showSnackbar(data);
122 return;
123 }
124 // Check if the user is signed-in
125 if (checkSignedInWithMessage()) {
126 saveImageMessage(file);
127 }
128}
129
130// Triggered when the send new message form is submitted.
131function onMessageFormSubmit(e) {

Callers

nothing calls this directly

Calls 2

checkSignedInWithMessageFunction · 0.70
saveImageMessageFunction · 0.70

Tested by

no test coverage detected