Merge branch 'refactor/use-null-coalesce-etc'

Reviewed-on: FoundKeyGang/FoundKey#195
This commit is contained in:
Norm 2022-10-10 18:43:34 -04:00
commit 13a3581817
Signed by untrusted user: norm
GPG key ID: 7123E30E441E80DE
7 changed files with 7 additions and 7 deletions

View file

@ -56,7 +56,7 @@ export default define(meta, paramDef, async (ps, user) => {
id: genId(),
createdAt: new Date(),
name: ps.name,
parentId: parent !== null ? parent.id : null,
parentId: parent?.id,
userId: user.id,
}).then(x => DriveFolders.findOneByOrFail(x.identifiers[0]));

View file

@ -425,7 +425,7 @@ export async function addFile({
file.createdAt = new Date();
file.userId = user ? user.id : null;
file.userHost = user ? user.host : null;
file.folderId = folder !== null ? folder.id : null;
file.folderId = folder?.id;
file.comment = comment;
file.properties = properties;
file.blurhash = info.blurhash || null;

View file

@ -9,7 +9,7 @@
@drop.stop="onDrop"
>
<i v-if="folder == null" class="fas fa-cloud"></i>
<span>{{ folder == null ? i18n.ts.drive : folder.name }}</span>
<span>{{ folder?.name ?? i18n.ts.drive }}</span>
</div>
</template>

View file

@ -60,7 +60,7 @@ const modal = $ref<InstanceType<typeof MkModal>>();
const menu = defaultStore.state.menu;
const items = Object.keys(menuDef).filter(k => !menu.includes(k)).map(k => menuDef[k]).filter(def => def.show == null ? true : def.show).map(def => ({
const items = Object.keys(menuDef).filter(k => !menu.includes(k)).map(k => menuDef[k]).filter(def => def.show ?? true).map(def => ({
type: def.to ? 'link' : 'button',
text: i18n.ts[def.title],
icon: def.icon,

View file

@ -1 +1 @@
export default n => n == null ? 'N/A' : n.toLocaleString();
export default n => n?.toLocaleString() ?? 'N/A';

View file

@ -85,7 +85,7 @@ async function edit(type) {
type: 'enum',
enum: soundsTypes.map(x => ({
value: x,
label: x == null ? i18n.ts.none : x,
label: x ?? i18n.ts.none,
})),
label: i18n.ts.sound,
default: sounds.value[type].type,

View file

@ -12,7 +12,7 @@ export function getScrollContainer(el: HTMLElement | null): HTMLElement | null {
export function getScrollPosition(el: Element | null): number {
const container = getScrollContainer(el);
return container == null ? window.scrollY : container.scrollTop;
return container?.scrollTop ?? window.scrollY;
}
export function isTopVisible(el: Element | null): boolean {