Better id

This commit is contained in:
syuilo 2018-10-13 19:16:47 +09:00
parent 2b536a7443
commit 3aef5e6748
No known key found for this signature in database
GPG Key ID: BDC4C49D06AB9D69
5 changed files with 7 additions and 7 deletions

View File

@ -142,7 +142,7 @@
localStorage.setItem('shouldFlush', 'false'); localStorage.setItem('shouldFlush', 'false');
// Random // Random
localStorage.setItem('salt', Math.random().toString()); localStorage.setItem('salt', Math.random().toString().substr(2, 8));
// Clear cache (service worker) // Clear cache (service worker)
try { try {

View File

@ -156,7 +156,7 @@ class Pool {
this.channel = channel; this.channel = channel;
this.stream = stream; this.stream = stream;
this.id = Math.random().toString(); this.id = Math.random().toString().substr(2, 8);
this.stream.on('_disconnected_', this.onStreamDisconnected); this.stream.on('_disconnected_', this.onStreamDisconnected);
} }
@ -275,7 +275,7 @@ class NonSharedConnection extends Connection {
super(stream, channel); super(stream, channel);
this.params = params; this.params = params;
this.id = Math.random().toString(); this.id = Math.random().toString().substr(2, 8);
this.connect(); this.connect();
} }

View File

@ -114,7 +114,7 @@ export default define({
this.connection.on('stats', this.onStats); this.connection.on('stats', this.onStats);
this.connection.on('statsLog', this.onStatsLog); this.connection.on('statsLog', this.onStatsLog);
this.connection.send('requestLog',{ this.connection.send('requestLog',{
id: Math.random().toString() id: Math.random().toString().substr(2, 8)
}); });
}, },
beforeDestroy() { beforeDestroy() {

View File

@ -446,7 +446,7 @@ export default class MiOS extends EventEmitter {
const viaStream = this.stream && this.store.state.device.apiViaStream && !forceFetch; const viaStream = this.stream && this.store.state.device.apiViaStream && !forceFetch;
if (viaStream) { if (viaStream) {
const id = Math.random().toString(); const id = Math.random().toString().substr(2, 8);
this.stream.once(`api:${id}`, res => { this.stream.once(`api:${id}`, res => {
if (res == null || Object.keys(res).length == 0) { if (res == null || Object.keys(res).length == 0) {

View File

@ -64,14 +64,14 @@ module.exports = (server: http.Server) => {
})); }));
}; };
main.connectChannel(Math.random().toString(), null, main.connectChannel(Math.random().toString().substr(2, 8), null,
request.resourceURL.pathname === '/' ? 'homeTimeline' : request.resourceURL.pathname === '/' ? 'homeTimeline' :
request.resourceURL.pathname === '/local-timeline' ? 'localTimeline' : request.resourceURL.pathname === '/local-timeline' ? 'localTimeline' :
request.resourceURL.pathname === '/hybrid-timeline' ? 'hybridTimeline' : request.resourceURL.pathname === '/hybrid-timeline' ? 'hybridTimeline' :
request.resourceURL.pathname === '/global-timeline' ? 'globalTimeline' : null); request.resourceURL.pathname === '/global-timeline' ? 'globalTimeline' : null);
if (request.resourceURL.pathname === '/') { if (request.resourceURL.pathname === '/') {
main.connectChannel(Math.random().toString(), null, 'main'); main.connectChannel(Math.random().toString().substr(2, 8), null, 'main');
} }
} }