Skip to content

Commit

Permalink
Fix some tslint warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
pepebecker committed Nov 19, 2019
1 parent 2e0ea76 commit 28eae08
Show file tree
Hide file tree
Showing 39 changed files with 397 additions and 375 deletions.
6 changes: 3 additions & 3 deletions src/angularjs/abstract/abstract-users-list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export class AbstractUsersListController {
protected RoomOpenQueue: IRoomOpenQueue,

) {
if (this.constructor == AbstractUsersListController) {
if (this.constructor === AbstractUsersListController) {
throw new Error('AbstractUsersListController can\'t be instantiated.');
}

Expand Down Expand Up @@ -69,7 +69,7 @@ export class AbstractUsersListController {
let rooms = this.Cache.getPrivateRoomsWithUsers(this.UserStore.currentUser(), user);
if (rooms.length) {
const r = rooms[0];
if (r.getType() == RoomType.OneToOne) {
if (r.getType() === RoomType.OneToOne) {
r.flashHeader();
// The room is already open! Do nothing
return;
Expand All @@ -86,7 +86,7 @@ export class AbstractUsersListController {
this.RoomCreator.createAndPushPrivateRoom([user]).then((room) => {
this.RoomOpenQueue.addRoomWithID(room.rid());
room.open(0);
//let room = RoomStore.getOrCreateRoomWithID(rid);
// let room = RoomStore.getOrCreateRoomWithID(rid);
}, (error) => {
console.log(error);
});
Expand Down
2 changes: 1 addition & 1 deletion src/angularjs/app/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export let myApp = angular.module('myApp',
$provide.decorator('$browser', ['$delegate', ($delegate) => {
$delegate.onUrlChange = () => { };
$delegate.url = () => {
return "";
return '';
};
return $delegate;
}]);
Expand Down
2 changes: 1 addition & 1 deletion src/angularjs/components/chat-settings.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class ChatSettingsController {
saveTranscript() {
const t = this.room.transcript();

if (DEBUG) console.log(t);
if (DEBUG) { console.log(t); }

FileSaver.saveAs(new Blob([t], { type: 'text/plain;charset=utf-8' }), this.room.name + '-transcript.txt');
}
Expand Down
6 changes: 3 additions & 3 deletions src/angularjs/components/friends-list.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ export class FriendsListController extends AbstractUsersListController {
// then alphabetically
this.users.sort((user1, user2) => {
// Sort by who's online first then alphabetcially
let aOnline = this.OnlineConnector.onlineUsers[user1.uid()];
let bOnline = this.OnlineConnector.onlineUsers[user2.uid()];
const aOnline = this.OnlineConnector.onlineUsers[user1.uid()];
const bOnline = this.OnlineConnector.onlineUsers[user2.uid()];

if (aOnline !== bOnline) {
return aOnline ? 1 : -1;
Expand All @@ -90,7 +90,7 @@ export class FriendsListController extends AbstractUsersListController {
this.$timeout(() => {
this.$scope.$digest();
});
};
}

}

Expand Down
9 changes: 4 additions & 5 deletions src/angularjs/components/public-rooms-list.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,25 +55,24 @@ class PublicRoomsListController {
const au = Utils.unORNull(a.getMetaObject().userCreated) ? false : a.getMetaObject().userCreated;
const bu = Utils.unORNull(b.getMetaObject().userCreated) ? false : b.getMetaObject().userCreated;

if (au != bu) {
if (au !== bu) {
return au ? 1 : -1;
}

// Weight
const aw = Utils.unORNull(a.getMetaObject().weight) ? 100 : a.getMetaObject().weight;
const bw = Utils.unORNull(b.getMetaObject().weight) ? 100 : b.getMetaObject().weight;

if (aw != bw) {
if (aw !== bw) {
return aw - bw;
}
else {

const ac = a.getOnlineUserCount();
const bc = b.getOnlineUserCount();

//console.log('1: ' + ac + ', 2: ' + bc);
// console.log('1: ' + ac + ', 2: ' + bc);

if (ac != bc) {
if (ac !== bc) {
return bc - ac;
}
else {
Expand Down
22 changes: 11 additions & 11 deletions src/angularjs/components/room-list-box.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,10 @@ class RoomListBoxController {
this.rooms.sort((a, b) => {
// First order by number of unread messages
// Badge can be null
let ab = a.badge ? a.badge : 0;
let bb = b.badge ? b.badge : 0;
const ab = a.badge ? a.badge : 0;
const bb = b.badge ? b.badge : 0;

if (ab != bb) {
if (ab !== bb) {
return bb - ab;
}
// Otherwise sort them by number of users
Expand All @@ -68,7 +68,7 @@ class RoomListBoxController {
}
});

this.moreChatsMinimized = this.rooms.length == 0;
this.moreChatsMinimized = this.rooms.length === 0;

this.$timeout(() => {
this.$scope.$digest();
Expand All @@ -77,23 +77,23 @@ class RoomListBoxController {

roomClicked(room: IRoom) {
// Get the left most room
let rooms = this.RoomPositionManager.getRooms();
const rooms = this.RoomPositionManager.getRooms();

// Get the last box that's active
for (let i = rooms.length - 1; i >= 0; i--) {
if (rooms[i].active) {

// Get the details of the final room
let offset = rooms[i].offset;
let width = rooms[i].width;
let height = rooms[i].height;
let slot = rooms[i].slot;
const offset = rooms[i].offset;
const width = rooms[i].width;
const height = rooms[i].height;
const slot = rooms[i].slot;

// Update the old room with the position of the new room
rooms[i].setOffset(room.offset);
rooms[i].width = room.width;
rooms[i].height = room.height;
//rooms[i].active = false;
// rooms[i].active = false;
rooms[i].setActive(false);
rooms[i].slot = room.slot;

Expand All @@ -102,7 +102,7 @@ class RoomListBoxController {
room.width = width;
room.height = height;

//room.setSizeToDefault();
// room.setSizeToDefault();
room.setActive(true);
room.badge = null;
room.minimized = false;
Expand Down
9 changes: 4 additions & 5 deletions src/angularjs/connectors/friend-connector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class FriendsConnector implements IFriendsConnector {
) { }

on(uid: string) {
let friendsRef = this.Paths.userFriendsRef(uid);
const friendsRef = this.Paths.userFriendsRef(uid);

friendsRef.on('child_added', (snapshot) => {

Expand All @@ -48,7 +48,7 @@ class FriendsConnector implements IFriendsConnector {
}

off(uid: string) {
let friendsRef = this.Paths.userFriendsRef(uid);
const friendsRef = this.Paths.userFriendsRef(uid);

friendsRef.off('child_added');
friendsRef.off('child_removed');
Expand All @@ -66,7 +66,7 @@ class FriendsConnector implements IFriendsConnector {

user.removeFriend = () => {
snapshot.ref.remove();
}
};
this.addFriend(user);
}

Expand All @@ -77,8 +77,7 @@ class FriendsConnector implements IFriendsConnector {
}

addFriendsFromConfig(friends: string[]) {
for (let i = 0; i < friends.length; i++) {
const uid = friends[i];
for (const uid of friends) {

const user = this.UserStore.getOrCreateUserWithID(uid);
user.ssoFriend = true;
Expand Down
18 changes: 9 additions & 9 deletions src/angularjs/connectors/online-connector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,18 @@ class OnlineConnector implements IOnlineConnector {
}
this.isOn = true;

let onlineUsersRef = this.Paths.onlineUsersRef();
const onlineUsersRef = this.Paths.onlineUsersRef();

onlineUsersRef.on('child_added', (snapshot: firebase.database.DataSnapshot) => {

if (DEBUG) console.log('Online: ' + snapshot.key);
if (DEBUG) { console.log('Online: ' + snapshot.key); }

// Get the UID of the added user
let uid = null;
if (snapshot && snapshot.val()) {
uid = snapshot.key;

let user = this.UserStore.getOrCreateUserWithID(uid);
const user = this.UserStore.getOrCreateUserWithID(uid);

if (this.addOnlineUser(user)) {
// Update the user's rooms
Expand All @@ -62,7 +62,7 @@ class OnlineConnector implements IOnlineConnector {

console.log('Offline: ' + snapshot.key);

let user = this.UserStore.getOrCreateUserWithID(snapshot.key);
const user = this.UserStore.getOrCreateUserWithID(snapshot.key);

user.off();

Expand All @@ -81,19 +81,19 @@ class OnlineConnector implements IOnlineConnector {

this.isOn = false;

//this.onlineUsers = {};
// this.onlineUsers = {};
// having the user.blocked is useful because it means
// that the partials don't have to call a function
// however when you logout you want the flags to be reset
for (let key in this.onlineUsers) {
for (const key in this.onlineUsers) {
if (this.onlineUsers.hasOwnProperty(key)) {
this.onlineUsers[key].blocked = false;
this.onlineUsers[key].friend = false;
}
}
this.onlineUsers = {};

let onlineUsersRef = this.Paths.onlineUsersRef();
const onlineUsersRef = this.Paths.onlineUsersRef();

onlineUsersRef.off('child_added');
onlineUsersRef.off('child_removed');
Expand Down Expand Up @@ -121,7 +121,7 @@ class OnlineConnector implements IOnlineConnector {

removeOnlineUserWithID(uid: string) {
if (uid) {
let user = this.onlineUsers[uid];
const user = this.onlineUsers[uid];
if (user) {
user.online = false;
delete this.onlineUsers[uid];
Expand All @@ -132,7 +132,7 @@ class OnlineConnector implements IOnlineConnector {

onlineUserCount() {
let i = 0;
for (let key in this.onlineUsers) {
for (const key in this.onlineUsers) {
if (this.onlineUsers.hasOwnProperty(key)) {
i++;
}
Expand Down
2 changes: 1 addition & 1 deletion src/angularjs/controllers/chat-bar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class ChatBarController implements IChatBarController {

this.$timeout(() => {
this.$scope.$digest();
})
});
}

}
Expand Down
Loading

0 comments on commit 28eae08

Please sign in to comment.