Fix DM reminders trying to load guild data
This commit is contained in:
parent
5e82a687f9
commit
8881ef0f85
2
Cargo.lock
generated
2
Cargo.lock
generated
@ -2431,7 +2431,7 @@ checksum = "adad44e29e4c806119491a7f06f03de4d1af22c3a680dd47f1e6e179439d1f56"
|
||||
|
||||
[[package]]
|
||||
name = "reminder-rs"
|
||||
version = "1.7.19"
|
||||
version = "1.7.20"
|
||||
dependencies = [
|
||||
"base64 0.22.1",
|
||||
"chrono",
|
||||
|
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "reminder-rs"
|
||||
version = "1.7.19"
|
||||
version = "1.7.20"
|
||||
authors = ["Jude Southworth <judesouthworth@pm.me>"]
|
||||
edition = "2021"
|
||||
license = "AGPL-3.0 only"
|
||||
|
@ -7,6 +7,10 @@ import { useGuild } from "./useGuild";
|
||||
export const Mentions = ({ input }) => {
|
||||
const guild = useGuild();
|
||||
|
||||
return <>{guild && <_Mentions guild={guild} input={input} />}</>;
|
||||
};
|
||||
|
||||
const _Mentions = ({ guild, input }) => {
|
||||
const { data: roles } = useQuery(fetchGuildRoles(guild));
|
||||
const { data: channels } = useQuery(fetchGuildChannels(guild));
|
||||
const { data: emojis } = useQuery(fetchGuildEmojis(guild));
|
||||
|
@ -45,6 +45,37 @@ function defaultReminder(): Reminder {
|
||||
export const CreateReminder = () => {
|
||||
const guild = useGuild();
|
||||
|
||||
if (guild) {
|
||||
return <_Guild guild={guild} />;
|
||||
} else {
|
||||
return <_User />;
|
||||
}
|
||||
};
|
||||
|
||||
const _User = () => {
|
||||
const [reminder, setReminder] = useState(defaultReminder());
|
||||
const [collapsed, setCollapsed] = useState(false);
|
||||
|
||||
return (
|
||||
<ReminderContext.Provider value={[reminder, setReminder]}>
|
||||
<div class={collapsed ? "reminderContent is-collapsed" : "reminderContent"}>
|
||||
<TopBar
|
||||
isCreating={true}
|
||||
toggleCollapsed={() => {
|
||||
setCollapsed(!collapsed);
|
||||
}}
|
||||
/>
|
||||
<div class="columns reminder-settings">
|
||||
<Message />
|
||||
<Settings />
|
||||
</div>
|
||||
<CreateButtonRow />
|
||||
</div>
|
||||
</ReminderContext.Provider>
|
||||
);
|
||||
};
|
||||
|
||||
const _Guild = ({ guild }) => {
|
||||
const [reminder, setReminder] = useState(defaultReminder());
|
||||
const [collapsed, setCollapsed] = useState(false);
|
||||
|
||||
|
@ -53,7 +53,7 @@ export const TimezonePicker = () => {
|
||||
|
||||
const TimezoneModal = ({ setModalOpen }) => {
|
||||
const browserTimezone = DateTime.now().zoneName;
|
||||
const [selectedZone, setSelectedZone] = useTimezone();
|
||||
const [selectedZone] = useTimezone();
|
||||
|
||||
const queryClient = useQueryClient();
|
||||
const { isLoading, isError, data } = useQuery(fetchUserInfo());
|
||||
|
@ -11,12 +11,7 @@ enum Sort {
|
||||
}
|
||||
|
||||
export const UserReminders = () => {
|
||||
const {
|
||||
isSuccess,
|
||||
isFetching,
|
||||
isFetched,
|
||||
data: guildReminders,
|
||||
} = useQuery(fetchUserReminders());
|
||||
const { isSuccess, isFetching, isFetched, data: reminders } = useQuery(fetchUserReminders());
|
||||
|
||||
const [collapsed, setCollapsed] = useState(false);
|
||||
const [sort, setSort] = useState(Sort.Time);
|
||||
@ -85,7 +80,7 @@ export const UserReminders = () => {
|
||||
|
||||
<div id={"guildReminders"} className={isFetching ? "loading" : ""}>
|
||||
{isSuccess &&
|
||||
guildReminders
|
||||
reminders
|
||||
.sort((r1, r2) => {
|
||||
if (sort === Sort.Time) {
|
||||
return r1.utc_time > r2.utc_time ? 1 : -1;
|
||||
|
@ -52,6 +52,7 @@ async fn _initialize(ctx: Context, pool: impl Executor<'_, Database = Database>
|
||||
|
||||
for reminder in reminders {
|
||||
reminder.send(pool, ctx.clone()).await;
|
||||
let _ = sd_notify::notify(false, &[NotifyState::Watchdog]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9,7 +9,7 @@ WorkingDirectory=/etc/reminder-rs
|
||||
Restart=always
|
||||
RestartSec=10
|
||||
Environment="reminder_rs=warn,postman=warn"
|
||||
WatchdogSec=600
|
||||
WatchdogSec=120
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
|
Loading…
Reference in New Issue
Block a user