Skip to content

Commit

Permalink
title in notification
Browse files Browse the repository at this point in the history
  • Loading branch information
vvsviridov committed Apr 25, 2021
1 parent 3ba54a1 commit 82c1e9e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
14 changes: 7 additions & 7 deletions assets/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ function pageInit() {


async function uploadFile(file) {
await sendNotification(`Upload of ${file.name} started.`)
await sendNotification('Upload started', file.name)
const ref = storageRef.child(fileId)
const uploadTask = ref.put(file)
uploadTask.on(
Expand All @@ -59,11 +59,11 @@ async function uploadFile(file) {


async function downloadFileFromStorage() {
await sendNotification(`Download started.`)
const fileRef = storageRef.child(fileId)
const metadata = await getMetadata(fileRef)
if (!metadata) return
const { contentType, customMetadata: { fileName } } = metadata
await sendNotification('Download started', fileName)
const url = await fileRef.getDownloadURL()
downloadFile(url, fileName, contentType)
}
Expand Down Expand Up @@ -110,7 +110,7 @@ async function successfulUpload(ref, fileName) {
fileName
}
})
await sendNotification(`Upload of ${fileName} finished.`)
await sendNotification('Upload finished',fileName)
}


Expand All @@ -126,7 +126,7 @@ function setDownloadProgress(e) {

async function downloadComplete(blob, fileName, contentType) {
saveFile(blob, fileName, contentType)
await sendNotification(`Download of ${fileName} finished.`)
await sendNotification('Download finished', fileName)
container.classList.remove('active')
document.location.replace('/')
}
Expand Down Expand Up @@ -154,7 +154,7 @@ async function copyToClipboard() {
textarea.value = fileUrl
textarea.select()
document.execCommand('copy')
await sendNotification(`Copied to clipboard ${fileUrl}.`)
await sendNotification('Copied to clipboard', fileUrl)
document.body.removeChild(textarea)
document.location.replace('/')
}
Expand All @@ -180,10 +180,10 @@ async function showError() {
}


async function sendNotification(message) {
async function sendNotification(title = 'Streamio', message) {
const notificationPermission = await Notification.requestPermission()
if (notificationPermission === 'granted') {
new Notification('Stream.io', {
new Notification(title, {
body: message,
icon: './assets/icon-192x192.png'
})
Expand Down
2 changes: 1 addition & 1 deletion serviceworker.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const staticCacheName = 's-streamio-v3'
const staticCacheName = 's-streamio-v1'

const assetUrls = [
'.',
Expand Down

0 comments on commit 82c1e9e

Please sign in to comment.