<commit_before>// @flow weak

import io from 'socket.io-client';
import Vue from 'vue';
import state from './state';
import messageSchema from '../schemas/message';

/* flow-include
  declare var GLOBAL_ROUTER: any;
*/

const socket = io();

socket.on('err', (message) => {
  console.error(message);
});

socket.on('chooseName success', (username) => {
  state.username = username;
});

socket.on('hash color', (color) => {
  state.hashColor = color;
});

socket.on('load all rooms', (allRooms) => {
  state.allRooms = allRooms;
});

socket.on('load rooms', (rooms) => {
  state.rooms = rooms;
});

socket.on('load room', (room) => {
  Vue.set(state.rooms, room.id, room);
});

socket.on('load room userlist', (room) => {
  Vue.set(state.rooms[room.id], 'users', room.users);
});

socket.on('add room log', (data) => {
  const room = state.rooms[data.room];
  if (!room) return console.error('add room log: room does not exist');
  room.log.push(data);
  if (window.Notification && Notification.permission !== "denied") {
    Notification.requestPermission(function(status) {
      alert('ran');
      let notif = new Notification('ZOA Alert', {
        body: 'New message in ' + room.name + '!',
      });
    });
  }
});

socket.on('finish add auth user', () => {
  socket.emit('user join room', 'lobby');
});<commit_msg>Remove test alert<commit_after>// @flow weak

import io from 'socket.io-client';
import Vue from 'vue';
import state from './state';
import messageSchema from '../schemas/message';

/* flow-include
  declare var GLOBAL_ROUTER: any;
*/

const socket = io();

socket.on('err', (message) => {
  console.error(message);
});

socket.on('chooseName success', (username) => {
  state.username = username;
});

socket.on('hash color', (color) => {
  state.hashColor = color;
});

socket.on('load all rooms', (allRooms) => {
  state.allRooms = allRooms;
});

socket.on('load rooms', (rooms) => {
  state.rooms = rooms;
});

socket.on('load room', (room) => {
  Vue.set(state.rooms, room.id, room);
});

socket.on('load room userlist', (room) => {
  Vue.set(state.rooms[room.id], 'users', room.users);
});

socket.on('add room log', (data) => {
  const room = state.rooms[data.room];
  if (!room) return console.error('add room log: room does not exist');
  room.log.push(data);
  if (window.Notification && Notification.permission !== "denied") {
    Notification.requestPermission(function(status) {
      let notif = new Notification('ZOA Alert', {
        body: 'New message in ' + room.name + '!',
      });
    });
  }
});

socket.on('finish add auth user', () => {
  socket.emit('user join room', 'lobby');
});
{'fraction_non_alphanumeric': 0.20038022813688214, 'fraction_numerical': 0.0, 'mean_word_length': 3.8722222222222222, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4178137', 'n_tokens_mistral': 897, 'n_tokens_neox': 884, 'n_words': 213}