refresh edited insights panel on change (#10180)

* refresh edited insights panel on change

* move api simpleHash to shared utils getSimpleHash

* Simply reactivity fix for time-series

* Remove unused import

Co-authored-by: rijkvanzanten <rijkvanzanten@me.com>
This commit is contained in:
Azri Kahar
2021-12-02 01:26:55 +08:00
committed by GitHub
parent 569a8dd7db
commit 8dec148ca2
5 changed files with 21 additions and 12 deletions

View File

@@ -1,5 +1,4 @@
import { simpleHash } from './get-simple-hash';
import { getSimpleHash } from '@directus/shared/utils';
/**
* Generate an index name for a given collection + fields combination.
*
@@ -20,7 +19,7 @@ export function getDefaultIndexName(
if (indexName.length <= 60) return indexName;
const suffix = `__${simpleHash(indexName)}_${type}`;
const suffix = `__${getSimpleHash(indexName)}_${type}`;
const prefix = indexName.substring(0, 60 - suffix.length);
return `${prefix}${suffix}`;

View File

@@ -1,13 +0,0 @@
/**
* Generate a simple short hash for a given string
* This is not cryptographically secure in any way, and has a high chance of collision
*/
export function simpleHash(str: string) {
let hash = 0;
for (let i = 0; i < str.length; hash &= hash) {
hash = 31 * hash + str.charCodeAt(i++);
}
return Math.abs(hash).toString(16);
}