Skip to content

Commit

Permalink
fix: rm local apps (#1333)
Browse files Browse the repository at this point in the history
* v

* Update satolist.js

* v
  • Loading branch information
maxgithubprofile authored Dec 16, 2024
1 parent 906d73f commit 81004b3
Show file tree
Hide file tree
Showing 4 changed files with 105 additions and 10 deletions.
29 changes: 25 additions & 4 deletions js/functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -9802,6 +9802,31 @@ checkConnection = function () {
}
}

localSearch = function(s1 = '', s2 = '', level = 0.6){

if(!s1) return 0
if(!s2) return 1

s1 = s1.toLowerCase()
s2 = s2.toLowerCase()

if (s1.indexOf(s2) > -1) return 1

var parts = s1.split(/[ \t\v\r\n\f,.]+/)

var m = 0

_.each(parts, (part) => {
var eq = stringEqTrig(part, s2)

if (eq > level && eq > m) m = eq
})

if(m < 0 || !m) m = 0

return m
}

stringEqTrig = function (s1, s2) {

if (!s1) s1 = ''
Expand All @@ -9818,8 +9843,6 @@ stringEqTrig = function (s1, s2) {
return ps.toLowerCase().replace(/[^a-zа-я0-9&]*/g, '');
}



var makeTr = function (w) {
var trs = {};

Expand All @@ -9830,8 +9853,6 @@ stringEqTrig = function (s1, s2) {

else c = w[index];



return c;
}

Expand Down
11 changes: 8 additions & 3 deletions js/lib/apps/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1233,6 +1233,8 @@ var BastyonApps = function (app) {

_.each(localdata, (info, id) => {

if(!id || id == 'undefined') return

var saving = {
id,
cached: {},
Expand Down Expand Up @@ -1606,6 +1608,9 @@ var BastyonApps = function (app) {
}

var loadAllAppsFromLocalhost = function () {

return []

let apps = [];
for (let i = 0; i < localStorage.length; i++) {
const key = localStorage.key(i);
Expand Down Expand Up @@ -1788,7 +1793,7 @@ var BastyonApps = function (app) {

var promises = []
const developApps = app.developapps || [];
const localApps = loadAllAppsFromLocalhost() || [];
const localApps = [] //loadAllAppsFromLocalhost() || [];
const allApps = [...developApps, ...localApps];

if (allApps.length > 0) {
Expand Down Expand Up @@ -1839,9 +1844,9 @@ var BastyonApps = function (app) {
console.log("INSTALLED LOCAL", installedLocal)


_.forEach(installedLocal, (info) => {
/*_.forEach(installedLocal, (info) => {
info?.id && install(info.data, info.cached)
})
})*/

promises.push(Promise.all(_.map(installedLocal, (info) => {

Expand Down
71 changes: 70 additions & 1 deletion js/lib/client/sdk.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ var pSDK = function ({ app, api, actions }) {
},

userInfoLight: {
time: 30000
time: 120000
},

userState: {
Expand Down Expand Up @@ -759,6 +759,17 @@ var pSDK = function ({ app, api, actions }) {
self.userInfo = {
keys: ['userInfoFull', 'userInfoLight'],

objkey : 'address',

searchIndex : function(obj){
var sobj = {
name : {v : (obj.n || obj.name), c : 5},
about : {v : (obj.a || obj.about), c : 1}
}

return sobj
},

cleanData: function (rawinfo) {
return _.filter(_.map(rawinfo, (c) => {

Expand Down Expand Up @@ -1861,6 +1872,18 @@ var pSDK = function ({ app, api, actions }) {
self.share = {
keys: ['share'],

objkey : 'txid',

searchIndex : function(obj){
var sobj = {
caption : {v : (obj.c || obj.caption), c : 2},
message : {v : (obj.b || obj.message), c : 1},
tags : {v : (obj.t || obj.tags || []).join(' '), c : 1}
}

return sobj
},

request: function (executor, hash, cacheIndex) {

return request('share', hash, (data) => {
Expand Down Expand Up @@ -3039,6 +3062,52 @@ var pSDK = function ({ app, api, actions }) {
prepareStorages()
}

self.search = function(type, str = ''){
if(!self[type]) return []

var meta = self[type]

var objs = []

_.each(meta.keys, (key) => {
objs = objs.concat(_.toArray(objects[key]))
})

if (meta.objkey){
objs = _.uniq(objs, (o) => {
return o[meta.objkey]
})
}

var si = meta.searchIndex

var executor = function(obj){
var ind = si(obj)
var value = 0

_.each(ind, ({v = '', c = 1}) => {

console.log('localSearch(v, str)', localSearch(v, str), v, str, c)

value += localSearch(v, str) * c
})

return value
}

console.log('objs', objs)

var resultObjects = _.map(objs, (obj) => {
var value = executor(obj)

return {
obj, value
}
})

return Promise.resolve(resultObjects)
}

self.ws = {
update : function(type, wsdata){

Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

"version": "0.9.105",

"versionsuffix": "3",
"versionsuffix": "4",
"cordovaversion": "1.8.105",
"cordovaversioncode": "1801053",
"cordovaversioncode": "1801054",

"description": "Bastyon desktop application",
"author": "Pocketnet Community <[email protected]>",
Expand Down

0 comments on commit 81004b3

Please sign in to comment.