Use ascii sum for computing hash for avatar color
This commit is contained in:
parent
b3b9f49464
commit
45f0d120e2
2 changed files with 4 additions and 2 deletions
|
@ -12,6 +12,7 @@ import 'package:photos/core/constants.dart';
|
|||
import 'package:photos/core/event_bus.dart';
|
||||
import 'package:photos/events/clear_selections_event.dart';
|
||||
import 'package:photos/events/files_updated_event.dart';
|
||||
import 'package:photos/extensions/string_ext.dart';
|
||||
import 'package:photos/models/file.dart';
|
||||
import 'package:photos/models/selected_files.dart';
|
||||
import 'package:photos/theme/ente_theme.dart';
|
||||
|
@ -415,7 +416,7 @@ class _LazyLoadingGridViewState extends State<LazyLoadingGridView> {
|
|||
final avatarColors = getEnteColorScheme(context).avatarColors;
|
||||
final int randomID = file.ownerID != _currentUserID
|
||||
? file.ownerID
|
||||
: file.pubMagicMetadata.uploaderName.hashCode;
|
||||
: file.pubMagicMetadata.uploaderName.sumAsciiValues;
|
||||
selectionColor = avatarColors[(randomID).remainder(avatarColors.length)];
|
||||
}
|
||||
return GestureDetector(
|
||||
|
|
|
@ -11,6 +11,7 @@ import 'package:photos/db/files_db.dart';
|
|||
import 'package:photos/db/trash_db.dart';
|
||||
import 'package:photos/events/files_updated_event.dart';
|
||||
import 'package:photos/events/local_photos_updated_event.dart';
|
||||
import 'package:photos/extensions/string_ext.dart';
|
||||
import 'package:photos/models/collection.dart';
|
||||
import 'package:photos/models/file.dart';
|
||||
import 'package:photos/models/file_type.dart';
|
||||
|
@ -132,7 +133,7 @@ class _ThumbnailWidgetState extends State<ThumbnailWidget> {
|
|||
// get avatar color
|
||||
OwnerAvatarOverlayIcon(
|
||||
User(
|
||||
id: widget.file.pubMagicMetadata.uploaderName.hashCode,
|
||||
id: widget.file.pubMagicMetadata.uploaderName.sumAsciiValues,
|
||||
email: owner.email,
|
||||
name: widget.file.pubMagicMetadata.uploaderName,
|
||||
),
|
||||
|
|
Loading…
Reference in a new issue