Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use native uuid generator function #11587

Merged
merged 1 commit into from
Oct 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions resources/js/models/chat/create-announcement.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

import UserJson from 'interfaces/user-json';
import { action, autorun, computed, makeObservable, observable } from 'mobx';
import { uuid } from 'utils/seq';
import { present } from 'utils/string';
import { maxMessageLength } from './channel';

Expand Down Expand Up @@ -34,7 +33,7 @@ export default class CreateAnnouncement {
@observable validUsers = new Map<number, UserJson>();

private initialized = false;
private readonly uuid = uuid();
private readonly uuid = crypto.randomUUID();

@computed
get errors() {
Expand Down
3 changes: 1 addition & 2 deletions resources/js/models/chat/message.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,13 @@ import { action, computed, makeObservable, observable } from 'mobx';
import User from 'models/user';
import * as moment from 'moment';
import core from 'osu-core-singleton';
import { uuid } from 'utils/seq';

export default class Message {
@observable channelId = -1;
@observable content = '';
@observable errored = false;
@observable isAction = false;
@observable messageId: number | string = uuid();
@observable messageId: number | string = crypto.randomUUID();
@observable persisted = false;
@observable senderId = -1;
@observable timestamp: string = moment().toISOString();
Expand Down
2 changes: 1 addition & 1 deletion resources/js/turbolinks-overrides.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ Turbolinks.Controller::advanceHistory = (url) ->
location = @lastRenderedLocation
@cache.put location, snapshot.clone()
@lastRenderedLocation = Turbolinks.Location.wrap(url)
@pushHistoryWithLocationAndRestorationIdentifier url, Turbolinks.uuid()
@pushHistoryWithLocationAndRestorationIdentifier url, crypto.randomUUID()


# @lastRenderedLocation must be updated so the most recent url will be used for @cache
Expand Down
1 change: 0 additions & 1 deletion resources/js/turbolinks.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ declare module 'turbolinks' {
controller: Controller;
setProgressBarDelay(delayInMilliseconds: number): void;
supported: boolean;
uuid(): string;
visit(location: string, options?: TurbolinksAction): void;
}
}
4 changes: 0 additions & 4 deletions resources/js/utils/seq.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,3 @@ let currVal = 0;
export function nextVal() {
return ++currVal;
}

export function uuid() {
return Turbolinks.uuid(); // no point rolling our own
}