mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-14 21:27:20 +00:00
refactor(editor): enable the noUncheckedIndexedAccess rule for the data-view package (#9351)
close: BS-2230
This commit is contained in:
@@ -233,9 +233,12 @@ export class FilterConditionView extends SignalWatcher(ShadowlessElement) {
|
||||
if (!type || !argValues || !data) {
|
||||
return;
|
||||
}
|
||||
const argDataList = argValues.map((v, i) =>
|
||||
v ? { value: v, type: type.args[i + 1] } : undefined
|
||||
);
|
||||
const argDataList = argValues.map((v, i) => {
|
||||
if (v == null) return undefined;
|
||||
const argType = type.args[i + 1];
|
||||
if (!argType) return undefined;
|
||||
return { value: v, type: argType };
|
||||
});
|
||||
const valueString = data.shortString?.(...argDataList) ?? '';
|
||||
if (valueString) {
|
||||
return `${name}${valueString}`;
|
||||
|
||||
@@ -262,6 +262,9 @@ export class FilterGroupView extends SignalWatcher(ShadowlessElement) {
|
||||
|
||||
private _clickConditionOps(target: HTMLElement, i: number) {
|
||||
const filter = this.filterGroup.value.conditions[i];
|
||||
if (!filter) {
|
||||
return;
|
||||
}
|
||||
popFilterableSimpleMenu(popupTargetFromElement(target), [
|
||||
menu.group({
|
||||
items: [
|
||||
|
||||
@@ -202,6 +202,9 @@ export class FilterRootView extends SignalWatcher(ShadowlessElement) {
|
||||
|
||||
private _clickConditionOps(target: HTMLElement, i: number) {
|
||||
const filter = this.filterGroup.value.conditions[i];
|
||||
if (!filter) {
|
||||
return;
|
||||
}
|
||||
popFilterableSimpleMenu(popupTargetFromElement(target), [
|
||||
menu.action({
|
||||
name: filter.type === 'filter' ? 'Turn into group' : 'Wrap in group',
|
||||
|
||||
@@ -259,7 +259,7 @@ export const popViewOptions = (
|
||||
return;
|
||||
}
|
||||
const isSelected =
|
||||
meta.type === view.manager.currentView$.value.type;
|
||||
meta.type === view.manager.currentView$.value?.type;
|
||||
const iconStyle = styleMap({
|
||||
fontSize: '24px',
|
||||
color: isSelected
|
||||
@@ -285,10 +285,11 @@ export const popViewOptions = (
|
||||
</div>
|
||||
`,
|
||||
select: () => {
|
||||
view.manager.viewChangeType(
|
||||
view.manager.currentViewId$.value,
|
||||
meta.type
|
||||
);
|
||||
const id = view.manager.currentViewId$.value;
|
||||
if (!id) {
|
||||
return;
|
||||
}
|
||||
view.manager.viewChangeType(id, meta.type);
|
||||
dataViewInstance.clearSelection();
|
||||
},
|
||||
class: {},
|
||||
|
||||
@@ -148,7 +148,11 @@ export class DataViewHeaderViews extends WidgetBase {
|
||||
}
|
||||
const views = this.viewManager.views$.value;
|
||||
const index = views.findIndex(v => v === id);
|
||||
const view = this.viewManager.viewGet(views[index]);
|
||||
const viewId = views[index];
|
||||
if (!viewId) {
|
||||
return;
|
||||
}
|
||||
const view = this.viewManager.viewGet(viewId);
|
||||
if (!view) {
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user