Skip to content

Draggable Space Ordering and Space Folders#701

Open
CollinBartlam wants to merge 4 commits intocommetchat:mainfrom
CollinBartlam:space-organization
Open

Draggable Space Ordering and Space Folders#701
CollinBartlam wants to merge 4 commits intocommetchat:mainfrom
CollinBartlam:space-organization

Conversation

@CollinBartlam
Copy link
Contributor

Implements #644 by adding persistent reordering of spaces, allowing users to drag and drop spaces into the order they desire. Also implements #646 by adding the ability to drag these spaces in and out of folders to help users organize. All of this information is stored via Matrix account data, which allows changes to sync across different Commet clients/instances. Users can edit folders names or remove folders using either a right-click context menu in the desktop layout or a press and hold in the mobile layout.

Copy link
Contributor

@Airyzz Airyzz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a really cool PR, and will be a great feature to have. I'm mostly just commenting on backend stuff at the moment, haven't had a look over UI yet. Mostly wanting to tweak it to be more inline with how other features in Commet are implemented using Components.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be implemented as a Client Component, with an abstract SidebarLayoutComponent which doesn't implement any matrix-specific functionality, just the bare layout api, and MatrixSidebarLayoutComponent which implements the specifics of how its stored

import 'package:commet/client/sidebar/sidebar_model.dart';

class SidebarData {
static const String accountDataType = 'im.commet.space_sidebar';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use chat.commet.sidebar_layout instead

Future<void> _persist() async {
final data = SidebarData(items: _rawItems);
_lastAccountDataHash = data.toJson().toString();
await SidebarPersistence.writeToAllClients(clientManager.clients, data);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I dont think we should be storing the entire layout in all clients, Ideally each client should only store the layout for its own spaces. As is, this would leak user membership info to the homeserver of your other accounts.

I'd suggest each account stores an order string, similarly to how space children are ordered in the spec

You could still allow creating a folder that stores items from multiple accounts by just using the same folder ID

Map<String, dynamic> toJson() {
return {
'version': version,
'items': items.map((item) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of a list, store in a Map, and sort by order string

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think probably this should be moved out of client and in to a Widget, maybe modify SideNavigationBar to be aware of the component?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

move these into new SidebarLayoutComponent

required this.id,
required this.name,
required this.spaces,
this.isExpanded = false,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

UI state probably shouldn't be stored here, at the moment for subspaces we store expanded state just in the widget itself, which I think is preferable

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems very similar to ResolvedSidebarItem and similar, why do we need both?

late CallManager callManager;

late final DirectMessagesAggregator directMessages;
late final SidebarManager sidebarManager;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I dont think this needs to exist in ClientManager, maybe in the state of SideNavigationBar makes more sense?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Comments