Skip to content
This repository was archived by the owner on Oct 1, 2019. It is now read-only.

Commit 92bd50c

Browse files
author
finnzeit
committed
Remove console log, update send file function, edit README
1 parent 2914be9 commit 92bd50c

File tree

4 files changed

+26
-40
lines changed

4 files changed

+26
-40
lines changed

README.md

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,14 @@
44
[![Build Status](https://travis-ci.org/finnzeit/instant.svg?branch=master)](https://travis-ci.org/finnzeit/instant)
55
[![codebeat badge](https://codebeat.co/badges/1b33c26b-9165-454f-b3df-dbe4dfb56c9e)](https://codebeat.co/projects/github.amrom.workers.dev-finnzeit-instant-master)
66

7-
Try out at [finnzeit.github.io/instant](https://finnzeit.github.io/instant/) or [https://instant-4cf24.firebaseapp.com](https://instant-4cf24.firebaseapp.com)
7+
Try out at [zeit.js.org/instant](https://zeit.js.org/instant/) or [https://instant-4cf24.firebaseapp.com](https://instant-4cf24.firebaseapp.com)
88

99
## Current features
1010
- Create, login with an account
1111
- Sign in with Facebook account
1212
- Send text messages, photos and files in realtime
1313
- Create channels for multiple topics
1414

15-
## Team members
16-
- Nguyễn Vũ Quốc Thiện
17-
- Dư Cao Tiến
18-
- Phạm Trọng Vinh
19-
2015
## Development server
2116
Run `ng serve` for a dev server. Navigate to `http://localhost:4200/`. The app will automatically reload if you change any of the source files.
2217

src/app/home/chat/chat.component.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,7 @@ export class ChatComponent implements AfterViewChecked, OnChanges {
3333
if (event.target && event.target.files && event.target.files.length) {
3434
const file = event.target.files[0] as File;
3535
console.log(file);
36-
if (file.type.match('image.*')) {
37-
this.afService.sendImage(this.channelId, file);
38-
} else {
39-
this.afService.sendFile(this.channelId, file);
40-
}
36+
this.afService.sendFile(this.channelId, file)
4137
}
4238
}
4339

src/app/home/home.component.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ export class HomeComponent {
2929

3030
this.channels = afService.channels;
3131
this.afService.defaultChannelId.subscribe(value => this.channelId = value);
32-
console.log(`This: ${this.channelId}`);
3332
}
3433

3534
logout() {

src/app/shared/services/firebase.ts

Lines changed: 24 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ export class AngularFire {
3838
limitToFirst: 1
3939
}
4040
}).subscribe(items => {
41-
console.log(items[0].$key);
4241
this.defaultChannelId.next(items[0].$key);
4342
});
4443
}
@@ -90,40 +89,37 @@ export class AngularFire {
9089
this.db.list('channelMessages/' + channel).push(message);
9190
}
9291

93-
sendImage(channel, file: File) {
94-
const storageRef = firebase.storage().ref();
95-
let uploadTask: firebase.storage.UploadTask;
96-
uploadTask = storageRef.child('images/' + this.afAuth.auth.currentUser.uid + '/' + Date.now() + '/' + file.name).put(file);
97-
98-
uploadTask.on(firebase.storage.TaskEvent.STATE_CHANGED, null, (error) => {
99-
console.error('There was an error uploading file to Firebase Storage: ', error);
100-
}, () => {
101-
const url = uploadTask.snapshot.downloadURL;
102-
this.saveFile(channel, {
103-
displayName: this.displayName,
104-
email: this.email,
105-
imageUrl: url,
106-
timestamp: Date.now(),
107-
});
108-
});
109-
}
110-
11192
sendFile(channel, file: File) {
93+
let propName: String;
11294
const storageRef = firebase.storage().ref();
11395
let uploadTask: firebase.storage.UploadTask;
114-
uploadTask = storageRef.child('files/' + this.afAuth.auth.currentUser.uid + '/' + Date.now() + '/' + file.name).put(file);
115-
96+
if (file.type.match('image.*')) {
97+
propName = 'imageUrl';
98+
uploadTask = storageRef.child('images/' + this.afAuth.auth.currentUser.uid + '/' + Date.now() + '/' + file.name).put(file);
99+
} else {
100+
propName = 'fileUrl';
101+
uploadTask = storageRef.child('files/' + this.afAuth.auth.currentUser.uid + '/' + Date.now() + '/' + file.name).put(file);
102+
}
116103
uploadTask.on(firebase.storage.TaskEvent.STATE_CHANGED, null, (error) => {
117104
console.error('There was an error uploading file to Firebase Storage: ', error);
118105
}, () => {
119106
const url = uploadTask.snapshot.downloadURL;
120-
this.saveFile(channel, {
121-
displayName: this.displayName,
122-
email: this.email,
123-
fileName: file.name,
124-
fileUrl: url,
125-
timestamp: Date.now(),
126-
});
107+
if (file.type.match('image.*')) {
108+
this.saveFile(channel, {
109+
displayName: this.displayName,
110+
email: this.email,
111+
imageUrl: url,
112+
timestamp: Date.now(),
113+
});
114+
} else {
115+
this.saveFile(channel, {
116+
displayName: this.displayName,
117+
email: this.email,
118+
fileName: file.name,
119+
fileUrl: url,
120+
timestamp: Date.now(),
121+
});
122+
}
127123
});
128124
}
129125

0 commit comments

Comments
 (0)