-
-
Notifications
You must be signed in to change notification settings - Fork 70
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
[feature] Note To Self #569
base: dev
Are you sure you want to change the base?
Changes from 17 commits
8c65731
30542a3
db0369b
296c8fa
f58936b
b3628eb
8b21bb2
8accf96
50fae37
4c21963
06003b9
21bd3e7
692a013
8c6f827
0008b93
5e20396
5c50218
c99e8fd
588c2f5
2266195
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,11 +28,17 @@ List<User> selectFriendlyUsers(AppState state) { | |
return List.from(roomsDirectUsers); | ||
} | ||
|
||
// Users the authed user has dm'ed | ||
// Users the authed user has encountered | ||
List<User> selectKnownUsers(AppState state) { | ||
final currentUser = state.authStore.currentUser; | ||
final users = state.userStore.users; | ||
final latestUsers = users.values.take(25); | ||
return List.from(latestUsers); | ||
final List<User> latestUsers = List.from(users.values.take(25)); | ||
|
||
if (!latestUsers.any((user) => user.userId == currentUser.userId)) { | ||
latestUsers.insert(0, currentUser); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it's picky, but you could use a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That only works if the user's in the list to begin with though, right? |
||
} | ||
|
||
return latestUsers; | ||
} | ||
|
||
List<User?> roomUsers(AppState state, String? roomId) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,11 @@ | ||
import 'package:equatable/equatable.dart'; | ||
|
||
import 'package:file/memory.dart'; | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_redux/flutter_redux.dart'; | ||
import 'package:redux/redux.dart'; | ||
import 'package:screenshot/screenshot.dart'; | ||
import 'package:syphon/global/dimensions.dart'; | ||
import 'package:syphon/global/formatters.dart'; | ||
import 'package:syphon/global/strings.dart'; | ||
import 'package:syphon/store/index.dart'; | ||
|
@@ -15,6 +18,7 @@ import 'package:syphon/store/user/selectors.dart'; | |
import 'package:syphon/views/home/chat/chat-screen.dart'; | ||
import 'package:syphon/views/navigation.dart'; | ||
import 'package:syphon/views/widgets/appbars/appbar-search.dart'; | ||
import 'package:syphon/views/widgets/avatars/avatar.dart'; | ||
import 'package:syphon/views/widgets/dialogs/dialog-start-chat.dart'; | ||
import 'package:syphon/views/widgets/lists/list-item-user.dart'; | ||
import 'package:syphon/views/widgets/loader/index.dart'; | ||
|
@@ -158,7 +162,8 @@ class SearchUserState extends State<SearchUserScreen> { | |
setState(() { | ||
creatingRoomDisplayName = user.displayName; | ||
}); | ||
final newRoomId = await props!.onCreateChatDirect(user: user); | ||
final newRoomId = | ||
await props!.onCreateChatDirect(user: user, context: context); | ||
|
||
Navigator.pop(dialogContext); | ||
|
||
|
@@ -212,6 +217,7 @@ class SearchUserState extends State<SearchUserScreen> { | |
onTap: () => onAttemptChat(props: props, context: context, user: attemptableUser), | ||
child: ListItemUser( | ||
user: attemptableUser, | ||
currentUser: props.currentUser, | ||
enabled: creatingRoomDisplayName != searchable, | ||
loading: props.loading, | ||
real: false, | ||
|
@@ -230,6 +236,7 @@ class SearchUserState extends State<SearchUserScreen> { | |
onTap: () => onShowUserDetails(context: context, user: user), | ||
child: ListItemUser( | ||
user: user, | ||
currentUser: props.currentUser, | ||
enabled: creatingRoomDisplayName != user.displayName, | ||
loading: props.loading, | ||
onPress: () => onCreateChat( | ||
|
@@ -279,6 +286,7 @@ class SearchUserState extends State<SearchUserScreen> { | |
onTap: () => onShowUserDetails(context: context, user: user), | ||
child: ListItemUser( | ||
user: user, | ||
currentUser: props.currentUser, | ||
enabled: creatingRoomDisplayName != user.displayName, | ||
loading: props.loading, | ||
onPress: () => onCreateChat( | ||
|
@@ -314,6 +322,7 @@ class SearchUserState extends State<SearchUserScreen> { | |
onTap: () => onShowUserDetails(context: context, user: user), | ||
child: ListItemUser( | ||
user: user, | ||
currentUser: props.currentUser, | ||
enabled: creatingRoomDisplayName != user.displayName, | ||
loading: props.loading, | ||
onPress: () => onCreateChat( | ||
|
@@ -377,6 +386,7 @@ class _Props extends Equatable { | |
final bool loading; | ||
final ThemeType themeType; | ||
final bool creatingRoom; | ||
final User currentUser; | ||
final List<User> usersRecent; | ||
final List<User> usersKnown; | ||
final List<dynamic> searchResults; | ||
|
@@ -389,6 +399,7 @@ class _Props extends Equatable { | |
required this.loading, | ||
required this.creatingRoom, | ||
required this.searchResults, | ||
required this.currentUser, | ||
required this.usersRecent, | ||
required this.usersKnown, | ||
required this.onSearch, | ||
|
@@ -407,6 +418,7 @@ class _Props extends Equatable { | |
themeType: store.state.settingsStore.themeSettings.themeType, | ||
loading: store.state.searchStore.loading, | ||
creatingRoom: store.state.roomStore.loading, | ||
currentUser: store.state.authStore.currentUser, | ||
usersKnown: selectKnownUsers(store.state), | ||
usersRecent: selectFriendlyUsers(store.state), | ||
searchResults: store.state.searchStore.searchResults, | ||
|
@@ -421,7 +433,36 @@ class _Props extends Equatable { | |
|
||
store.dispatch(searchUsers(searchText: text)); | ||
}, | ||
onCreateChatDirect: ({required User user}) async { | ||
onCreateChatDirect: ( | ||
{required User user, required BuildContext context}) async { | ||
if (user.userId == store.state.authStore.currentUser.userId) { | ||
//Note to self, create our Avatar | ||
final store = StoreProvider.of<AppState>(context); | ||
final screenshotController = ScreenshotController(); | ||
final avatar = MemoryFileSystem().file('avatar.png'); | ||
|
||
await screenshotController | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ignore the previous message, I just realized the Icon is an asset. You should be able to convert this to a bytestream without taking a screenshot. I can push something in a branch to help with this There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thank you. It has been driving me nuts how to get it out of its SVG |
||
.captureFromWidget( | ||
Avatar( | ||
alt: Strings.labelNoteToSelf, | ||
icon: Icons.sticky_note_2_outlined, | ||
size: Dimensions.avatarSizeMax, | ||
background: Theme.of(context).primaryColor, | ||
).build(context), | ||
EdGeraghty marked this conversation as resolved.
Show resolved
Hide resolved
|
||
context: context) | ||
.then((capturedAvatar) { | ||
avatar.writeAsBytesSync(capturedAvatar); | ||
}); | ||
|
||
return store.dispatch( | ||
createRoom( | ||
isDirect: true, | ||
invites: <User>[user], | ||
avatarFile: avatar, | ||
), | ||
); | ||
} | ||
|
||
return store.dispatch( | ||
createRoom( | ||
isDirect: true, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good form on this line. It's a one liner, but it's easy to read