Skip to content

Commit

Permalink
fix the runes export (#6793)
Browse files Browse the repository at this point in the history
  • Loading branch information
julianjelfs authored Nov 12, 2024
1 parent 6dbce5e commit 513a6b7
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 23 deletions.
6 changes: 4 additions & 2 deletions frontend/app/src/components/App.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,8 @@
window.addEventListener("orientationchange", calculateHeight);
window.addEventListener("unhandledrejection", unhandledError);
(<any>window).platformModerator = {
//@ts-ignore
window.platformModerator = {
addHotGroupExclusion,
deleteFrozenGroup,
deleteMessage,
Expand All @@ -130,7 +131,8 @@
removeMessageFilter,
reportedMessages,
};
(<any>window).platformOperator = {
//@ts-ignore
window.platformOperator = {
addRemoveSwapProvider,
setGroupUpgradeConcurrency,
setCommunityUpgradeConcurrency,
Expand Down
15 changes: 6 additions & 9 deletions frontend/app/src/components/calendar/Calendar.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -8,32 +8,29 @@
import { type Snippet } from "svelte";
import { translationCodes } from "../../i18n/i18n";
import { weekDays } from "./weekdays";
import { calendarState, type DateRange } from "./calendarState.svelte.ts"
import { calendarState, type DateRange } from "./calendarState.svelte";
interface Props {
monthTitleTemplate?: Snippet;
dayTemplate?: Snippet<[Date]>;
dateSelected?: (range: DateRange) => void
dateSelected?: (range: DateRange) => void;
}
let {
monthTitleTemplate,
dayTemplate,
dateSelected,
}: Props = $props();
let { monthTitleTemplate, dayTemplate, dateSelected }: Props = $props();
let today = $state(new Date());
let showDate = $state(new Date());
let dates = $state<Date[][]>([]);
let translatedLocale = $derived(translationCodes[$locale || "en"] || "en");
$effect(() => getDates(showDate))
$effect(() => getDates(showDate));
function endOfDay(date: Date): Date {
return new Date(date.getTime() + 24 * 60 * 60 * 1000 - 1);
}
function getDates(start: Date) {
console.log("Getting dates for start date: ", start);
const resp = getMonthCalendar(start);
calendarState.monthTitle = getTitleText(resp.year, resp.month, translatedLocale);
dates = resp.dates;
Expand Down Expand Up @@ -98,7 +95,7 @@
class:today={typeof day === "string" ? false : isSameDay(today, day)}
class="block daily-date-block pointer">
{#if dayTemplate}
{@render dayTemplate(day) }
{@render dayTemplate(day)}
{:else}
{day.getDate()}
{/if}
Expand Down
57 changes: 49 additions & 8 deletions frontend/app/src/components/calendar/calendarState.svelte.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,54 @@
export type DateRange = { date: Date; range: [Date, Date] };
let monthTitle = $state<string>("");
const selectedMonth = $state<number>(0);
const selectedRange = $state<DateRange>({

let monthTitle = $state("");
let selectedMonth = $state(0);
let selectedRange = $state<DateRange>({
date: new Date(),
range: [new Date(), new Date()],
});

export const calendarState = {
monthTitle,
selectedMonth,
selectedRange,
};
class CalendarState {
get monthTitle() {
return monthTitle;
}
set monthTitle(value: string) {
monthTitle = value;
}
get selectedMonth() {
return selectedMonth;
}
set selectedMonth(value: number) {
selectedMonth = value;
}

get selectedRange() {
return selectedRange;
}
set selectedRange(value: DateRange) {
selectedRange = value;
}
}

// This *would* work and in much less verbose. But something converts the code
// and puts the $state initialisation in the constructor which is not allowed.
// To improve this I need to discover what is causing that particular pre-processing ...
// class CalendarState {
// monthTitle = $state("");
// selectedMonth = $state(0);
// selectedRange = $state<DateRange>({
// date: new Date(),
// range: [new Date(), new Date()],
// });
// }

// This also works for reference but it doesn't support derived state
// export const calendarState = $state({
// monthTitle: "",
// selectedMonth: 0,
// selectedRange: {
// date: new Date(),
// range: [new Date(), new Date()],
// },
// });

export const calendarState = new CalendarState();
2 changes: 1 addition & 1 deletion frontend/app/src/components/home/profile/ChitEvents.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import { chitPopup, hideChitIcon, utcMode } from "../../../stores/settings";
import Translatable from "../../Translatable.svelte";
import { menuCloser } from "../../../actions/closeMenu";
import { calendarState, type DateRange } from "../../calendar/calendarState.svelte.ts";
import { calendarState, type DateRange } from "../../calendar/calendarState.svelte";
import Calendar from "../../calendar/Calendar.svelte";
const client = getContext<OpenChat>("client");
Expand Down
3 changes: 1 addition & 2 deletions frontend/app/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
"extends": "../tsconfig",
"compilerOptions": {
"isolatedModules": true,
"outDir": "build",
"allowImportingTsExtensions": true
"outDir": "build"
},
"include": ["./src/**/*"]
}
3 changes: 2 additions & 1 deletion frontend/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"strict": true,
"target": "es2020",
"types": ["jest", "node", "svelte"],
"verbatimModuleSyntax": true
"verbatimModuleSyntax": true,
"useDefineForClassFields": false
}
}

0 comments on commit 513a6b7

Please sign in to comment.