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

feat: #55 User configuration for relay controls #57

Merged
merged 6 commits into from
Dec 22, 2024

Conversation

xurizaemon
Copy link
Contributor

@xurizaemon xurizaemon commented Dec 12, 2024

Works, input welcome!

In this PR

Data / schema changes

  • Adds relayCriteria (all, favedBySelf, containsMarker, notContainsMarker) and relayMarker (string) to User
  • Adds a Constraint class to pass to getNewToots()

UI changes

Below "Bluesky App Password" input on root (/) form:

image

@thilobillerbeck
Copy link
Owner

Thanks for picking up work on this <3

How do you feel about splitting this up into a settings object (or use this existing one?). I don't know how much we want to pump up the main user object. (I have to clean up the settings object anyway at some point :D )

@xurizaemon
Copy link
Contributor Author

xurizaemon commented Dec 12, 2024

I think it's a good idea to use the UserSettings storage if that fits better with your plans.

I tried to implement that but didn't have any luck constructing syntax to update it on save. And AFAICT that UserSettings storage is not yet in use? I'm not familiar with this stack so likely missed some details ...

Storing against User worked for my purposes, happy to refine, appreciate any pointers 😄

What I tried was, below the existing db.User.update() @

skymoth/routes/root.ts

Lines 57 to 66 in db8fae4

await db.user.update({
where: {
id: req.user.id
},
data: {
blueskyHandle: req.body.blueskyHandle,
blueskyToken: req.body.blueskyToken,
blueskyPDS: req.body.blueskyPDS,
}
})

I tried a few variations to update UserSettings, but had no success getting syntax that worked in my testing:

        if (user?.UserSettings) {
            await db.userSettings.update({
                where: {
                    userId: req.user.id,
                },
                data: {
                    relayCriteria: req.body.relayCriteria ?? user.UserSettings.relayCriteria,
                    relayMarker: req.body.relayMarker ?? user.UserSettings.relayMarker,
                },
            });
        }

So I put the storage back against User, which works, and am happy to revisit with guidance. It looks to me that the existing UserSettings columns suggest you already had some thinking about storing similar details, but I'm not clear what is/isn't in use. (It's fine to push new commits to this MR if that suits you, or the storage details could be dealt with in a follow-up if this is sufficient.)

Hah, just realised I had missed committing my migrations to this MR. I will add them in the current state and rebase to target develop branch.

@xurizaemon xurizaemon changed the base branch from main to develop December 12, 2024 18:25
@xurizaemon
Copy link
Contributor Author

xurizaemon commented Dec 19, 2024

@thilobillerbeck I did try using the UserSettings object, but had no luck making that work, so I've prototyped with storage directly on the User schema (for now, anyway).

For my testing, this is working OK so far! Will road test it myself over the xmas/NY break, happy to hear any input or testing feedback folks have.

New contributor to Typescript projects so feedback on style very welcome 😀

@xurizaemon xurizaemon changed the title feat: #55 Mock up user configuration for relay controls feat: #55 User configuration for relay controls Dec 20, 2024
@xurizaemon xurizaemon force-pushed the 55-relay-control branch 2 times, most recently from 4ef5b67 to 3bcfe9b Compare December 20, 2024 20:29
@xurizaemon xurizaemon marked this pull request as ready for review December 20, 2024 20:48
Copy link
Owner

@thilobillerbeck thilobillerbeck left a comment

Choose a reason for hiding this comment

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

Tested and it works, thanks for contributing <3

@thilobillerbeck
Copy link
Owner

🎉 This PR is included in version 0.3.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants