Update etebase dep and adjust code accordingly.

master
Tom Hacohen 4 years ago
parent 55cae0962d
commit f142b6081a

@ -9,7 +9,7 @@
"@material-ui/lab": "^4.0.0-alpha.56",
"@material-ui/pickers": "^3.2.10",
"@material-ui/styles": "^4.10.0",
"etebase": "^0.14.0",
"etebase": "^0.20.0",
"fuse.js": "^5.0.9-beta",
"ical.js": "^1.4.0",
"immutable": "^4.0.0-rc.12",

@ -48,7 +48,7 @@ class Collection extends React.Component<PropsType> {
return (
<React.Fragment>
<AppBarOverride title={metadata.name}>
<AppBarOverride title={metadata.name!!}>
{isAdmin &&
<>
<IconButton

@ -47,9 +47,8 @@ export default function CollectionChangeEntries(props: PropsType) {
const history = useHistory();
const etebase = useCredentials()!;
const { collection, metadata } = props.collection;
const colType = metadata.type;
const items = useItems(etebase, colType);
const { collection, collectionType } = props.collection;
const items = useItems(etebase, collectionType);
React.useEffect(() => {
if (items) {
@ -71,7 +70,7 @@ export default function CollectionChangeEntries(props: PropsType) {
});
let changelogRoute = "";
switch (colType) {
switch (collectionType) {
case "etebase.vevent": {
changelogRoute = "pim.events._id.log";
break;

@ -40,19 +40,21 @@ interface FormErrors {
export default function CollectionEdit(props: PropsType) {
const [errors, setErrors] = React.useState<FormErrors>({});
const [showDeleteDialog, setShowDeleteDialog] = React.useState(false);
const [info, setInfo] = React.useState<Etebase.CollectionMetadata>();
const [colType, setColType] = React.useState("");
const [info, setInfo] = React.useState<Etebase.ItemMetadata>();
const [selectedColor, setSelectedColor] = React.useState("");
const etebase = useCredentials()!;
React.useEffect(() => {
if (props.collection !== undefined) {
setColType(props.collection.collectionType);
setInfo(props.collection.metadata);
if (props.collection.metadata.color) {
setSelectedColor(props.collection.metadata.color);
}
} else {
setColType("etebase.vcard");
setInfo({
type: "etebase.vcard",
name: "",
description: "",
});
@ -98,7 +100,7 @@ export default function CollectionEdit(props: PropsType) {
collection = props.collection.collection;
await collection.setMeta(meta);
} else {
collection = await colMgr.create(meta, "");
collection = await colMgr.create(colType, meta, "");
}
onSave(collection);
@ -111,7 +113,7 @@ export default function CollectionEdit(props: PropsType) {
const { collection, onDelete, onCancel } = props;
const item = collection?.metadata;
const pageTitle = (item !== undefined) ? item.name : "New Collection";
const pageTitle = (item !== undefined) ? item.name! : "New Collection";
const styles = {
fullWidth: {
@ -130,7 +132,7 @@ export default function CollectionEdit(props: PropsType) {
"etebase.vtodo": "Task List",
};
let collectionColorBox: React.ReactNode;
switch (info.type) {
switch (colType) {
case "etebase.vevent":
case "etebase.vtodo":
collectionColorBox = (
@ -156,8 +158,8 @@ export default function CollectionEdit(props: PropsType) {
<Select
name="type"
required
value={info.type}
onChange={(event: React.ChangeEvent<{ value: string }>) => setInfo({ ...info, type: event.target.value })}
value={colType}
onChange={(event: React.ChangeEvent<{ value: string }>) => setColType(event.target.value)}
>
{Object.keys(colTypes).map((x) => (
<MenuItem key={x} value={x}>{colTypes[x]}</MenuItem>

@ -35,13 +35,14 @@ export default function CollectionImport(props: PropsType) {
}
for (const col of props.collections) {
if (collectionMap[col.metadata.type]) {
const supportsColor = (["etebase.vevent", "etebase.vtodo"].includes(col.metadata.type));
const colType = col.collectionType;
if (collectionMap[colType]) {
const supportsColor = (["etebase.vevent", "etebase.vtodo"].includes(colType));
const colorBox = (supportsColor) ? (
<ColorBox size={24} color={col.metadata.color || defaultColor} />
) : undefined;
collectionMap[col.metadata.type].push((
collectionMap[colType].push((
<ListItem key={col.collection.uid} rightIcon={colorBox} insetChildren
onClick={() => colClicked(col.collection.uid)}>
{col.metadata.name}

@ -38,13 +38,14 @@ export default function CollectionList(props: PropsType) {
}
for (const col of props.collections) {
if (collectionMap[col.metadata.type]) {
const supportsColor = (["etebase.vevent", "etebase.vtodo"].includes(col.metadata.type));
const colType = col.collectionType;
if (collectionMap[colType]) {
const supportsColor = (["etebase.vevent", "etebase.vtodo"].includes(colType));
const colorBox = (supportsColor) ? (
<ColorBox size={24} color={col.metadata.color || defaultColor} />
) : undefined;
collectionMap[col.metadata.type].push((
collectionMap[colType].push((
<ListItem key={col.collection.uid} rightIcon={colorBox} insetChildren
onClick={() => colClicked(col.collection.uid)}>
{col.metadata.name}

@ -158,17 +158,17 @@ export default function ImportDialog(props: PropsType) {
}
}
const { metadata } = props.collection;
const { collectionType } = props.collection;
let acceptTypes;
let dropFunction;
if (metadata.type === "etebase.vcard") {
if (collectionType === "etebase.vcard") {
acceptTypes = ["text/vcard", "text/directory", "text/x-vcard", ".vcf"];
dropFunction = onFileDropContact;
} else if (metadata.type === "etebase.vevent") {
} else if (collectionType === "etebase.vevent") {
acceptTypes = ["text/calendar", ".ics", ".ical"];
dropFunction = onFileDropEvent;
} else if (metadata.type === "etebase.vtodo") {
} else if (collectionType === "etebase.vtodo") {
acceptTypes = ["text/calendar", ".ics", ".ical"];
dropFunction = onFileDropTask;
}

@ -56,8 +56,8 @@ export default function ItemChangeHistory(props: PropsType) {
const [entries, setEntries] = React.useState<CachedItem[]>();
const [dialog, setDialog] = React.useState<CachedItem>();
const etebase = useCredentials()!;
const { collection, metadata } = props.collection;
const items = useItems(etebase, metadata.type);
const { collection, collectionType } = props.collection;
const items = useItems(etebase, collectionType);
const item = items?.get(collection.uid)?.get(props.itemUid);

@ -18,7 +18,8 @@ export const defaultColor = "#8BC34A";
export interface CachedCollection {
collection: Etebase.Collection;
metadata: Etebase.CollectionMetadata;
metadata: Etebase.ItemMetadata;
collectionType: string;
}
export function getRawItemNavigationUid(collectionUid: string, itemUid: string) {
@ -40,6 +41,7 @@ export function getDecryptCollectionsFunction(_colType?: string) {
entries.push({
collection,
metadata: await collection.getMeta(),
collectionType: await collection.getCollectionType(),
});
} catch (e) {
store.dispatch(appendError(e));

@ -59,12 +59,11 @@ function SetupCollectionsPage(props: PagePropsType) {
["etebase.vtodo", "My Tasks"],
];
for (const [type, name] of types) {
const meta: Etebase.CollectionMetadata = {
type,
const meta: Etebase.ItemMetadata = {
name,
mtime: (new Date()).getTime(),
};
const collection = await colMgr.create(meta, "");
const collection = await colMgr.create(type, meta, "");
await colMgr.upload(collection);
}

@ -20,8 +20,8 @@ export const getCollectionsByType = memoize(async function (cachedCollections: C
const collections = await getCollections(cachedCollections, etebase);
const ret: Etebase.Collection[] = [];
for (const col of collections) {
const meta = await col.getMeta();
if (meta.type === colType) {
const collectionType = await col.getCollectionType();
if (collectionType === colType) {
ret.push(col);
}
}

@ -64,10 +64,10 @@ export class SyncManager {
let stoken = syncGeneral?.stoken;
let done = false;
while (!done) {
const collections = await colMgr.list({ stoken, limit });
const collections = await colMgr.list(this.COLLECTION_TYPES, { stoken, limit });
for (const col of collections.data) {
const meta = await col.getMeta();
if (this.COLLECTION_TYPES.includes(meta.type)) {
const collectionType = await col.getCollectionType();
if (this.COLLECTION_TYPES.includes(collectionType)) {
store.dispatch(setCacheCollection(colMgr, col));
await this.fetchCollection(col);
}

@ -4644,10 +4644,10 @@ etag@~1.8.1:
resolved "https://registry.yarnpkg.com/etag/-/etag-1.8.1.tgz#41ae2eeb65efa62268aebfea83ac7d79299b0887"
integrity sha1-Qa4u62XvpiJorr/qg6x9eSmbCIc=
etebase@^0.14.0:
version "0.14.0"
resolved "https://registry.yarnpkg.com/etebase/-/etebase-0.14.0.tgz#87a7e0c678a6c842aa2c71af46aa0d4a11129441"
integrity sha512-PYTgQ1w/qHjazlXoC2XZ7pMccwvIa1Beqv+iY5atwJ4zbxcfqgDgy/ibsOYXftr9h7YHxSnIKuhF5eHLlsh19A==
etebase@^0.20.0:
version "0.20.0"
resolved "https://registry.yarnpkg.com/etebase/-/etebase-0.20.0.tgz#53537d76d71d356d2538c85292ee40ed32fde625"
integrity sha512-jmrrflrSG0kLe1ud3FjDishQ93Jx8s72r9xgkDxlVioxRJamJ0mE/+9KjfDRAFjWAzui8LIblOcIDw+NYPfbsA==
dependencies:
"@msgpack/msgpack" "^1.12.2"
libsodium-wrappers "0.7.6"

Loading…
Cancel
Save