mirror of
https://github.com/HeyPuter/puter.git
synced 2025-02-02 14:18:43 +08:00
No need for params
when passing params to Apps driver
This commit is contained in:
parent
d7aa08b345
commit
ac8068a139
@ -140,7 +140,7 @@ class AppInformationService {
|
||||
const key_open_count = `apps:open_count:uid:${app_uid}`;
|
||||
const key_user_count = `apps:user_count:uid:${app_uid}`;
|
||||
const key_referral_count = `apps:referral_count:uid:${app_uid}`;
|
||||
|
||||
|
||||
const [cached_open_count, cached_user_count, cached_referral_count] = await Promise.all([
|
||||
kv.get(key_open_count),
|
||||
kv.get(key_user_count),
|
||||
@ -158,12 +158,12 @@ class AppInformationService {
|
||||
}
|
||||
|
||||
const db = this.services.get('database').get(DB_READ, 'apps');
|
||||
|
||||
|
||||
// Helper function to get timestamp for different periods
|
||||
const getTimeRange = (period) => {
|
||||
const now = new Date();
|
||||
const today = new Date(now.getFullYear(), now.getMonth(), now.getDate());
|
||||
|
||||
|
||||
switch(period) {
|
||||
case 'today':
|
||||
return {
|
||||
|
@ -144,7 +144,7 @@ $(document).ready(function () {
|
||||
})
|
||||
}
|
||||
// Get apps
|
||||
puter.apps.list({params:{ icon_size: 64}}).then((resp) => {
|
||||
puter.apps.list({ icon_size: 64 }).then((resp) => {
|
||||
apps = resp;
|
||||
|
||||
// hide loading
|
||||
@ -184,7 +184,7 @@ function refresh_app_list(show_loading = false) {
|
||||
// uncheck the select all checkbox
|
||||
$('.select-all-apps').prop('checked', false);
|
||||
|
||||
puter.apps.list({params:{ icon_size: 64}}).then((apps_res) => {
|
||||
puter.apps.list({ icon_size: 64 }).then((apps_res) => {
|
||||
$('#loading').hide();
|
||||
apps = apps_res;
|
||||
if (apps.length > 0) {
|
||||
@ -315,7 +315,7 @@ async function create_app(title, source_path = null, items = null) {
|
||||
background: false,
|
||||
}).then(async (app) => {
|
||||
// refresh app list
|
||||
puter.apps.list({params:{ icon_size: 64}}).then(async (resp) => {
|
||||
puter.apps.list({ icon_size: 64 }).then(async (resp) => {
|
||||
apps = resp;
|
||||
// Close the 'Creting new app...' modal
|
||||
// but make sure it was shown for at least 2 seconds
|
||||
@ -375,7 +375,7 @@ $(document).on('click', '.delete-app', async function (e) {
|
||||
let app_name = $(this).attr('data-app-name');
|
||||
|
||||
// get app
|
||||
const app_data = await puter.apps.get(app_name, {params:{ icon_size: 16}});
|
||||
const app_data = await puter.apps.get(app_name, { icon_size: 16 });
|
||||
|
||||
if(app_data.metadata?.locked){
|
||||
puter.ui.alert(`<strong>${app_data.title}</strong> is locked and cannot be deleted.`, [
|
||||
@ -758,7 +758,7 @@ async function edit_app_section(cur_app_name) {
|
||||
$('.tab-btn').removeClass('active');
|
||||
$('.tab-btn[data-tab="apps"]').addClass('active');
|
||||
|
||||
let cur_app = await puter.apps.get(cur_app_name, {params: {icon_size: 128}});
|
||||
let cur_app = await puter.apps.get(cur_app_name, {icon_size: 128});
|
||||
currently_editing_app = cur_app;
|
||||
|
||||
// generate edit app section
|
||||
@ -1309,7 +1309,7 @@ $(document).on('click', '.delete-app-settings', async function (e) {
|
||||
let app_title = $(this).attr('data-app-title');
|
||||
|
||||
// check if app is locked
|
||||
const app_data = await puter.apps.get(app_name, {params: {icon_size: 16}});
|
||||
const app_data = await puter.apps.get(app_name, {icon_size: 16});
|
||||
|
||||
if(app_data.metadata?.locked){
|
||||
puter.ui.alert(`<strong>${app_data.title}</strong> is locked and cannot be deleted.`, [
|
||||
@ -1385,7 +1385,7 @@ $(document).on('click', '.back-to-main-btn', function (e) {
|
||||
// get apps
|
||||
$('#loading').show();
|
||||
setTimeout(function () {
|
||||
puter.apps.list({params: {icon_size: 64}}).then((apps_res) => {
|
||||
puter.apps.list({icon_size: 64}).then((apps_res) => {
|
||||
// uncheck the select all checkbox
|
||||
$('.select-all-apps').prop('checked', false);
|
||||
|
||||
@ -2174,7 +2174,7 @@ $(document).on('click', '.insta-deploy-to-existing-app', function (e) {
|
||||
$('.insta-deploy-modal').get(0).close();
|
||||
$('.insta-deploy-existing-app-select').get(0).showModal();
|
||||
$('.insta-deploy-existing-app-list').html(`<div style="margin: 100px auto 10px auto; width: 40px; height:40px;">${loading_spinner}</div>`);
|
||||
puter.apps.list({params:{ icon_size: 64}}).then((apps) => {
|
||||
puter.apps.list({ icon_size: 64 }).then((apps) => {
|
||||
setTimeout(() => {
|
||||
$('.insta-deploy-existing-app-list').html('');
|
||||
if (apps.length === 0)
|
||||
@ -2367,7 +2367,7 @@ $('.insta-deploy-existing-app-select').on('close', function (e) {
|
||||
$('.refresh-app-list').on('click', function (e) {
|
||||
$('.loading-modal').get(0)?.showModal();
|
||||
|
||||
puter.apps.list({params:{ icon_size: 64}}).then((resp) => {
|
||||
puter.apps.list({ icon_size: 64 }).then((resp) => {
|
||||
setTimeout(() => {
|
||||
apps = resp;
|
||||
|
||||
@ -2500,7 +2500,7 @@ $(document).on('click', '.delete-apps-btn', async function (e) {
|
||||
const app_name = $(app).attr('data-app-name');
|
||||
|
||||
// get app
|
||||
const app_data = await puter.apps.get(app_name, {params: {icon_size: 64}});
|
||||
const app_data = await puter.apps.get(app_name, {icon_size: 64 });
|
||||
|
||||
if(app_data.metadata?.locked){
|
||||
if(apps.length === 1){
|
||||
|
@ -1166,7 +1166,7 @@ async function UIDesktop(options){
|
||||
window.app_launched_from_url = window.url_paths[1];
|
||||
// get app metadata
|
||||
try{
|
||||
window.app_launched_from_url = await puter.apps.get(window.url_paths[1], {params: {icon_size: 64}})
|
||||
window.app_launched_from_url = await puter.apps.get(window.url_paths[1], {icon_size: 64})
|
||||
window.is_fullpage_mode = window.app_launched_from_url.metadata?.fullpage_on_landing ?? window.is_fullpage_mode ?? false;
|
||||
|
||||
// show 'Show Desktop' button
|
||||
|
@ -45,7 +45,7 @@ const launch_app = async (options)=>{
|
||||
else if(options.app_obj)
|
||||
app_info = options.app_obj;
|
||||
else
|
||||
app_info = await puter.apps.get(options.name, {params: {icon_size: 64}});
|
||||
app_info = await puter.apps.get(options.name, {icon_size: 64});
|
||||
|
||||
// For backward compatibility reasons we need to make sure that both `uuid` and `uid` are set
|
||||
app_info.uuid = app_info.uuid ?? app_info.uid;
|
||||
|
@ -42,7 +42,7 @@ class Apps{
|
||||
|
||||
// if args is a single object, assume it is the options object
|
||||
if (typeof args[0] === 'object' && args[0] !== null) {
|
||||
options = args[0];
|
||||
options.params = args[0];
|
||||
}
|
||||
|
||||
options.predicate = ['user-can-edit'];
|
||||
@ -65,6 +65,7 @@ class Apps{
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
// * allows for: puter.apps.new({name: 'example-app', indexURL: 'https://example.com'}) *
|
||||
else if (typeof args[0] === 'object' && args[0] !== null) {
|
||||
let options_raw = args[0];
|
||||
@ -123,7 +124,7 @@ class Apps{
|
||||
if (Array.isArray(args) && typeof args[0] === 'string') {
|
||||
// if second argument is an object, assume it is the options object
|
||||
if (typeof args[1] === 'object' && args[1] !== null) {
|
||||
options = args[1];
|
||||
options.params = args[1];
|
||||
}
|
||||
// name
|
||||
options.id = {name: args[0]};
|
||||
@ -131,7 +132,7 @@ class Apps{
|
||||
|
||||
// if first argument is an object, assume it is the options object
|
||||
if (typeof args[0] === 'object' && args[0] !== null) {
|
||||
options = args[0];
|
||||
options.params = args[0];
|
||||
}
|
||||
|
||||
return utils.make_driver_method(['uid'], 'puter-apps', undefined, 'read').call(this, options);
|
||||
|
Loading…
Reference in New Issue
Block a user