• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

backspace / prison-rideshare-ui / 18065086725

27 Sep 2025 09:19PM UTC coverage: 83.736% (-6.5%) from 90.207%
18065086725

Pull #201

github

web-flow
Merge 790989ccb into 972e0c448
Pull Request #201: Change to pnpm

253 of 319 branches covered (79.31%)

Branch coverage included in aggregate %.

787 of 923 relevant lines covered (85.27%)

23.47 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/app/services/user-socket.js
1
/* eslint-disable ember/no-get */
2
import classic from 'ember-classic-decorator';
3
import Service, { inject as service } from '@ember/service';
4
// TODO restore in #202
5
// import { A } from '@ember/array';
6
// import PhoenixSocket from 'ember-phoenix/app/services/phoenix-socket';
7
// import Ember from 'ember';
8
// import config from '../config/environment';
9

10
@classic
11
export default class UserSocketService extends Service /*extends PhoenixSocket*/ {
12
  @service('session')
13
  session;
14

15
  // init() {
16
  //   super.init(...arguments);
17
  //   this.set('present', A());
18
  //   this.connect();
19
  // }
20

21
  connect() {
22
    // if (Ember.testing || !this.get('session.isAuthenticated')) {
23
    //   return;
24
    // }
25
    // const guardian_token = this.get('session.data.authenticated.access_token');
26
    // super.connect(`${config.DS.socketHost}/socket`, {
27
    //   params: { guardian_token },
28
    // });
29
    // // TODO is this a sensible channel name?
30
    // const channel = this.joinChannel('user:presence');
31
    // channel.on('presence_state', (presenceState) =>
32
    //   this._onPresenceState(presenceState),
33
    // );
34
    // channel.on('presence_diff', (presenceDiff) =>
35
    //   this._onPresenceDiff(presenceDiff),
36
    // );
37
  }
38

39
  _onPresenceState(users) {
40
    this._processJoins(Object.keys(users));
×
41
  }
42

43
  _onPresenceDiff({ leaves, joins }) {
44
    this._processJoins(Object.keys(joins));
×
45
    this._processLeaves(Object.keys(leaves));
×
46
  }
47

48
  _processJoins(keys) {
49
    const present = this.present;
×
50
    keys
×
51
      .map((stringWithPrefix) => this._parseUserString(stringWithPrefix))
×
52
      .forEach((joinId) => {
53
        if (!present.includes(joinId)) {
×
54
          present.pushObject(joinId);
×
55
        }
56
      });
57
  }
58

59
  _processLeaves(keys) {
60
    const present = this.present;
×
61
    keys
×
62
      .map((stringWithPrefix) => this._parseUserString(stringWithPrefix))
×
63
      .forEach((leaveId) => present.removeObject(leaveId));
×
64
  }
65

66
  _parseUserString(stringWithPrefix) {
67
    return stringWithPrefix.split(':')[1];
×
68
  }
69
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc