mirror of
https://github.com/discourse/discourse.git
synced 2025-02-10 16:32:01 +08:00
![Robin Ward](/assets/img/avatar_default.png)
Sometimes you want stale data right away, then refresh it async. This adds `findStale` to the store for that case. If it returns an object with `hasResults` you can get the `results` and display them. It also returns a `refresh()` method to freshen up the stale data. To enable `localStorage` support for stale data, just include the mixin `StaleLocalStorage` into an adapter for that model. This commit includes a sample of doing that for `Notifications`.
12 lines
286 B
JavaScript
12 lines
286 B
JavaScript
/*eslint no-bitwise:0 */
|
|
|
|
// Note: before changing this be aware the same algo is used server side for avatars.
|
|
export function hashString(str) {
|
|
let hash = 0;
|
|
for (let i = 0; i<str.length; i++) {
|
|
hash = ((hash<<5)-hash) + str.charCodeAt(i);
|
|
hash |= 0;
|
|
}
|
|
return hash;
|
|
}
|